Merge pull request #14107 from electron/channel_id_patch
fix: create persistent channel ID store when cookie store is persistent
This commit is contained in:
commit
98b7a9ce9c
3 changed files with 34 additions and 12 deletions
|
@ -13,6 +13,7 @@ static_library("brightray") {
|
||||||
"//components/prefs",
|
"//components/prefs",
|
||||||
"//content/public/browser",
|
"//content/public/browser",
|
||||||
"//content/shell:resources",
|
"//content/shell:resources",
|
||||||
|
"//net:extras",
|
||||||
"//net:net_with_v8",
|
"//net:net_with_v8",
|
||||||
"//skia",
|
"//skia",
|
||||||
"//ui/views",
|
"//ui/views",
|
||||||
|
|
|
@ -112,6 +112,7 @@
|
||||||
'libraries': [
|
'libraries': [
|
||||||
# Following libraries are always linked statically.
|
# Following libraries are always linked statically.
|
||||||
'<(libchromiumcontent_dir)/libbase_static.a',
|
'<(libchromiumcontent_dir)/libbase_static.a',
|
||||||
|
'<(libchromiumcontent_dir)/libextras.a',
|
||||||
'<(libchromiumcontent_dir)/libgtkui.a',
|
'<(libchromiumcontent_dir)/libgtkui.a',
|
||||||
'<(libchromiumcontent_dir)/libhttp_server.a',
|
'<(libchromiumcontent_dir)/libhttp_server.a',
|
||||||
'<(libchromiumcontent_dir)/libdevice_service.a',
|
'<(libchromiumcontent_dir)/libdevice_service.a',
|
||||||
|
@ -206,6 +207,7 @@
|
||||||
'libraries': [
|
'libraries': [
|
||||||
# Following libraries are always linked statically.
|
# Following libraries are always linked statically.
|
||||||
'<(libchromiumcontent_dir)/libbase_static.a',
|
'<(libchromiumcontent_dir)/libbase_static.a',
|
||||||
|
'<(libchromiumcontent_dir)/libextras.a',
|
||||||
'<(libchromiumcontent_dir)/libhttp_server.a',
|
'<(libchromiumcontent_dir)/libhttp_server.a',
|
||||||
'<(libchromiumcontent_dir)/libdevice_service.a',
|
'<(libchromiumcontent_dir)/libdevice_service.a',
|
||||||
'<(libchromiumcontent_dir)/libdom_keycode_converter.a',
|
'<(libchromiumcontent_dir)/libdom_keycode_converter.a',
|
||||||
|
@ -342,6 +344,7 @@
|
||||||
'-ldxgi.lib',
|
'-ldxgi.lib',
|
||||||
# Following libs are always linked statically.
|
# Following libs are always linked statically.
|
||||||
'<(libchromiumcontent_dir)/base_static.lib',
|
'<(libchromiumcontent_dir)/base_static.lib',
|
||||||
|
'<(libchromiumcontent_dir)/extras.lib',
|
||||||
'<(libchromiumcontent_dir)/sandbox.lib',
|
'<(libchromiumcontent_dir)/sandbox.lib',
|
||||||
'<(libchromiumcontent_dir)/sandbox_helper_win.lib',
|
'<(libchromiumcontent_dir)/sandbox_helper_win.lib',
|
||||||
'<(libchromiumcontent_dir)/http_server.lib',
|
'<(libchromiumcontent_dir)/http_server.lib',
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "net/cookies/cookie_monster.h"
|
#include "net/cookies/cookie_monster.h"
|
||||||
#include "net/cookies/cookie_store.h"
|
#include "net/cookies/cookie_store.h"
|
||||||
#include "net/dns/mapped_host_resolver.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_filter.h"
|
||||||
#include "net/http/http_auth_handler_factory.h"
|
#include "net/http/http_auth_handler_factory.h"
|
||||||
#include "net/http/http_auth_preferences.h"
|
#include "net/http/http_auth_preferences.h"
|
||||||
|
@ -215,29 +216,46 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
||||||
|
|
||||||
storage_->set_network_delegate(delegate_->CreateNetworkDelegate());
|
storage_->set_network_delegate(delegate_->CreateNetworkDelegate());
|
||||||
|
|
||||||
|
std::unique_ptr<net::CookieStore> cookie_store;
|
||||||
|
scoped_refptr<net::SQLiteChannelIDStore> channel_id_db;
|
||||||
|
// Create a single task runner to use with the CookieStore and
|
||||||
|
// ChannelIDStore.
|
||||||
|
scoped_refptr<base::SequencedTaskRunner> cookie_background_task_runner =
|
||||||
|
base::CreateSequencedTaskRunnerWithTraits(
|
||||||
|
{base::MayBlock(), base::TaskPriority::BACKGROUND,
|
||||||
|
base::TaskShutdownBehavior::BLOCK_SHUTDOWN});
|
||||||
auto cookie_path = in_memory_
|
auto cookie_path = in_memory_
|
||||||
? base::FilePath()
|
? base::FilePath()
|
||||||
: base_path_.Append(FILE_PATH_LITERAL("Cookies"));
|
: base_path_.Append(FILE_PATH_LITERAL("Cookies"));
|
||||||
std::unique_ptr<net::CookieStore> cookie_store = content::CreateCookieStore(
|
if (!in_memory_) {
|
||||||
content::CookieStoreConfig(cookie_path, false, false, nullptr));
|
channel_id_db = new net::SQLiteChannelIDStore(
|
||||||
storage_->set_cookie_store(std::move(cookie_store));
|
base_path_.Append(FILE_PATH_LITERAL("Origin Bound Certs")),
|
||||||
|
cookie_background_task_runner);
|
||||||
|
}
|
||||||
|
std::unique_ptr<net::ChannelIDService> 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.
|
// Set custom schemes that can accept cookies.
|
||||||
net::CookieMonster* cookie_monster =
|
net::CookieMonster* cookie_monster =
|
||||||
static_cast<net::CookieMonster*>(url_request_context_->cookie_store());
|
static_cast<net::CookieMonster*>(cookie_store.get());
|
||||||
std::vector<std::string> cookie_schemes({"http", "https", "ws", "wss"});
|
std::vector<std::string> cookie_schemes({"http", "https", "ws", "wss"});
|
||||||
delegate_->GetCookieableSchemes(&cookie_schemes);
|
delegate_->GetCookieableSchemes(&cookie_schemes);
|
||||||
cookie_monster->SetCookieableSchemes(cookie_schemes);
|
cookie_monster->SetCookieableSchemes(cookie_schemes);
|
||||||
// Cookie store will outlive notifier by order of declaration
|
// Cookie store will outlive notifier by order of declaration
|
||||||
// in the header.
|
// in the header.
|
||||||
cookie_change_sub_ = url_request_context_->cookie_store()
|
cookie_change_sub_ =
|
||||||
->GetChangeDispatcher()
|
cookie_store->GetChangeDispatcher().AddCallbackForAllChanges(
|
||||||
.AddCallbackForAllChanges(base::Bind(
|
base::Bind(&URLRequestContextGetter::OnCookieChanged,
|
||||||
&URLRequestContextGetter::OnCookieChanged,
|
base::RetainedRef(this)));
|
||||||
base::RetainedRef(this)));
|
storage_->set_cookie_store(std::move(cookie_store));
|
||||||
|
storage_->set_channel_id_service(std::move(channel_id_service));
|
||||||
storage_->set_channel_id_service(std::make_unique<net::ChannelIDService>(
|
|
||||||
new net::DefaultChannelIDStore(nullptr)));
|
|
||||||
|
|
||||||
storage_->set_http_user_agent_settings(
|
storage_->set_http_user_agent_settings(
|
||||||
base::WrapUnique(new net::StaticHttpUserAgentSettings(
|
base::WrapUnique(new net::StaticHttpUserAgentSettings(
|
||||||
|
|
Loading…
Reference in a new issue