128 lines
5.7 KiB
Diff
128 lines
5.7 KiB
Diff
diff --git net/cookies/cookie_monster.cc net/cookies/cookie_monster.cc
|
|
index 6b19478013bf5..acc6f2dcb4472 100644
|
|
--- net/cookies/cookie_monster.cc
|
|
+++ net/cookies/cookie_monster.cc
|
|
@@ -635,6 +635,25 @@ void CookieMonster::SetCookieableSchemes(
|
|
MaybeRunCookieCallback(std::move(callback), true);
|
|
}
|
|
|
|
+void CookieMonster::AddCookieableSchemes(
|
|
+ const std::vector<std::string>& schemes,
|
|
+ SetCookieableSchemesCallback callback) {
|
|
+ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
|
+
|
|
+ // 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_CALLED_ON_VALID_THREAD(thread_checker_);
|
|
diff --git net/cookies/cookie_monster.h net/cookies/cookie_monster.h
|
|
index bea9a3b81a538..78fbab874c436 100644
|
|
--- net/cookies/cookie_monster.h
|
|
+++ net/cookies/cookie_monster.h
|
|
@@ -210,6 +210,8 @@ class NET_EXPORT CookieMonster : public CookieStore {
|
|
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;
|
|
std::optional<bool> SiteHasCookieInOtherPartition(
|
|
const net::SchemefulSite& site,
|
|
const std::optional<CookiePartitionKey>& partition_key) const override;
|
|
diff --git net/cookies/cookie_store.h net/cookies/cookie_store.h
|
|
index 3f0be99e0e145..0462ebbe9bedc 100644
|
|
--- net/cookies/cookie_store.h
|
|
+++ net/cookies/cookie_store.h
|
|
@@ -163,6 +163,11 @@ class NET_EXPORT CookieStore {
|
|
// Transfer ownership of a CookieAccessDelegate.
|
|
void SetCookieAccessDelegate(std::unique_ptr<CookieAccessDelegate> delegate);
|
|
|
|
+ // 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;
|
|
+
|
|
// 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 {
|
|
diff --git services/network/cookie_manager.cc services/network/cookie_manager.cc
|
|
index f78c6a467befc..97f1d21218eed 100644
|
|
--- services/network/cookie_manager.cc
|
|
+++ services/network/cookie_manager.cc
|
|
@@ -345,14 +345,9 @@ void CookieManager::AllowFileSchemeCookies(
|
|
AllowFileSchemeCookiesCallback callback) {
|
|
OnSettingsWillChange();
|
|
|
|
- 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() {
|
|
diff --git services/network/network_context.cc services/network/network_context.cc
|
|
index 502cd4ac8b0e8..4532f67ceca70 100644
|
|
--- services/network/network_context.cc
|
|
+++ services/network/network_context.cc
|
|
@@ -2578,16 +2578,20 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext(
|
|
network_service_->network_quality_estimator());
|
|
}
|
|
|
|
- if (session_cleanup_cookie_store) {
|
|
- std::unique_ptr<net::CookieMonster> cookie_store =
|
|
- std::make_unique<net::CookieMonster>(session_cleanup_cookie_store.get(),
|
|
- net_log);
|
|
- if (params_->persist_session_cookies)
|
|
- cookie_store->SetPersistSessionCookies(true);
|
|
+ std::unique_ptr<net::CookieMonster> cookie_store =
|
|
+ std::make_unique<net::CookieMonster>(session_cleanup_cookie_store.get(),
|
|
+ net_log);
|
|
+ if (session_cleanup_cookie_store && params_->persist_session_cookies)
|
|
+ cookie_store->SetPersistSessionCookies(true);
|
|
|
|
- builder.SetCookieStore(std::move(cookie_store));
|
|
+ if (params_->cookieable_schemes.has_value()) {
|
|
+ cookie_store->SetCookieableSchemes(
|
|
+ *params_->cookieable_schemes,
|
|
+ net::CookieStore::SetCookieableSchemesCallback());
|
|
}
|
|
|
|
+ builder.SetCookieStore(std::move(cookie_store));
|
|
+
|
|
if (base::FeatureList::IsEnabled(features::kPrivateStateTokens) ||
|
|
base::FeatureList::IsEnabled(features::kFledgePst)) {
|
|
trust_token_store_ = std::make_unique<PendingTrustTokenStore>();
|
|
diff --git services/network/public/mojom/network_context.mojom services/network/public/mojom/network_context.mojom
|
|
index b3775284f55c7..66f1b5279c7b7 100644
|
|
--- services/network/public/mojom/network_context.mojom
|
|
+++ services/network/public/mojom/network_context.mojom
|
|
@@ -359,6 +359,9 @@ struct NetworkContextParams {
|
|
// cookies. Otherwise it should be false.
|
|
bool persist_session_cookies = false;
|
|
|
|
+ // Schemes that will be passed to CookieMonster::SetCookieableSchemes.
|
|
+ array<string>? cookieable_schemes;
|
|
+
|
|
// 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.
|