Skip to content

Commit

Permalink
expose api only on platforms using nss cert database
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak1556 committed Apr 19, 2016
1 parent 2c0494d commit 2d82865
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
8 changes: 6 additions & 2 deletions atom/browser/api/atom_api_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@ void PassLoginInformation(scoped_refptr<LoginHandler> login_handler,
login_handler->CancelAuth();
}

#if defined(USE_NSS_CERTS)
int ImportIntoCertStore(
CertificateManagerModel* model,
const base::DictionaryValue& options) {
std::string file_data, cert_path;
base::string16 password;
net::CertificateList imported_certs;
int rv;
int rv = -1;
options.GetString("clientCertificate", &cert_path);
options.GetString("password", &password);

Expand All @@ -189,6 +190,7 @@ int ImportIntoCertStore(
}
return rv;
}
#endif

} // namespace

Expand Down Expand Up @@ -402,6 +404,7 @@ bool App::MakeSingleInstance(
}
}

#if defined(USE_NSS_CERTS)
void App::ImportClientCertificate(
const base::DictionaryValue& options,
const net::CompletionCallback& callback) {
Expand Down Expand Up @@ -429,6 +432,7 @@ void App::OnCertificateManagerModelCreated(
*(options.get()));
callback.Run(rv);
}
#endif

mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
Expand Down Expand Up @@ -469,7 +473,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
.SetMethod("allowNTLMCredentialsForAllDomains",
&App::AllowNTLMCredentialsForAllDomains)
.SetMethod("getLocale", &App::GetLocale)
#if defined(OS_LINUX)
#if defined(USE_NSS_CERTS)
.SetMethod("importClientCertificate", &App::ImportClientCertificate)
#endif
.SetMethod("makeSingleInstance", &App::MakeSingleInstance);
Expand Down
13 changes: 12 additions & 1 deletion atom/browser/api/atom_api_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/browser_observer.h"
#include "atom/common/native_mate_converters/callback.h"
#include "chrome/browser/certificate_manager_model.h"
#include "chrome/browser/process_singleton.h"
#include "content/public/browser/gpu_data_manager_observer.h"
#include "native_mate/handle.h"
#include "net/base/completion_callback.h"

#if defined(USE_NSS_CERTS)
#include "chrome/browser/certificate_manager_model.h"
#endif

namespace base {
class FilePath;
}
Expand All @@ -43,10 +46,12 @@ class App : public AtomBrowserClient::Delegate,
int render_process_id,
int render_frame_id);

#if defined(USE_NSS_CERTS)
void OnCertificateManagerModelCreated(
scoped_ptr<base::DictionaryValue> options,
const net::CompletionCallback& callback,
scoped_ptr<CertificateManagerModel> model);
#endif

protected:
App();
Expand Down Expand Up @@ -104,15 +109,21 @@ class App : public AtomBrowserClient::Delegate,
bool MakeSingleInstance(
const ProcessSingleton::NotificationCallback& callback);
std::string GetLocale();

#if defined(USE_NSS_CERTS)
void ImportClientCertificate(const base::DictionaryValue& options,
const net::CompletionCallback& callback);
#endif

#if defined(OS_WIN)
bool IsAeroGlassEnabled();
#endif

scoped_ptr<ProcessSingleton> process_singleton_;

#if defined(USE_NSS_CERTS)
scoped_ptr<CertificateManagerModel> certificate_manager_model_;
#endif

DISALLOW_COPY_AND_ASSIGN(App);
};
Expand Down
3 changes: 3 additions & 0 deletions electron.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@
],
}], # OS=="mac" and mas_build==1
['OS=="linux"', {
'sources': [
'<@(lib_sources_nss)',
],
'link_settings': {
'ldflags': [
# Make binary search for libraries under current directory, so we
Expand Down
6 changes: 4 additions & 2 deletions filenames.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,6 @@
'atom/utility/atom_content_utility_client.h',
'chromium_src/chrome/browser/browser_process.cc',
'chromium_src/chrome/browser/browser_process.h',
'chromium_src/chrome/browser/certificate_manager_model.cc',
'chromium_src/chrome/browser/certificate_manager_model.h',
'chromium_src/chrome/browser/chrome_process_finder_win.cc',
'chromium_src/chrome/browser/chrome_process_finder_win.h',
'chromium_src/chrome/browser/chrome_notification_types.h',
Expand Down Expand Up @@ -519,6 +517,10 @@
'<@(native_mate_files)',
'<(SHARED_INTERMEDIATE_DIR)/atom_natives.h',
],
'lib_sources_nss': [
'chromium_src/chrome/browser/certificate_manager_model.cc',
'chromium_src/chrome/browser/certificate_manager_model.h',
],
'lib_sources_win': [
'chromium_src/chrome/browser/ui/views/color_chooser_dialog.cc',
'chromium_src/chrome/browser/ui/views/color_chooser_dialog.h',
Expand Down

0 comments on commit 2d82865

Please sign in to comment.