diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index ce60fb0aed33..5bae8a179e19 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -681,15 +681,17 @@ void Session::CreateInterruptedDownload(const mate::Dictionary& options) { } void Session::AddPreload(const base::FilePath::StringType& preloadPath) { - g_preloads.push_back(preloadPath); + preloads_.push_back(preloadPath); } + void Session::RemovePreload(const base::FilePath::StringType& preloadPath) { - g_preloads.erase( - std::remove(g_preloads.begin(), g_preloads.end(), preloadPath), - g_preloads.end()); + preloads_.erase( + std::remove(preloads_.begin(), preloads_.end(), preloadPath), + preloads_.end()); } -std::vector Session::GetPreloads() { - return g_preloads; + +std::vector Session::GetPreloads() const { + return preloads_; } v8::Local Session::Cookies(v8::Isolate* isolate) { diff --git a/atom/browser/api/atom_api_session.h b/atom/browser/api/atom_api_session.h index 5d05fbe7390f..bd52a05cf875 100644 --- a/atom/browser/api/atom_api_session.h +++ b/atom/browser/api/atom_api_session.h @@ -84,7 +84,7 @@ class Session: public mate::TrackableObject, void CreateInterruptedDownload(const mate::Dictionary& options); void AddPreload(const base::FilePath::StringType& preloadPath); void RemovePreload(const base::FilePath::StringType& preloadPath); - std::vector GetPreloads(); + std::vector GetPreloads() const; v8::Local Cookies(v8::Isolate* isolate); v8::Local Protocol(v8::Isolate* isolate); v8::Local WebRequest(v8::Isolate* isolate); @@ -107,7 +107,7 @@ class Session: public mate::TrackableObject, std::string devtools_network_emulation_client_id_; scoped_refptr browser_context_; - std::vector g_preloads; + std::vector preloads_; DISALLOW_COPY_AND_ASSIGN(Session); }; diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index 9f4a47895061..1a369dd0e9a0 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -141,10 +141,10 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( v8::Isolate* isolate = v8::Isolate::GetCurrent(); mate::Handle api_web_contents = - atom::api::WebContents::CreateFrom(isolate, web_contents); + atom::api::WebContents::CreateFrom(isolate, web_contents); auto session = atom::api::Session::CreateFrom( - isolate, api_web_contents.get()->GetBrowserContext()); - for (auto preloadPath : session->GetPreloads()) { + isolate, api_web_contents.get()->GetBrowserContext()); + for (const auto& preloadPath : session->GetPreloads()) { if (base::FilePath(preloadPath).IsAbsolute()) command_line->AppendSwitchNative(switches::kSessionPreloadScript, preloadPath);