2019-04-24 04:50:25 +02:00
|
|
|
diff --git chrome/browser/net/profile_network_context_service.cc chrome/browser/net/profile_network_context_service.cc
|
2020-06-25 04:34:12 +02:00
|
|
|
index 75a5ee192358..379e0bdd11b1 100644
|
2019-04-24 04:50:25 +02:00
|
|
|
--- chrome/browser/net/profile_network_context_service.cc
|
|
|
|
+++ chrome/browser/net/profile_network_context_service.cc
|
2020-03-30 22:13:42 +02:00
|
|
|
@@ -18,6 +18,7 @@
|
2019-11-12 17:11:44 +01:00
|
|
|
#include "base/strings/string_split.h"
|
2019-05-02 20:50:59 +02:00
|
|
|
#include "base/task/post_task.h"
|
2020-03-30 22:13:42 +02:00
|
|
|
#include "base/task/thread_pool.h"
|
2020-06-28 20:29:44 +02:00
|
|
|
+#include "cef/libcef/features/runtime.h"
|
2019-05-02 20:50:59 +02:00
|
|
|
#include "chrome/browser/browser_process.h"
|
2019-09-04 17:13:32 +02:00
|
|
|
#include "chrome/browser/content_settings/cookie_settings_factory.h"
|
2019-05-02 20:50:59 +02:00
|
|
|
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
2020-06-25 04:34:12 +02:00
|
|
|
@@ -661,9 +662,23 @@ void ProfileNetworkContextService::ConfigureNetworkContextParamsInternal(
|
2019-09-04 17:13:32 +02:00
|
|
|
network_context_params->cookie_manager_params =
|
|
|
|
CreateCookieManagerParams(profile_, *cookie_settings_);
|
2019-04-24 04:50:25 +02:00
|
|
|
|
|
|
|
+ network_context_params->cookieable_schemes = profile_->GetCookieableSchemes();
|
|
|
|
+
|
|
|
|
// Configure on-disk storage for non-OTR profiles. OTR profiles just use
|
|
|
|
// default behavior (in memory storage, default sizes).
|
2020-06-25 04:34:12 +02:00
|
|
|
- if (!in_memory) {
|
2020-06-28 20:29:44 +02:00
|
|
|
+ if (!in_memory && cef::IsAlloyRuntimeEnabled()) {
|
2019-10-01 15:55:16 +02:00
|
|
|
+ PrefService* prefs = profile_->GetPrefs();
|
|
|
|
+ // Configure the HTTP cache path and size.
|
|
|
|
+ const base::FilePath& base_cache_path =
|
|
|
|
+ prefs->GetFilePath(prefs::kDiskCacheDir);
|
2019-05-02 20:50:59 +02:00
|
|
|
+ DCHECK(!base_cache_path.empty());
|
2019-10-01 15:55:16 +02:00
|
|
|
+ network_context_params->http_cache_path =
|
|
|
|
+ base_cache_path.Append(chrome::kCacheDirname);
|
|
|
|
+ network_context_params->http_cache_max_size =
|
|
|
|
+ prefs->GetInteger(prefs::kDiskCacheSize);
|
2020-06-25 04:34:12 +02:00
|
|
|
+ }
|
|
|
|
+
|
2020-06-28 20:29:44 +02:00
|
|
|
+ if (!in_memory && !cef::IsAlloyRuntimeEnabled()) {
|
2019-10-01 15:55:16 +02:00
|
|
|
PrefService* local_state = g_browser_process->local_state();
|
|
|
|
// Configure the HTTP cache path and size.
|
|
|
|
base::FilePath base_cache_path;
|
2020-06-25 04:34:12 +02:00
|
|
|
@@ -676,7 +691,9 @@ void ProfileNetworkContextService::ConfigureNetworkContextParamsInternal(
|
2019-05-02 20:50:59 +02:00
|
|
|
base_cache_path.Append(chrome::kCacheDirname);
|
|
|
|
network_context_params->http_cache_max_size =
|
2019-10-01 15:55:16 +02:00
|
|
|
local_state->GetInteger(prefs::kDiskCacheSize);
|
2020-06-25 04:34:12 +02:00
|
|
|
+ }
|
2019-10-01 15:55:16 +02:00
|
|
|
|
2020-06-25 04:34:12 +02:00
|
|
|
+ if (!in_memory) {
|
2019-10-01 15:55:16 +02:00
|
|
|
// Currently this just contains HttpServerProperties, but that will likely
|
|
|
|
// change.
|
2020-06-25 04:34:12 +02:00
|
|
|
network_context_params->http_server_properties_path =
|
2019-04-24 04:50:25 +02:00
|
|
|
diff --git chrome/browser/profiles/profile.h chrome/browser/profiles/profile.h
|
2020-06-09 19:48:00 +02:00
|
|
|
index a48ead96b3f7..967a5975c330 100644
|
2019-04-24 04:50:25 +02:00
|
|
|
--- chrome/browser/profiles/profile.h
|
|
|
|
+++ chrome/browser/profiles/profile.h
|
2020-06-09 19:48:00 +02:00
|
|
|
@@ -464,6 +464,11 @@ class Profile : public content::BrowserContext {
|
2019-04-24 04:50:25 +02:00
|
|
|
virtual bool ShouldRestoreOldSessionCookies();
|
|
|
|
virtual bool ShouldPersistSessionCookies();
|
|
|
|
|
|
|
|
+ // Returns schemes that should be cookieable, if other than the defaults.
|
2019-05-03 00:23:57 +02:00
|
|
|
+ virtual base::Optional<std::vector<std::string>> GetCookieableSchemes() {
|
|
|
|
+ return base::nullopt;
|
2019-04-24 04:50:25 +02:00
|
|
|
+ }
|
|
|
|
+
|
2020-06-09 19:48:00 +02:00
|
|
|
// Configures NetworkContextParams and CertVerifierCreationParams for the
|
|
|
|
// specified isolated app (or for the profile itself, if |relative_path| is
|
|
|
|
// empty).
|
2019-06-05 16:15:45 +02:00
|
|
|
diff --git net/cookies/cookie_monster.cc net/cookies/cookie_monster.cc
|
2020-06-09 19:48:00 +02:00
|
|
|
index 69652bdb5952..f1554d00df7b 100644
|
2019-06-05 16:15:45 +02:00
|
|
|
--- net/cookies/cookie_monster.cc
|
|
|
|
+++ net/cookies/cookie_monster.cc
|
2020-02-10 18:10:17 +01:00
|
|
|
@@ -476,6 +476,25 @@ void CookieMonster::SetCookieableSchemes(
|
2019-06-05 16:15:45 +02:00
|
|
|
MaybeRunCookieCallback(std::move(callback), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
+void CookieMonster::AddCookieableSchemes(
|
|
|
|
+ const std::vector<std::string>& schemes,
|
|
|
|
+ SetCookieableSchemesCallback callback) {
|
|
|
|
+ DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
+
|
|
|
|
+ // Calls to this method will have no effect if made after a WebView or
|
|
|
|
+ // CookieManager instance has been created.
|
|
|
|
+ if (initialized_) {
|
|
|
|
+ MaybeRunCookieCallback(std::move(callback), false);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!schemes.empty()) {
|
|
|
|
+ cookieable_schemes_.insert(cookieable_schemes_.begin(), schemes.begin(),
|
|
|
|
+ schemes.end());
|
|
|
|
+ }
|
|
|
|
+ MaybeRunCookieCallback(std::move(callback), true);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
// This function must be called before the CookieMonster is used.
|
|
|
|
void CookieMonster::SetPersistSessionCookies(bool persist_session_cookies) {
|
|
|
|
DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
diff --git net/cookies/cookie_monster.h net/cookies/cookie_monster.h
|
2020-06-09 19:48:00 +02:00
|
|
|
index 46001bd4e4e1..7ac1fc4f49ce 100644
|
2019-06-05 16:15:45 +02:00
|
|
|
--- net/cookies/cookie_monster.h
|
|
|
|
+++ net/cookies/cookie_monster.h
|
2019-11-12 17:11:44 +01:00
|
|
|
@@ -180,6 +180,8 @@ class NET_EXPORT CookieMonster : public CookieStore {
|
2019-06-05 16:15:45 +02:00
|
|
|
CookieChangeDispatcher& GetChangeDispatcher() override;
|
|
|
|
void SetCookieableSchemes(const std::vector<std::string>& schemes,
|
|
|
|
SetCookieableSchemesCallback callback) override;
|
|
|
|
+ void AddCookieableSchemes(const std::vector<std::string>& schemes,
|
|
|
|
+ SetCookieableSchemesCallback callback) override;
|
|
|
|
|
|
|
|
// Enables writing session cookies into the cookie database. If this this
|
|
|
|
// method is called, it must be called before first use of the instance
|
|
|
|
diff --git net/cookies/cookie_store.h net/cookies/cookie_store.h
|
2020-06-09 19:48:00 +02:00
|
|
|
index 4157f0ce83a5..1a0966ce73c8 100644
|
2019-06-05 16:15:45 +02:00
|
|
|
--- net/cookies/cookie_store.h
|
|
|
|
+++ net/cookies/cookie_store.h
|
2019-11-12 17:11:44 +01:00
|
|
|
@@ -148,6 +148,11 @@ class NET_EXPORT CookieStore {
|
|
|
|
// Transfer ownership of a CookieAccessDelegate.
|
|
|
|
void SetCookieAccessDelegate(std::unique_ptr<CookieAccessDelegate> delegate);
|
2019-06-05 16:15:45 +02:00
|
|
|
|
|
|
|
+ // Adds to the list of cookieable schemes. Does nothing if called after first
|
|
|
|
+ // use of the instance (i.e. after the instance initialization process).
|
|
|
|
+ virtual void AddCookieableSchemes(const std::vector<std::string>& schemes,
|
|
|
|
+ SetCookieableSchemesCallback callback) = 0;
|
|
|
|
+
|
2019-07-16 19:59:21 +02:00
|
|
|
// Reports the estimate of dynamically allocated memory in bytes.
|
|
|
|
virtual void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd,
|
|
|
|
const std::string& parent_absolute_name) const;
|
2019-06-05 16:15:45 +02:00
|
|
|
diff --git services/network/cookie_manager.cc services/network/cookie_manager.cc
|
2020-06-09 19:48:00 +02:00
|
|
|
index 1d988375b00a..e71cbc3b612f 100644
|
2019-06-05 16:15:45 +02:00
|
|
|
--- services/network/cookie_manager.cc
|
|
|
|
+++ services/network/cookie_manager.cc
|
2020-02-10 18:10:17 +01:00
|
|
|
@@ -228,14 +228,9 @@ void CookieManager::FlushCookieStore(FlushCookieStoreCallback callback) {
|
2019-06-05 16:15:45 +02:00
|
|
|
void CookieManager::AllowFileSchemeCookies(
|
|
|
|
bool allow,
|
|
|
|
AllowFileSchemeCookiesCallback callback) {
|
|
|
|
- std::vector<std::string> cookieable_schemes(
|
|
|
|
- net::CookieMonster::kDefaultCookieableSchemes,
|
|
|
|
- net::CookieMonster::kDefaultCookieableSchemes +
|
|
|
|
- net::CookieMonster::kDefaultCookieableSchemesCount);
|
|
|
|
- if (allow) {
|
|
|
|
- cookieable_schemes.push_back(url::kFileScheme);
|
|
|
|
- }
|
|
|
|
- cookie_store_->SetCookieableSchemes(cookieable_schemes, std::move(callback));
|
|
|
|
+ if (!allow)
|
|
|
|
+ return;
|
|
|
|
+ cookie_store_->AddCookieableSchemes({url::kFileScheme}, std::move(callback));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CookieManager::SetForceKeepSessionState() {
|
2019-04-24 04:50:25 +02:00
|
|
|
diff --git services/network/network_context.cc services/network/network_context.cc
|
2020-06-09 19:48:00 +02:00
|
|
|
index 2c3f75ea4ad1..2e639893913b 100644
|
2019-04-24 04:50:25 +02:00
|
|
|
--- services/network/network_context.cc
|
|
|
|
+++ services/network/network_context.cc
|
2020-06-09 19:48:00 +02:00
|
|
|
@@ -1746,6 +1746,7 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext() {
|
2019-04-24 04:50:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
scoped_refptr<SessionCleanupCookieStore> session_cleanup_cookie_store;
|
|
|
|
+ std::unique_ptr<net::CookieMonster> cookie_store;
|
|
|
|
if (params_->cookie_path) {
|
|
|
|
scoped_refptr<base::SequencedTaskRunner> client_task_runner =
|
2019-09-04 17:13:32 +02:00
|
|
|
base::ThreadTaskRunnerHandle::Get();
|
2020-06-09 19:48:00 +02:00
|
|
|
@@ -1772,18 +1773,26 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext() {
|
2019-04-24 04:50:25 +02:00
|
|
|
session_cleanup_cookie_store =
|
|
|
|
base::MakeRefCounted<SessionCleanupCookieStore>(sqlite_store);
|
|
|
|
|
|
|
|
- std::unique_ptr<net::CookieMonster> cookie_store =
|
|
|
|
+ cookie_store =
|
|
|
|
std::make_unique<net::CookieMonster>(session_cleanup_cookie_store.get(),
|
|
|
|
net_log);
|
|
|
|
if (params_->persist_session_cookies)
|
|
|
|
cookie_store->SetPersistSessionCookies(true);
|
|
|
|
-
|
2019-10-01 15:55:16 +02:00
|
|
|
- builder.SetCookieStore(std::move(cookie_store));
|
2019-04-24 04:50:25 +02:00
|
|
|
} else {
|
|
|
|
DCHECK(!params_->restore_old_session_cookies);
|
|
|
|
DCHECK(!params_->persist_session_cookies);
|
|
|
|
+ cookie_store =
|
|
|
|
+ std::make_unique<net::CookieMonster>(nullptr /* store */, net_log);
|
2020-03-30 22:13:42 +02:00
|
|
|
+ }
|
|
|
|
+
|
2019-05-03 00:23:57 +02:00
|
|
|
+ if (params_->cookieable_schemes.has_value()) {
|
2019-04-24 04:50:25 +02:00
|
|
|
+ cookie_store->SetCookieableSchemes(
|
2019-05-03 00:23:57 +02:00
|
|
|
+ *params_->cookieable_schemes,
|
2019-04-24 04:50:25 +02:00
|
|
|
+ net::CookieStore::SetCookieableSchemesCallback());
|
2020-03-30 22:13:42 +02:00
|
|
|
}
|
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
+ builder.SetCookieStore(std::move(cookie_store));
|
2019-04-24 04:50:25 +02:00
|
|
|
+
|
2020-03-30 22:13:42 +02:00
|
|
|
if (base::FeatureList::IsEnabled(features::kTrustTokens)) {
|
2020-04-14 21:31:00 +02:00
|
|
|
trust_token_store_ = std::make_unique<PendingTrustTokenStore>();
|
|
|
|
|
2019-04-24 04:50:25 +02:00
|
|
|
diff --git services/network/public/mojom/network_context.mojom services/network/public/mojom/network_context.mojom
|
2020-06-09 19:48:00 +02:00
|
|
|
index 6589fe215cfa..481fabeef3a1 100644
|
2019-04-24 04:50:25 +02:00
|
|
|
--- services/network/public/mojom/network_context.mojom
|
|
|
|
+++ services/network/public/mojom/network_context.mojom
|
2020-06-09 19:48:00 +02:00
|
|
|
@@ -258,6 +258,9 @@ struct NetworkContextParams {
|
2019-04-24 04:50:25 +02:00
|
|
|
// cookies. Otherwise it should be false.
|
|
|
|
bool persist_session_cookies = false;
|
|
|
|
|
|
|
|
+ // Schemes that will be passed to CookieMonster::SetCookieableSchemes.
|
2019-05-03 00:23:57 +02:00
|
|
|
+ array<string>? cookieable_schemes;
|
2019-04-24 04:50:25 +02:00
|
|
|
+
|
|
|
|
// True if an HTTP cache should be used.
|
|
|
|
bool http_cache_enabled = true;
|
|
|
|
// Maximum size of the HTTP cache. 0 means to use the default size.
|