diff --git a/brightray/BUILD.gn b/brightray/BUILD.gn index 166c01b86864..3bdcb96469c5 100644 --- a/brightray/BUILD.gn +++ b/brightray/BUILD.gn @@ -13,6 +13,7 @@ static_library("brightray") { "//components/prefs", "//content/public/browser", "//content/shell:resources", + "//net:extras", "//net:net_with_v8", "//skia", "//ui/views", diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index f233257e88ba..5b353f0a7a9b 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -112,6 +112,7 @@ 'libraries': [ # Following libraries are always linked statically. '<(libchromiumcontent_dir)/libbase_static.a', + '<(libchromiumcontent_dir)/libextras.a', '<(libchromiumcontent_dir)/libgtkui.a', '<(libchromiumcontent_dir)/libhttp_server.a', '<(libchromiumcontent_dir)/libdevice_service.a', @@ -206,6 +207,7 @@ 'libraries': [ # Following libraries are always linked statically. '<(libchromiumcontent_dir)/libbase_static.a', + '<(libchromiumcontent_dir)/libextras.a', '<(libchromiumcontent_dir)/libhttp_server.a', '<(libchromiumcontent_dir)/libdevice_service.a', '<(libchromiumcontent_dir)/libdom_keycode_converter.a', @@ -342,6 +344,7 @@ '-ldxgi.lib', # Following libs are always linked statically. '<(libchromiumcontent_dir)/base_static.lib', + '<(libchromiumcontent_dir)/extras.lib', '<(libchromiumcontent_dir)/sandbox.lib', '<(libchromiumcontent_dir)/sandbox_helper_win.lib', '<(libchromiumcontent_dir)/http_server.lib', diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index c07ba80cbc52..7a02e9b1aaa1 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -30,6 +30,7 @@ #include "net/cookies/cookie_monster.h" #include "net/cookies/cookie_store.h" #include "net/dns/mapped_host_resolver.h" +#include "net/extras/sqlite/sqlite_channel_id_store.h" #include "net/http/http_auth_filter.h" #include "net/http/http_auth_handler_factory.h" #include "net/http/http_auth_preferences.h" @@ -215,29 +216,46 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { storage_->set_network_delegate(delegate_->CreateNetworkDelegate()); + std::unique_ptr cookie_store; + scoped_refptr channel_id_db; + // Create a single task runner to use with the CookieStore and + // ChannelIDStore. + scoped_refptr cookie_background_task_runner = + base::CreateSequencedTaskRunnerWithTraits( + {base::MayBlock(), base::TaskPriority::BACKGROUND, + base::TaskShutdownBehavior::BLOCK_SHUTDOWN}); auto cookie_path = in_memory_ ? base::FilePath() : base_path_.Append(FILE_PATH_LITERAL("Cookies")); - std::unique_ptr cookie_store = content::CreateCookieStore( - content::CookieStoreConfig(cookie_path, false, false, nullptr)); - storage_->set_cookie_store(std::move(cookie_store)); + if (!in_memory_) { + channel_id_db = new net::SQLiteChannelIDStore( + base_path_.Append(FILE_PATH_LITERAL("Origin Bound Certs")), + cookie_background_task_runner); + } + std::unique_ptr channel_id_service( + new net::ChannelIDService( + new net::DefaultChannelIDStore(channel_id_db.get()))); + content::CookieStoreConfig cookie_config(cookie_path, false, false, + nullptr); + cookie_config.channel_id_service = channel_id_service.get(); + cookie_config.background_task_runner = cookie_background_task_runner; + cookie_store = content::CreateCookieStore(cookie_config); + cookie_store->SetChannelIDServiceID(channel_id_service->GetUniqueID()); // Set custom schemes that can accept cookies. net::CookieMonster* cookie_monster = - static_cast(url_request_context_->cookie_store()); + static_cast(cookie_store.get()); std::vector cookie_schemes({"http", "https", "ws", "wss"}); delegate_->GetCookieableSchemes(&cookie_schemes); cookie_monster->SetCookieableSchemes(cookie_schemes); // Cookie store will outlive notifier by order of declaration // in the header. - cookie_change_sub_ = url_request_context_->cookie_store() - ->GetChangeDispatcher() - .AddCallbackForAllChanges(base::Bind( - &URLRequestContextGetter::OnCookieChanged, - base::RetainedRef(this))); - - storage_->set_channel_id_service(std::make_unique( - new net::DefaultChannelIDStore(nullptr))); + cookie_change_sub_ = + cookie_store->GetChangeDispatcher().AddCallbackForAllChanges( + base::Bind(&URLRequestContextGetter::OnCookieChanged, + base::RetainedRef(this))); + storage_->set_cookie_store(std::move(cookie_store)); + storage_->set_channel_id_service(std::move(channel_id_service)); storage_->set_http_user_agent_settings( base::WrapUnique(new net::StaticHttpUserAgentSettings(