1diff --git chrome/browser/net/profile_network_context_service.cc chrome/browser/net/profile_network_context_service.cc 2index d89552afd9c8f..7f2da3945aa3b 100644 3--- chrome/browser/net/profile_network_context_service.cc 4+++ chrome/browser/net/profile_network_context_service.cc 5@@ -22,6 +22,7 @@ 6 #include "base/task/thread_pool.h" 7 #include "build/build_config.h" 8 #include "build/chromeos_buildflags.h" 9+#include "cef/libcef/features/runtime.h" 10 #include "chrome/browser/browser_features.h" 11 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/content_settings/cookie_settings_factory.h" 13@@ -718,7 +719,19 @@ void ProfileNetworkContextService::ConfigureNetworkContextParamsInternal( 14 15 // Configure on-disk storage for non-OTR profiles. OTR profiles just use 16 // default behavior (in memory storage, default sizes). 17- if (!in_memory) { 18+ if (!in_memory && cef::IsAlloyRuntimeEnabled()) { 19+ PrefService* prefs = profile_->GetPrefs(); 20+ // Configure the HTTP cache path and size. 21+ const base::FilePath& base_cache_path = 22+ prefs->GetFilePath(prefs::kDiskCacheDir); 23+ DCHECK(!base_cache_path.empty()); 24+ network_context_params->http_cache_path = 25+ base_cache_path.Append(chrome::kCacheDirname); 26+ network_context_params->http_cache_max_size = 27+ prefs->GetInteger(prefs::kDiskCacheSize); 28+ } 29+ 30+ if (!in_memory && !cef::IsAlloyRuntimeEnabled()) { 31 PrefService* local_state = g_browser_process->local_state(); 32 // Configure the HTTP cache path and size. 33 base::FilePath base_cache_path; 34@@ -746,7 +759,9 @@ void ProfileNetworkContextService::ConfigureNetworkContextParamsInternal( 35 network_context_params->http_cache_max_size = 36 local_state->GetInteger(prefs::kDiskCacheSize); 37 } 38+ } 39 40+ if (!in_memory) { 41 network_context_params->file_paths = 42 ::network::mojom::NetworkContextFilePaths::New(); 43 44diff --git net/cookies/cookie_monster.cc net/cookies/cookie_monster.cc 45index 0aaef609b0709..ab1a8e96fdb30 100644 46--- net/cookies/cookie_monster.cc 47+++ net/cookies/cookie_monster.cc 48@@ -545,6 +545,25 @@ void CookieMonster::SetCookieableSchemes( 49 MaybeRunCookieCallback(std::move(callback), true); 50 } 51 52+void CookieMonster::AddCookieableSchemes( 53+ const std::vector<std::string>& schemes, 54+ SetCookieableSchemesCallback callback) { 55+ DCHECK(thread_checker_.CalledOnValidThread()); 56+ 57+ // Calls to this method will have no effect if made after a WebView or 58+ // CookieManager instance has been created. 59+ if (initialized_) { 60+ MaybeRunCookieCallback(std::move(callback), false); 61+ return; 62+ } 63+ 64+ if (!schemes.empty()) { 65+ cookieable_schemes_.insert(cookieable_schemes_.begin(), schemes.begin(), 66+ schemes.end()); 67+ } 68+ MaybeRunCookieCallback(std::move(callback), true); 69+} 70+ 71 // This function must be called before the CookieMonster is used. 72 void CookieMonster::SetPersistSessionCookies(bool persist_session_cookies) { 73 DCHECK(thread_checker_.CalledOnValidThread()); 74diff --git net/cookies/cookie_monster.h net/cookies/cookie_monster.h 75index 1ed421b60d526..d65d32b4c0ca0 100644 76--- net/cookies/cookie_monster.h 77+++ net/cookies/cookie_monster.h 78@@ -205,6 +205,8 @@ class NET_EXPORT CookieMonster : public CookieStore { 79 CookieChangeDispatcher& GetChangeDispatcher() override; 80 void SetCookieableSchemes(const std::vector<std::string>& schemes, 81 SetCookieableSchemesCallback callback) override; 82+ void AddCookieableSchemes(const std::vector<std::string>& schemes, 83+ SetCookieableSchemesCallback callback) override; 84 85 // Enables writing session cookies into the cookie database. If this this 86 // method is called, it must be called before first use of the instance 87diff --git net/cookies/cookie_store.h net/cookies/cookie_store.h 88index 8631b10535c7d..7c4c518ee5b3d 100644 89--- net/cookies/cookie_store.h 90+++ net/cookies/cookie_store.h 91@@ -155,6 +155,11 @@ class NET_EXPORT CookieStore { 92 // Transfer ownership of a CookieAccessDelegate. 93 void SetCookieAccessDelegate(std::unique_ptr<CookieAccessDelegate> delegate); 94 95+ // Adds to the list of cookieable schemes. Does nothing if called after first 96+ // use of the instance (i.e. after the instance initialization process). 97+ virtual void AddCookieableSchemes(const std::vector<std::string>& schemes, 98+ SetCookieableSchemesCallback callback) = 0; 99+ 100 // This may be null if no delegate has been set yet, or the delegate has been 101 // reset to null. 102 const CookieAccessDelegate* cookie_access_delegate() const { 103diff --git services/network/cookie_manager.cc services/network/cookie_manager.cc 104index f0660ffa8bd4d..4eb14790b8979 100644 105--- services/network/cookie_manager.cc 106+++ services/network/cookie_manager.cc 107@@ -324,14 +324,9 @@ void CookieManager::FlushCookieStore(FlushCookieStoreCallback callback) { 108 void CookieManager::AllowFileSchemeCookies( 109 bool allow, 110 AllowFileSchemeCookiesCallback callback) { 111- std::vector<std::string> cookieable_schemes( 112- net::CookieMonster::kDefaultCookieableSchemes, 113- net::CookieMonster::kDefaultCookieableSchemes + 114- net::CookieMonster::kDefaultCookieableSchemesCount); 115- if (allow) { 116- cookieable_schemes.push_back(url::kFileScheme); 117- } 118- cookie_store_->SetCookieableSchemes(cookieable_schemes, std::move(callback)); 119+ if (!allow) 120+ return; 121+ cookie_store_->AddCookieableSchemes({url::kFileScheme}, std::move(callback)); 122 } 123 124 void CookieManager::SetForceKeepSessionState() { 125diff --git services/network/network_context.cc services/network/network_context.cc 126index abcf825d8049a..552d8403fa0a8 100644 127--- services/network/network_context.cc 128+++ services/network/network_context.cc 129@@ -2216,17 +2216,21 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext( 130 network_service_->network_quality_estimator()); 131 } 132 133- if (session_cleanup_cookie_store) { 134- std::unique_ptr<net::CookieMonster> cookie_store = 135- std::make_unique<net::CookieMonster>( 136- session_cleanup_cookie_store.get(), net_log, 137- network_service_->first_party_sets()->is_enabled()); 138- if (params_->persist_session_cookies) 139- cookie_store->SetPersistSessionCookies(true); 140+ std::unique_ptr<net::CookieMonster> cookie_store = 141+ std::make_unique<net::CookieMonster>( 142+ session_cleanup_cookie_store.get(), net_log, 143+ network_service_->first_party_sets()->is_enabled()); 144+ if (session_cleanup_cookie_store && params_->persist_session_cookies) 145+ cookie_store->SetPersistSessionCookies(true); 146 147- builder.SetCookieStore(std::move(cookie_store)); 148+ if (params_->cookieable_schemes.has_value()) { 149+ cookie_store->SetCookieableSchemes( 150+ *params_->cookieable_schemes, 151+ net::CookieStore::SetCookieableSchemesCallback()); 152 } 153 154+ builder.SetCookieStore(std::move(cookie_store)); 155+ 156 if (base::FeatureList::IsEnabled(features::kTrustTokens)) { 157 trust_token_store_ = std::make_unique<PendingTrustTokenStore>(); 158 159diff --git services/network/public/mojom/network_context.mojom services/network/public/mojom/network_context.mojom 160index d7c10e5a55bf0..958c2c27211f7 100644 161--- services/network/public/mojom/network_context.mojom 162+++ services/network/public/mojom/network_context.mojom 163@@ -330,6 +330,9 @@ struct NetworkContextParams { 164 // cookies. Otherwise it should be false. 165 bool persist_session_cookies = false; 166 167+ // Schemes that will be passed to CookieMonster::SetCookieableSchemes. 168+ array<string>? cookieable_schemes; 169+ 170 // True if an HTTP cache should be used. 171 bool http_cache_enabled = true; 172 // Maximum size of the HTTP cache. 0 means to use the default size. 173