Remove AtomBrowserContext::SetCookieableSchemes
The standard schemes are already stored, we don't have to duplicate the list for every session.
This commit is contained in:
parent
6cd1aa21af
commit
a14b2c1cf8
4 changed files with 28 additions and 25 deletions
|
@ -42,10 +42,26 @@ void ClearJobFactoryInIO(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
std::vector<std::string> GetStandardSchemes() {
|
||||||
|
return g_standard_schemes;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterStandardSchemes(const std::vector<std::string>& schemes) {
|
||||||
|
g_standard_schemes = schemes;
|
||||||
|
|
||||||
|
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
|
||||||
|
for (const std::string& scheme : schemes) {
|
||||||
|
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
|
||||||
|
policy->RegisterWebSafeScheme(scheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||||
|
atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
|
||||||
|
}
|
||||||
|
|
||||||
Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||||
: request_context_getter_(browser_context->GetRequestContext()),
|
: request_context_getter_(browser_context->GetRequestContext()),
|
||||||
weak_factory_(this) {
|
weak_factory_(this) {
|
||||||
browser_context->SetCookieableSchemes(g_standard_schemes);
|
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,17 +220,7 @@ void RegisterStandardSchemes(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto policy = content::ChildProcessSecurityPolicy::GetInstance();
|
atom::api::RegisterStandardSchemes(schemes);
|
||||||
for (const auto& scheme : schemes) {
|
|
||||||
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
|
|
||||||
policy->RegisterWebSafeScheme(scheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
|
||||||
command_line->AppendSwitchASCII(atom::switches::kStandardSchemes,
|
|
||||||
base::JoinString(schemes, ","));
|
|
||||||
|
|
||||||
atom::api::g_standard_schemes = schemes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||||
|
@ -222,6 +228,7 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.SetMethod("registerStandardSchemes", &RegisterStandardSchemes);
|
dict.SetMethod("registerStandardSchemes", &RegisterStandardSchemes);
|
||||||
|
dict.SetMethod("getStandardSchemes", &atom::api::GetStandardSchemes);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -28,6 +28,9 @@ namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
|
std::vector<std::string> GetStandardSchemes();
|
||||||
|
void RegisterStandardSchemes(const std::vector<std::string>& schemes);
|
||||||
|
|
||||||
class Protocol : public mate::TrackableObject<Protocol> {
|
class Protocol : public mate::TrackableObject<Protocol> {
|
||||||
public:
|
public:
|
||||||
using Handler =
|
using Handler =
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "atom/browser/atom_browser_context.h"
|
#include "atom/browser/atom_browser_context.h"
|
||||||
|
|
||||||
|
#include "atom/browser/api/atom_api_protocol.h"
|
||||||
#include "atom/browser/atom_browser_main_parts.h"
|
#include "atom/browser/atom_browser_main_parts.h"
|
||||||
#include "atom/browser/atom_download_manager_delegate.h"
|
#include "atom/browser/atom_download_manager_delegate.h"
|
||||||
#include "atom/browser/browser.h"
|
#include "atom/browser/browser.h"
|
||||||
|
@ -88,9 +89,6 @@ AtomBrowserContext::AtomBrowserContext(
|
||||||
use_cache_ = true;
|
use_cache_ = true;
|
||||||
options.GetBoolean("cache", &use_cache_);
|
options.GetBoolean("cache", &use_cache_);
|
||||||
|
|
||||||
// Default schemes that should support cookies.
|
|
||||||
cookieable_schemes_ = {"http", "https", "ws", "wss"};
|
|
||||||
|
|
||||||
// Initialize Pref Registry in brightray.
|
// Initialize Pref Registry in brightray.
|
||||||
InitPrefs();
|
InitPrefs();
|
||||||
}
|
}
|
||||||
|
@ -102,13 +100,6 @@ void AtomBrowserContext::SetUserAgent(const std::string& user_agent) {
|
||||||
user_agent_ = user_agent;
|
user_agent_ = user_agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserContext::SetCookieableSchemes(
|
|
||||||
const std::vector<std::string>& schemes) {
|
|
||||||
if (!schemes.empty())
|
|
||||||
cookieable_schemes_.insert(cookieable_schemes_.end(),
|
|
||||||
schemes.begin(), schemes.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
net::NetworkDelegate* AtomBrowserContext::CreateNetworkDelegate() {
|
net::NetworkDelegate* AtomBrowserContext::CreateNetworkDelegate() {
|
||||||
return network_delegate_;
|
return network_delegate_;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +190,11 @@ net::SSLConfigService* AtomBrowserContext::CreateSSLConfigService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> AtomBrowserContext::GetCookieableSchemes() {
|
std::vector<std::string> AtomBrowserContext::GetCookieableSchemes() {
|
||||||
return cookieable_schemes_;
|
auto default_schemes = brightray::BrowserContext::GetCookieableSchemes();
|
||||||
|
const auto& standard_schemes = atom::api::GetStandardSchemes();
|
||||||
|
default_schemes.insert(default_schemes.end(),
|
||||||
|
standard_schemes.begin(), standard_schemes.end());
|
||||||
|
return default_schemes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) {
|
void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) {
|
||||||
|
|
|
@ -27,7 +27,6 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||||
const base::DictionaryValue& options = base::DictionaryValue());
|
const base::DictionaryValue& options = base::DictionaryValue());
|
||||||
|
|
||||||
void SetUserAgent(const std::string& user_agent);
|
void SetUserAgent(const std::string& user_agent);
|
||||||
void SetCookieableSchemes(const std::vector<std::string>& schemes);
|
|
||||||
|
|
||||||
// brightray::URLRequestContextGetter::Delegate:
|
// brightray::URLRequestContextGetter::Delegate:
|
||||||
net::NetworkDelegate* CreateNetworkDelegate() override;
|
net::NetworkDelegate* CreateNetworkDelegate() override;
|
||||||
|
@ -59,7 +58,6 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||||
std::unique_ptr<AtomDownloadManagerDelegate> download_manager_delegate_;
|
std::unique_ptr<AtomDownloadManagerDelegate> download_manager_delegate_;
|
||||||
std::unique_ptr<WebViewManager> guest_manager_;
|
std::unique_ptr<WebViewManager> guest_manager_;
|
||||||
std::unique_ptr<AtomPermissionManager> permission_manager_;
|
std::unique_ptr<AtomPermissionManager> permission_manager_;
|
||||||
std::vector<std::string> cookieable_schemes_;
|
|
||||||
std::string user_agent_;
|
std::string user_agent_;
|
||||||
bool use_cache_;
|
bool use_cache_;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue