• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git chrome/browser/net/profile_network_context_service.cc chrome/browser/net/profile_network_context_service.cc
2index b41fe282dea3..c5fc618d2fe8 100644
3--- chrome/browser/net/profile_network_context_service.cc
4+++ chrome/browser/net/profile_network_context_service.cc
5@@ -21,6 +21,7 @@
6 #include "base/task/post_task.h"
7 #include "base/task/thread_pool.h"
8 #include "build/chromeos_buildflags.h"
9+#include "cef/libcef/features/runtime.h"
10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/content_settings/cookie_settings_factory.h"
12 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
13@@ -684,7 +685,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@@ -697,7 +710,9 @@ void ProfileNetworkContextService::ConfigureNetworkContextParamsInternal(
35         base_cache_path.Append(chrome::kCacheDirname);
36     network_context_params->http_cache_max_size =
37         local_state->GetInteger(prefs::kDiskCacheSize);
38+  }
39
40+  if (!in_memory) {
41     // Currently this just contains HttpServerProperties, but that will likely
42     // change.
43     network_context_params->http_server_properties_path =
44diff --git net/cookies/cookie_monster.cc net/cookies/cookie_monster.cc
45index dd1ff2e34abc..755c3ac5441f 100644
46--- net/cookies/cookie_monster.cc
47+++ net/cookies/cookie_monster.cc
48@@ -495,6 +495,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 00446acaabc1..78235cfc1ed3 100644
76--- net/cookies/cookie_monster.h
77+++ net/cookies/cookie_monster.h
78@@ -180,6 +180,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 5ffbe648343d..3d9a0f2e828f 100644
89--- net/cookies/cookie_store.h
90+++ net/cookies/cookie_store.h
91@@ -149,6 +149,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   // Reports the estimate of dynamically allocated memory in bytes.
101   virtual void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd,
102                                const std::string& parent_absolute_name) const;
103diff --git services/network/cookie_manager.cc services/network/cookie_manager.cc
104index f91ffe61dba5..f3482e68cd11 100644
105--- services/network/cookie_manager.cc
106+++ services/network/cookie_manager.cc
107@@ -230,14 +230,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 1532b031db2c..066f68f38fd8 100644
127--- services/network/network_context.cc
128+++ services/network/network_context.cc
129@@ -2001,16 +2001,27 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext(
130         network_service_->network_quality_estimator());
131   }
132
133+  std::unique_ptr<net::CookieMonster> cookie_store;
134   if (session_cleanup_cookie_store) {
135-    std::unique_ptr<net::CookieMonster> cookie_store =
136+    cookie_store =
137         std::make_unique<net::CookieMonster>(session_cleanup_cookie_store.get(),
138                                              net_log);
139     if (params_->persist_session_cookies)
140       cookie_store->SetPersistSessionCookies(true);
141
142-    builder.SetCookieStore(std::move(cookie_store));
143+  } else {
144+    cookie_store =
145+        std::make_unique<net::CookieMonster>(nullptr /* store */, net_log);
146+  }
147+
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 ee27133a56df..3da7932bac49 100644
161--- services/network/public/mojom/network_context.mojom
162+++ services/network/public/mojom/network_context.mojom
163@@ -252,6 +252,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