#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "base/strings/string_util.h"
-#include "brightray/common/switches.h"
#include "content/public/browser/child_process_security_policy.h"
#include "native_mate/dictionary.h"
#include "url/url_util.h"
namespace {
+// List of registered custom standard schemes.
+std::vector<std::string> g_standard_schemes;
+
// Clear protocol handlers in IO thread.
void ClearJobFactoryInIO(
scoped_refptr<brightray::URLRequestContextGetter> request_context_getter) {
Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
: request_context_getter_(browser_context->GetRequestContext()),
weak_factory_(this) {
+ browser_context->SetCookieableSchemes(g_standard_schemes);
Init(isolate);
}
auto command_line = base::CommandLine::ForCurrentProcess();
command_line->AppendSwitchASCII(atom::switches::kStandardSchemes,
base::JoinString(schemes, ","));
- command_line->AppendSwitchASCII(brightray::switches::kCookieableSchemes,
- base::JoinString(schemes, ","));
+
+ atom::api::g_standard_schemes = schemes;
}
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
use_cache_ = true;
options.GetBoolean("cache", &use_cache_);
+ // Default schemes that should support cookies.
+ cookieable_schemes_ = {"http", "https", "ws", "wss"};
+
// Initialize Pref Registry in brightray.
InitPrefs();
}
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() {
return network_delegate_;
}
return new AtomSSLConfigService;
}
+std::vector<std::string> AtomBrowserContext::GetCookieableSchemes() {
+ return cookieable_schemes_;
+}
+
void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) {
pref_registry->RegisterFilePathPref(prefs::kSelectFileLastDirectory,
base::FilePath());
#define ATOM_BROWSER_ATOM_BROWSER_CONTEXT_H_
#include <string>
+#include <vector>
#include "brightray/browser/browser_context.h"
const base::DictionaryValue& options = base::DictionaryValue());
void SetUserAgent(const std::string& user_agent);
+ void SetCookieableSchemes(const std::vector<std::string>& schemes);
// brightray::URLRequestContextGetter::Delegate:
net::NetworkDelegate* CreateNetworkDelegate() override;
const base::FilePath& base_path) override;
std::unique_ptr<net::CertVerifier> CreateCertVerifier() override;
net::SSLConfigService* CreateSSLConfigService() override;
+ std::vector<std::string> GetCookieableSchemes() override;
// content::BrowserContext:
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
std::unique_ptr<AtomDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<WebViewManager> guest_manager_;
std::unique_ptr<AtomPermissionManager> permission_manager_;
+ std::vector<std::string> cookieable_schemes_;
std::string user_agent_;
bool use_cache_;