2019-06-05 16:15:45 +02:00
|
|
|
diff --git net/cookies/cookie_monster.cc net/cookies/cookie_monster.cc
|
2024-11-14 23:07:03 +01:00
|
|
|
index 020b7141b4bf5..8879bae28f119 100644
|
2019-06-05 16:15:45 +02:00
|
|
|
--- net/cookies/cookie_monster.cc
|
|
|
|
+++ net/cookies/cookie_monster.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -635,6 +635,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) {
|
2022-10-17 19:27:40 +02:00
|
|
|
+ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
2019-06-05 16:15:45 +02:00
|
|
|
+
|
|
|
|
+ // 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) {
|
2022-10-17 19:27:40 +02:00
|
|
|
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
2019-06-05 16:15:45 +02:00
|
|
|
diff --git net/cookies/cookie_monster.h net/cookies/cookie_monster.h
|
2024-10-24 17:05:31 +02:00
|
|
|
index eaf790ed6050c..dfbe71c38204a 100644
|
2019-06-05 16:15:45 +02:00
|
|
|
--- net/cookies/cookie_monster.h
|
|
|
|
+++ net/cookies/cookie_monster.h
|
2024-05-23 03:52:35 +02:00
|
|
|
@@ -210,6 +210,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;
|
2024-02-22 19:36:15 +01:00
|
|
|
std::optional<bool> SiteHasCookieInOtherPartition(
|
2022-11-15 18:50:53 +01:00
|
|
|
const net::SchemefulSite& site,
|
2024-02-22 19:36:15 +01:00
|
|
|
const std::optional<CookiePartitionKey>& partition_key) const override;
|
2019-06-05 16:15:45 +02:00
|
|
|
diff --git net/cookies/cookie_store.h net/cookies/cookie_store.h
|
2024-02-22 19:36:15 +01:00
|
|
|
index 3f0be99e0e145..0462ebbe9bedc 100644
|
2019-06-05 16:15:45 +02:00
|
|
|
--- net/cookies/cookie_store.h
|
|
|
|
+++ net/cookies/cookie_store.h
|
2022-03-26 02:12:30 +01:00
|
|
|
@@ -163,6 +163,11 @@ class NET_EXPORT CookieStore {
|
2019-11-12 17:11:44 +01:00
|
|
|
// 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;
|
|
|
|
+
|
2021-09-20 11:06:23 +02:00
|
|
|
// This may be null if no delegate has been set yet, or the delegate has been
|
|
|
|
// reset to null.
|
|
|
|
const CookieAccessDelegate* cookie_access_delegate() const {
|
2019-06-05 16:15:45 +02:00
|
|
|
diff --git services/network/cookie_manager.cc services/network/cookie_manager.cc
|
2024-11-14 23:07:03 +01:00
|
|
|
index 06a85c11e6604..c1d0bcfac60d4 100644
|
2019-06-05 16:15:45 +02:00
|
|
|
--- services/network/cookie_manager.cc
|
|
|
|
+++ services/network/cookie_manager.cc
|
2024-07-29 19:09:20 +02:00
|
|
|
@@ -345,14 +345,9 @@ void CookieManager::AllowFileSchemeCookies(
|
2019-06-05 16:15:45 +02:00
|
|
|
AllowFileSchemeCookiesCallback callback) {
|
2023-07-21 00:11:34 +02:00
|
|
|
OnSettingsWillChange();
|
|
|
|
|
2019-06-05 16:15:45 +02:00
|
|
|
- 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
|
2024-11-14 23:07:03 +01:00
|
|
|
index cae84c27a26d6..ce496fd4f97ea 100644
|
2019-04-24 04:50:25 +02:00
|
|
|
--- services/network/network_context.cc
|
|
|
|
+++ services/network/network_context.cc
|
2024-11-14 23:07:03 +01:00
|
|
|
@@ -2640,17 +2640,21 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext(
|
2020-12-02 23:31:49 +01:00
|
|
|
network_service_->network_quality_estimator());
|
2019-04-24 04:50:25 +02:00
|
|
|
}
|
|
|
|
|
2022-01-25 21:26:51 +01:00
|
|
|
- if (session_cleanup_cookie_store) {
|
2019-04-24 04:50:25 +02:00
|
|
|
- std::unique_ptr<net::CookieMonster> cookie_store =
|
2022-10-17 19:27:40 +02:00
|
|
|
- std::make_unique<net::CookieMonster>(session_cleanup_cookie_store.get(),
|
|
|
|
- net_log);
|
2024-11-14 23:07:03 +01:00
|
|
|
- if (params_->persist_session_cookies) {
|
2022-01-25 21:26:51 +01:00
|
|
|
- cookie_store->SetPersistSessionCookies(true);
|
2024-11-14 23:07:03 +01:00
|
|
|
- }
|
2022-01-25 21:26:51 +01:00
|
|
|
+ std::unique_ptr<net::CookieMonster> cookie_store =
|
2022-10-17 19:27:40 +02:00
|
|
|
+ std::make_unique<net::CookieMonster>(session_cleanup_cookie_store.get(),
|
|
|
|
+ net_log);
|
2024-11-14 23:07:03 +01:00
|
|
|
+ if (session_cleanup_cookie_store && params_->persist_session_cookies) {
|
2022-01-25 21:26:51 +01:00
|
|
|
+ cookie_store->SetPersistSessionCookies(true);
|
2024-11-14 23:07:03 +01:00
|
|
|
+ }
|
2020-12-02 23:31:49 +01:00
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
- builder.SetCookieStore(std::move(cookie_store));
|
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
|
|
|
+
|
2023-04-26 21:55:59 +02:00
|
|
|
if (base::FeatureList::IsEnabled(features::kPrivateStateTokens) ||
|
|
|
|
base::FeatureList::IsEnabled(features::kFledgePst)) {
|
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
|
2024-11-14 23:07:03 +01:00
|
|
|
index f2c8a56442e0a..747948ea6d197 100644
|
2019-04-24 04:50:25 +02:00
|
|
|
--- services/network/public/mojom/network_context.mojom
|
|
|
|
+++ services/network/public/mojom/network_context.mojom
|
2024-11-14 23:07:03 +01:00
|
|
|
@@ -366,6 +366,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.
|