From cbe92b5fb526689ac57c729ba9d4956531c09de4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 21 Sep 2016 09:09:43 -0700 Subject: [PATCH 1/2] Support configuring a cookie delegate --- .../browser/url_request_context_getter.cc | 21 ++++++++----------- .../browser/url_request_context_getter.h | 6 +++++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index a5110a8f713..535beb590a0 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -180,18 +180,15 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { storage_.reset(new net::URLRequestContextStorage(url_request_context_.get())); std::unique_ptr cookie_store = nullptr; - if (in_memory_) { - auto cookie_config = content::CookieStoreConfig(); - cookie_config.cookieable_schemes = delegate_->GetCookieableSchemes(); - cookie_store = content::CreateCookieStore(cookie_config); - } else { - auto cookie_config = content::CookieStoreConfig( - base_path_.Append(FILE_PATH_LITERAL("Cookies")), - content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, - nullptr, nullptr); - cookie_config.cookieable_schemes = delegate_->GetCookieableSchemes(); - cookie_store = content::CreateCookieStore(cookie_config); - } + auto cookie_path = in_memory_ ? + base::FilePath() : base_path_.Append(FILE_PATH_LITERAL("Cookies")); + auto cookie_config = content::CookieStoreConfig( + cookie_path, + content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, + nullptr, + delegate_->CreateCookieDelegate()); + cookie_config.cookieable_schemes = delegate_->GetCookieableSchemes(); + cookie_store = content::CreateCookieStore(cookie_config); storage_->set_cookie_store(std::move(cookie_store)); storage_->set_channel_id_service(base::WrapUnique( new net::ChannelIDService(new net::DefaultChannelIDStore(nullptr), diff --git a/brightray/browser/url_request_context_getter.h b/brightray/browser/url_request_context_getter.h index ed2814c738b..1b10c2d75a1 100644 --- a/brightray/browser/url_request_context_getter.h +++ b/brightray/browser/url_request_context_getter.h @@ -8,6 +8,7 @@ #include "base/files/file_path.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/content_browser_client.h" +#include "net/cookies/cookie_monster.h" #include "net/http/http_cache.h" #include "net/http/url_security_manager.h" #include "net/url_request/url_request_context_getter.h" @@ -38,7 +39,10 @@ class URLRequestContextGetter : public net::URLRequestContextGetter { Delegate() {} virtual ~Delegate() {} - virtual net::NetworkDelegate* CreateNetworkDelegate() { return NULL; } + virtual net::NetworkDelegate* CreateNetworkDelegate() { return nullptr; } + virtual net::CookieMonsterDelegate* CreateCookieDelegate() { + return nullptr; + } virtual std::string GetUserAgent(); virtual std::unique_ptr CreateURLRequestJobFactory( From 67eff02a6543652e07b8ebfea5b7f92d0be540eb Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 28 Sep 2016 16:49:26 -0700 Subject: [PATCH 2/2] :art: --- brightray/browser/url_request_context_getter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index 535beb590a0..57ca1f1b405 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -179,7 +179,6 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { storage_.reset(new net::URLRequestContextStorage(url_request_context_.get())); - std::unique_ptr cookie_store = nullptr; auto cookie_path = in_memory_ ? base::FilePath() : base_path_.Append(FILE_PATH_LITERAL("Cookies")); auto cookie_config = content::CookieStoreConfig( @@ -188,7 +187,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { nullptr, delegate_->CreateCookieDelegate()); cookie_config.cookieable_schemes = delegate_->GetCookieableSchemes(); - cookie_store = content::CreateCookieStore(cookie_config); + std::unique_ptr cookie_store = + content::CreateCookieStore(cookie_config); storage_->set_cookie_store(std::move(cookie_store)); storage_->set_channel_id_service(base::WrapUnique( new net::ChannelIDService(new net::DefaultChannelIDStore(nullptr),