Files
cromite/build/patches/Partitioning-all-cookies-by-top-frame-domain.patch
T
2025-08-30 12:50:59 +02:00

614 lines
31 KiB
Diff

From: uazo <uazo@users.noreply.github.com>
Date: Mon, 9 Jan 2023 12:02:05 +0000
Subject: Partitioning all cookies by top frame domain
Enables cookie partitioning by top frame etld, respecting the
user's possible wish to disable all third-party cookies.
Disabling the flag via the ui restores the normal mode, where
samesite=none first-party cookies are sent in third-party contexts.
License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
---
.../browser/chrome_content_browser_client.cc | 2 +-
.../extensions/api/cookies/cookies_helpers.cc | 4 ++
.../net/profile_network_context_service.cc | 12 ++--
.../privacy_sandbox_settings_delegate.cc | 1 +
...storage_access_grant_permission_context.cc | 13 +++++
.../experiment/experiment_manager_impl.cc | 1 +
.../strings/android/site_settings.grdp | 4 +-
.../core/browser/cookie_settings.cc | 4 +-
.../core/common/cookie_settings_base.cc | 57 +------------------
...ioning-all-cookies-by-top-frame-domain.inc | 4 ++
...ioning-all-cookies-by-top-frame-domain.inc | 1 +
...ioning-all-cookies-by-top-frame-domain.inc | 1 +
...ioning-all-cookies-by-top-frame-domain.inc | 15 +++++
...ioning-all-cookies-by-top-frame-domain.inc | 1 +
net/cookies/canonical_cookie.cc | 5 --
net/cookies/cookie_deletion_info.cc | 3 +-
net/cookies/cookie_monster.cc | 1 +
net/cookies/cookie_util.cc | 1 +
net/cookies/cookie_util.h | 4 +-
net/cookies/parsed_cookie.h | 6 +-
.../sqlite/sqlite_persistent_cookie_store.cc | 8 +++
net/url_request/url_request.cc | 3 +-
net/url_request/url_request_http_job.cc | 11 ++--
services/network/cookie_settings.cc | 6 +-
services/network/cors/cors_url_loader.cc | 1 +
services/network/restricted_cookie_manager.cc | 6 ++
services/network/url_loader.cc | 1 +
.../modules/cookie_store/cookie_init.idl | 2 +-
.../modules/cookie_store/cookie_store.cc | 3 +
.../cookie_store_delete_options.idl | 2 +-
ui/webui/webui_allowlist.cc | 1 +
url/url_features.cc | 1 +
32 files changed, 94 insertions(+), 91 deletions(-)
create mode 100644 cromite_flags/components/content_settings/core/common/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
create mode 100644 cromite_flags/components/permissions/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
create mode 100644 cromite_flags/content/public/common/content_features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
create mode 100644 cromite_flags/net/base/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
create mode 100644 cromite_flags/services/network/public/cpp/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -3692,7 +3692,7 @@ bool ChromeContentBrowserClient::IsFullCookieAccessAllowed(
scoped_refptr<content_settings::CookieSettings> cookie_settings =
CookieSettingsFactory::GetForProfile(profile);
if (!cookie_settings) {
- return true;
+ return false;
}
return cookie_settings->IsFullCookieAccessAllowed(
url, storage_key.ToNetSiteForCookies(),
diff --git a/chrome/browser/extensions/api/cookies/cookies_helpers.cc b/chrome/browser/extensions/api/cookies/cookies_helpers.cc
--- a/chrome/browser/extensions/api/cookies/cookies_helpers.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_helpers.cc
@@ -365,6 +365,10 @@ ToNetCookiePartitionKey(
bool CookieMatchesPartitionKeyCollection(
const net::CookiePartitionKeyCollection& cookie_partition_key_collection,
const net::CanonicalCookie& cookie) {
+ if (cookie_partition_key_collection.ContainsAllKeys() ||
+ cookie_partition_key_collection.IsEmpty()) {
+ return true;
+ }
if (!cookie.IsPartitioned()) {
return cookie_partition_key_collection.ContainsAllKeys() ||
cookie_partition_key_collection.IsEmpty();
diff --git a/chrome/browser/net/profile_network_context_service.cc b/chrome/browser/net/profile_network_context_service.cc
--- a/chrome/browser/net/profile_network_context_service.cc
+++ b/chrome/browser/net/profile_network_context_service.cc
@@ -1127,16 +1127,16 @@ ProfileNetworkContextService::CreateCookieManagerParams(
// UI to interact with SameSite cookies on accounts.google.com, which is used
// for displaying a list of available accounts on the NTP
// (chrome://new-tab-page), etc.
- out->secure_origin_cookies_allowed_schemes.push_back(
- content::kChromeUIScheme);
+ // out->secure_origin_cookies_allowed_schemes.push_back(
+ // content::kChromeUIScheme);
#if BUILDFLAG(ENABLE_EXTENSIONS)
// TODO(chlily): To be consistent with the content_settings version of
// CookieSettings, we should probably also add kExtensionScheme to the list of
// matching_scheme_cookies_allowed_schemes.
- out->third_party_cookies_allowed_schemes.push_back(
- extensions::kExtensionScheme);
- out->third_party_cookies_allowed_schemes.push_back(
- content::kChromeDevToolsScheme);
+ // out->third_party_cookies_allowed_schemes.push_back(
+ // extensions::kExtensionScheme);
+ // out->third_party_cookies_allowed_schemes.push_back(
+ // content::kChromeDevToolsScheme);
#endif
HostContentSettingsMap* host_content_settings_map =
diff --git a/chrome/browser/privacy_sandbox/privacy_sandbox_settings_delegate.cc b/chrome/browser/privacy_sandbox/privacy_sandbox_settings_delegate.cc
--- a/chrome/browser/privacy_sandbox/privacy_sandbox_settings_delegate.cc
+++ b/chrome/browser/privacy_sandbox/privacy_sandbox_settings_delegate.cc
@@ -354,6 +354,7 @@ bool PrivacySandboxSettingsDelegate::IsCookieDeprecationLabelAllowed() const {
bool PrivacySandboxSettingsDelegate::
AreThirdPartyCookiesBlockedByCookieDeprecationExperiment() const {
+ if ((true)) return false;
if (net::cookie_util::IsForceThirdPartyCookieBlockingEnabled()) {
return false;
}
diff --git a/chrome/browser/storage_access_api/storage_access_grant_permission_context.cc b/chrome/browser/storage_access_api/storage_access_grant_permission_context.cc
--- a/chrome/browser/storage_access_api/storage_access_grant_permission_context.cc
+++ b/chrome/browser/storage_access_api/storage_access_grant_permission_context.cc
@@ -220,6 +220,7 @@ FederatedIdentityPermissionContext* IsAutograntViaFedCmAllowed(
const url::Origin& embedding_origin,
const net::SchemefulSite& embedding_site,
const net::SchemefulSite& requesting_site) {
+ if ((true)) return nullptr;
CHECK(browser_context);
if (!rfh->IsFeatureEnabled(
network::mojom::PermissionsPolicyFeature::kIdentityCredentialsGet)) {
@@ -466,6 +467,18 @@ void StorageAccessGrantPermissionContext::CheckForAutoGrantOrAutoDenial(
std::unique_ptr<permissions::PermissionRequestData> request_data,
permissions::BrowserPermissionCallback callback,
net::FirstPartySetMetadata metadata) {
+ if ((true)) {
+ // don't use implicit grants or heuristic, ask to user
+ PermissionContextBase::DecidePermission(std::move(request_data),
+ std::move(callback));
+ // to deny:
+ // NotifyPermissionSetInternal(request_data.id, request_data.requesting_origin,
+ // request_data.embedding_origin,
+ // std::move(callback),
+ // /*persist=*/true, CONTENT_SETTING_BLOCK,
+ // RequestOutcome::kDeniedByFirstPartySet);
+ return;
+ }
if (metadata.AreSitesInSameFirstPartySet()) {
switch (metadata.top_frame_entry()->site_type()) {
case net::SiteType::kPrimary:
diff --git a/chrome/browser/tpcd/experiment/experiment_manager_impl.cc b/chrome/browser/tpcd/experiment/experiment_manager_impl.cc
--- a/chrome/browser/tpcd/experiment/experiment_manager_impl.cc
+++ b/chrome/browser/tpcd/experiment/experiment_manager_impl.cc
@@ -177,6 +177,7 @@ void ExperimentManagerImpl::MaybeUpdateSyntheticTrialRegistration() {
}
std::optional<bool> ExperimentManagerImpl::IsClientEligible() const {
+ if ((true)) return std::nullopt;
if (kForceEligibleForTesting.Get()) {
return true;
}
diff --git a/components/browser_ui/strings/android/site_settings.grdp b/components/browser_ui/strings/android/site_settings.grdp
--- a/components/browser_ui/strings/android/site_settings.grdp
+++ b/components/browser_ui/strings/android/site_settings.grdp
@@ -53,7 +53,7 @@
Third-party cookies
</message>
<message name="IDS_THIRD_PARTY_COOKIES_LINK_ROW_SUB_LABEL_ENABLED" desc="1 of 3 possible states for the Third-party cookies setting. This text appears beneath the 'Third-party cookies' button label.">
- Third-party cookies are allowed
+ Third-party cookies are partitioned
</message>
<message name="IDS_THIRD_PARTY_COOKIES_LINK_ROW_SUB_LABEL_DISABLED_INCOGNITO" desc="2 of 3 possible states for the Third-party cookies setting. This text appears beneath the 'Third-party cookies' button label.">
Third-party cookies are blocked in Incognito mode
@@ -658,7 +658,7 @@
Allow third-party cookies
</message>
<message name="IDS_WEBSITE_SETTINGS_THIRD_PARTY_COOKIES_PAGE_ALLOW_RADIO_SUB_LABEL" desc="This string appears as a sub label beneath the 'Allow all cookies' label. It summarizes the result of choosing this option.">
- Sites will work normally
+ Partitions all cookies by top frame url
</message>
<message name="IDS_WEBSITE_SETTINGS_THIRD_PARTY_COOKIES_PAGE_BLOCK_INCOGNITO_RADIO_LABEL" desc="2 of 3 options the user has to configure cookies. See the cookies page for context: chrome://settings/cookies. For more about Incognito mode, see https://support.google.com/chrome?p=incognito.">
Block third-party cookies in Incognito mode
diff --git a/components/content_settings/core/browser/cookie_settings.cc b/components/content_settings/core/browser/cookie_settings.cc
--- a/components/content_settings/core/browser/cookie_settings.cc
+++ b/components/content_settings/core/browser/cookie_settings.cc
@@ -126,6 +126,7 @@ void CookieSettings::SetTemporaryCookieGrantForHeuristic(
const GURL& first_party_url,
base::TimeDelta ttl,
bool use_schemeless_patterns) {
+ if ((true)) return;
if (url.is_empty() || first_party_url.is_empty()) {
return;
}
@@ -402,8 +403,7 @@ bool CookieSettings::ShouldBlockThirdPartyCookiesInternal() const {
}
bool CookieSettings::MitigationsEnabledFor3pcdInternal() const {
- return AreThirdPartyCookiesLimited() ||
- net::cookie_util::IsForceThirdPartyCookieBlockingEnabled();
+ return false;
}
void CookieSettings::OnContentSettingChanged(
diff --git a/components/content_settings/core/common/cookie_settings_base.cc b/components/content_settings/core/common/cookie_settings_base.cc
--- a/components/content_settings/core/common/cookie_settings_base.cc
+++ b/components/content_settings/core/common/cookie_settings_base.cc
@@ -668,18 +668,6 @@ CookieSettingsBase::DecideAccess(const GURL& url,
ThirdPartyCookieAllowMechanism::kAllowByGlobalSetting};
}
- if (IsThirdPartyCookiesAllowedScheme(first_party_url.scheme())) {
- return AllowAllCookies{ThirdPartyCookieAllowMechanism::kAllowByScheme};
- }
-
- // Site controlled mechanisms (ex: web APIs, deprecation trial):
- if (IsAllowedByTopLevelStorageAccessGrant(url, first_party_url, overrides)) {
- return AllowAllCookies{
- ThirdPartyCookieAllowMechanism::kAllowByTopLevelStorageAccess,
- IsAllowedByStorageAccessGrant(url, first_party_url, overrides)
- ? AllowedByStorageAccessType::kTopLevelAndStorageAccess
- : AllowedByStorageAccessType::kTopLevelOnly};
- }
if (IsAllowedByStorageAccessGrant(url, first_party_url, overrides)) {
return AllowAllCookies{
ThirdPartyCookieAllowMechanism::kAllowByStorageAccess,
@@ -690,54 +678,11 @@ CookieSettingsBase::DecideAccess(const GURL& url,
ThirdPartyCookieAllowMechanism::kAllowBySandboxValue};
}
- if (IsAllowedBy3pcdHeuristicsGrantsSettings(url, first_party_url,
- overrides)) {
- return AllowAllCookies{
- ThirdPartyCookieAllowMechanism::kAllowBy3PCDHeuristics};
- }
-
- // Enterprise Policies:
- if (is_explicit_setting && setting_info.source == SettingSource::kPolicy) {
- return AllowAllCookies{ThirdPartyCookieAllowMechanism::
- kAllowByEnterprisePolicyCookieAllowedForUrls};
- }
-
- // Chrome controlled mechanisms (ex. 3PCD Metadata Grants):
- if (IsAllowedWithMetadata tpcd_metadata_info =
- IsAllowedBy3pcdMetadataGrantsSettings(url, first_party_url,
- overrides);
- tpcd_metadata_info.allowed) {
- return AllowAllCookies{TpcdMetadataSourceToAllowMechanism(
- tpcd_metadata_info.info.metadata.tpcd_metadata_rule_source())};
- }
-
if (is_explicit_setting) {
return AllowAllCookies{
ThirdPartyCookieAllowMechanism::kAllowByExplicitSetting};
}
- // 3PCD 1P and 3P DTs
- // New registrations are not supported for the deprecation trials, but the
- // tokens are still valid until they expire.
- // TODO(https://crbug.com/364917750): Remove this check once the trials are no
- // longer relevant.
- if (IsAllowedByTopLevel3pcdTrialSettings(first_party_url, overrides)) {
- return AllowAllCookies{
- ThirdPartyCookieAllowMechanism::kAllowByTopLevel3PCD};
- }
- if (IsAllowedBy3pcdTrialSettings(url, first_party_url, overrides)) {
- return AllowAllCookies{ThirdPartyCookieAllowMechanism::kAllowBy3PCD};
- }
-
- // Check for a TRACKING_PROTECTION exception, which should also disable 3PCB.
- if (IsAllowedWithMetadata tp_info =
- IsAllowedByTrackingProtectionSetting(url, first_party_url);
- tp_info.allowed) {
- setting_info = std::move(tp_info.info);
- return AllowAllCookies{
- ThirdPartyCookieAllowMechanism::kAllowByTrackingProtectionException};
- }
-
return AllowPartitionedCookies{};
}
@@ -767,7 +712,7 @@ CookieSettingsBase::GetCookieSettingInternal(
}
return CookieSettingWithMetadata{/*cookie_setting=*/CONTENT_SETTING_ALLOW,
/*allow_partitioned_cookies=*/true,
- /*is_explicit_setting=*/false,
+ /*is_explicit_setting=*/true,
/*third_party_cookie_allow_mechanism=*/
ThirdPartyCookieAllowMechanism::kNone,
/*is_third_party_request=*/false};
diff --git a/cromite_flags/components/content_settings/core/common/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc b/cromite_flags/components/content_settings/core/common/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
new file mode 100644
--- /dev/null
+++ b/cromite_flags/components/content_settings/core/common/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
@@ -0,0 +1,4 @@
+SET_CROMITE_FEATURE_DISABLED(kTrackingProtection3pcd);
+SET_CROMITE_FEATURE_DISABLED(kUserBypassUI);
+SET_CROMITE_FEATURE_DISABLED(kTpcdHeuristicsGrants);
+SET_CROMITE_FEATURE_DISABLED(kNativeUnpartitionedStoragePermittedWhen3PCOff);
diff --git a/cromite_flags/components/permissions/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc b/cromite_flags/components/permissions/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
new file mode 100644
--- /dev/null
+++ b/cromite_flags/components/permissions/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
@@ -0,0 +1 @@
+SET_CROMITE_FEATURE_ENABLED(kShowRelatedWebsiteSetsPermissionGrants);
diff --git a/cromite_flags/content/public/common/content_features_cc/Partitioning-all-cookies-by-top-frame-domain.inc b/cromite_flags/content/public/common/content_features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
new file mode 100644
--- /dev/null
+++ b/cromite_flags/content/public/common/content_features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
@@ -0,0 +1 @@
+SET_CROMITE_FEATURE_DISABLED(kCookieDeprecationFacilitatedTesting);
diff --git a/cromite_flags/net/base/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc b/cromite_flags/net/base/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
new file mode 100644
--- /dev/null
+++ b/cromite_flags/net/base/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
@@ -0,0 +1,15 @@
+SET_CROMITE_FEATURE_ENABLED(kCookieDomainRejectNonASCII);
+
+SET_CROMITE_FEATURE_DISABLED(kForceThirdPartyCookieBlocking);
+SET_CROMITE_FEATURE_DISABLED(kThirdPartyPartitionedStorageAllowedByDefault);
+
+SET_CROMITE_FEATURE_ENABLED(kCookieSameSiteConsidersRedirectChain);
+SET_CROMITE_FEATURE_ENABLED(kSameSiteDefaultChecksMethodRigorously);
+SET_CROMITE_FEATURE_ENABLED(kTimeLimitedInsecureCookies);
+
+SET_CROMITE_FEATURE_DISABLED(kTpcdMetadataGrants);
+SET_CROMITE_FEATURE_DISABLED(kTpcdMetadataStageControl);
+
+// Implement `Activate-Storage-Access: retry` header semantics
+// https://source.chromium.org/chromium/chromium/src/+/ca4775cd3edadea0c3e756e772c3afc766e46fd1
+// SET_CROMITE_FEATURE_DISABLED(kStorageAccessHeaderRetry);
diff --git a/cromite_flags/services/network/public/cpp/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc b/cromite_flags/services/network/public/cpp/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
new file mode 100644
--- /dev/null
+++ b/cromite_flags/services/network/public/cpp/features_cc/Partitioning-all-cookies-by-top-frame-domain.inc
@@ -0,0 +1 @@
+// intentionally empty
diff --git a/net/cookies/canonical_cookie.cc b/net/cookies/canonical_cookie.cc
--- a/net/cookies/canonical_cookie.cc
+++ b/net/cookies/canonical_cookie.cc
@@ -1036,11 +1036,6 @@ CanonicalCookie::IsCanonicalForFromStorage() const {
return Fail(CanonicalizationFailure::kEmptyNameWithHiddenPrefix);
}
- if (IsPartitioned() && !CookiePartitionKey::HasNonce(PartitionKey()) &&
- !SecureAttribute()) {
- return Fail(CanonicalizationFailure::kPartitionedInsecure);
- }
-
return Pass();
}
diff --git a/net/cookies/cookie_deletion_info.cc b/net/cookies/cookie_deletion_info.cc
--- a/net/cookies/cookie_deletion_info.cc
+++ b/net/cookies/cookie_deletion_info.cc
@@ -131,7 +131,8 @@ bool CookieDeletionInfo::Matches(const CanonicalCookie& cookie,
return false;
}
- if (cookie.IsPartitioned() &&
+ // opened bug https://bugs.chromium.org/p/chromium/issues/detail?id=1405772
+ if (cookie.IsPartitioned() && !cookie_partition_key_collection.IsEmpty() &&
!cookie_partition_key_collection.Contains(*cookie.PartitionKey())) {
return false;
}
diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc
--- a/net/cookies/cookie_monster.cc
+++ b/net/cookies/cookie_monster.cc
@@ -2292,6 +2292,7 @@ size_t CookieMonster::GarbageCollectPartitionedCookies(
if (cookie_partition_it == partitioned_cookies_.end())
return num_deleted;
+ if ((false))
if (NumBytesInCookieMapForKey(*cookie_partition_it->second.get(), key) >
kPerPartitionDomainMaxCookieBytes ||
cookie_partition_it->second->count(key) > kPerPartitionDomainMaxCookies) {
diff --git a/net/cookies/cookie_util.cc b/net/cookies/cookie_util.cc
--- a/net/cookies/cookie_util.cc
+++ b/net/cookies/cookie_util.cc
@@ -828,6 +828,7 @@ bool IsCookiePartitionedValid(const GURL& url,
bool secure,
bool is_partitioned,
bool partition_has_nonce) {
+ if ((true)) return true;
if (!is_partitioned) {
return true;
}
diff --git a/net/cookies/cookie_util.h b/net/cookies/cookie_util.h
--- a/net/cookies/cookie_util.h
+++ b/net/cookies/cookie_util.h
@@ -132,7 +132,7 @@ enum class SecFetchStorageAccessOutcome {
enum class ActivateStorageAccessLoadOutcome {
// Applies when the `Activate-Storage-Access` header behavior is not enabled
// under the existing feature flags or content settings.
- // kFailureHeaderDisabled = 0, // Deprecated (feature is always enabled).
+ kFailureHeaderDisabled = 0, // Deprecated (feature is always enabled).
// Applies when a response includes the `Activate-Storage-Access: load`
// header, but its corresponding request either has an omitted storage access
// status, or has a storage access status of `none`.
@@ -153,7 +153,7 @@ enum class ActivateStorageAccessLoadOutcome {
enum class ActivateStorageAccessRetryOutcome {
// Applies when the `Activate-Storage-Access` header behavior is not enabled
// under the existing feature flags or content settings.
- // kFailureHeaderDisabled = 0, // Deprecated (feature is always enabled).
+ kFailureHeaderDisabled = 0, // Deprecated (feature is always enabled).
// Applies when a response includes a well-formed
// `Activate-Storage-Access: retry; ..." header, but the corresponding
// request's `Sec-Fetch-Storage-Access` header is not `inactive`.
diff --git a/net/cookies/parsed_cookie.h b/net/cookies/parsed_cookie.h
--- a/net/cookies/parsed_cookie.h
+++ b/net/cookies/parsed_cookie.h
@@ -13,6 +13,7 @@
#include <vector>
#include "base/functional/function_ref.h"
+#include "net/base/features.h"
#include "net/base/net_export.h"
#include "net/cookies/cookie_constants.h"
@@ -84,7 +85,10 @@ class NET_EXPORT ParsedCookie {
// attribute value.
std::pair<CookieSameSite, CookieSameSiteString> SameSite() const;
CookiePriority Priority() const;
- bool IsPartitioned() const { return partitioned_index_ != 0; }
+ bool IsPartitioned() const {
+ if ((true)) return true;
+ return partitioned_index_ != 0;
+ }
bool HasInternalHtab() const { return internal_htab_; }
// Returns the number of attributes, for example, returning 2 for:
// "BLAH=hah; path=/; domain=.google.com"
diff --git a/net/extras/sqlite/sqlite_persistent_cookie_store.cc b/net/extras/sqlite/sqlite_persistent_cookie_store.cc
--- a/net/extras/sqlite/sqlite_persistent_cookie_store.cc
+++ b/net/extras/sqlite/sqlite_persistent_cookie_store.cc
@@ -897,6 +897,14 @@ bool SQLitePersistentCookieStore::Backend::DoInitializeDatabase() {
if (!restore_old_session_cookies_)
DeleteSessionCookiesOnStartup();
+ // Since there is no automatic transition to partitioned cookies
+ // (the information would be missing), we clean the current ones
+ // present because they would otherwise be sent in third-party contexts
+ // even if the flag is active.
+ if (!db()->Execute("DELETE FROM cookies WHERE top_frame_site_key = ''")) {
+ LOG(WARNING) << "Unable to delete unpartitioned cookies.";
+ }
+
return true;
}
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -1415,8 +1415,7 @@ StorageAccessStatusCache URLRequest::CalculateStorageAccessStatus() const {
// `deferred_redirect_info_` that has to be used when calculating new storage
// access status.
std::optional<net::cookie_util::StorageAccessStatus> storage_access_status =
- network_delegate()->GetStorageAccessStatus(*this,
- deferred_redirect_info_);
+ std::nullopt; // disable storage access headers
base::UmaHistogramEnumeration(
"API.StorageAccessHeader.StorageAccessStatusOutcome",
storage_access_status
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -878,13 +878,9 @@ void URLRequestHttpJob::SetCookieHeaderAndStart(
AnnotateAndMoveUserBlockedCookies(maybe_included_cookies, excluded_cookies);
}
- const bool cookie_deprecation_testing_enabled =
- request_->context()->cookie_deprecation_label().has_value();
- const bool cookie_deprecation_testing_has_label =
- cookie_deprecation_testing_enabled &&
- !request_->context()->cookie_deprecation_label().value().empty();
- bool may_set_sec_cookie_deprecation_header =
- cookie_deprecation_testing_has_label;
+ const bool cookie_deprecation_testing_enabled = false;
+ const bool cookie_deprecation_testing_has_label = false;
+ bool may_set_sec_cookie_deprecation_header = false;
if (!maybe_included_cookies.empty()) {
std::string cookie_line =
@@ -1645,6 +1641,7 @@ bool URLRequestHttpJob::NeedsRetryWithStorageAccess() {
auto determine_storage_access_retry_outcome =
[&]() -> cookie_util::ActivateStorageAccessRetryOutcome {
using enum cookie_util::ActivateStorageAccessRetryOutcome;
+ if ((true)) return kFailureHeaderDisabled; // disable storage access headers
if (!ShouldAddCookieHeader() ||
request_->storage_access_status() !=
cookie_util::StorageAccessStatus::kInactive ||
diff --git a/services/network/cookie_settings.cc b/services/network/cookie_settings.cc
--- a/services/network/cookie_settings.cc
+++ b/services/network/cookie_settings.cc
@@ -46,8 +46,7 @@ namespace network {
namespace {
bool ShouldApply3pcdRelatedReasons(const net::CanonicalCookie& cookie) {
- return cookie.SameSite() == net::CookieSameSite::NO_RESTRICTION &&
- !cookie.IsPartitioned();
+ return cookie.SameSite() == net::CookieSameSite::NO_RESTRICTION;
}
@@ -124,8 +123,7 @@ bool IsOriginOpaqueHttpOrHttps(
// static
bool CookieSettings::IsCookieAllowed(const net::CanonicalCookie& cookie,
const CookieSettingWithMetadata& setting) {
- return IsAllowed(setting.cookie_setting()) ||
- (cookie.IsPartitioned() && setting.allow_partitioned_cookies());
+ return IsAllowed(setting.cookie_setting());
}
// static
diff --git a/services/network/cors/cors_url_loader.cc b/services/network/cors/cors_url_loader.cc
--- a/services/network/cors/cors_url_loader.cc
+++ b/services/network/cors/cors_url_loader.cc
@@ -903,6 +903,7 @@ void CorsURLLoader::StartRequest() {
}
if (request_.credentials_mode == mojom::CredentialsMode::kInclude &&
+ ((false)) && // storage access headers disabled by default
GetStorageAccessStatus() ==
net::cookie_util::StorageAccessStatus::kInactive) {
// Lower layers will add the Sec-Fetch-Storage-Access header, and the
diff --git a/services/network/restricted_cookie_manager.cc b/services/network/restricted_cookie_manager.cc
--- a/services/network/restricted_cookie_manager.cc
+++ b/services/network/restricted_cookie_manager.cc
@@ -983,6 +983,12 @@ void RestrictedCookieManager::SetCookieFromString(
shared_memory_region = GetAndPrepareSharedMemoryRegion(url);
}
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=911299
+ bool site_for_cookies_ok =
+ BoundSiteForCookies().IsEquivalent(site_for_cookies);
+ bool top_frame_origin_ok = top_frame_origin == BoundTopFrameOrigin();
+ if (!site_for_cookies_ok || !top_frame_origin_ok) return;
+
net::CookieInclusionStatus status;
std::unique_ptr<net::CanonicalCookie> parsed_cookie =
net::CanonicalCookie::Create(
diff --git a/services/network/url_loader.cc b/services/network/url_loader.cc
--- a/services/network/url_loader.cc
+++ b/services/network/url_loader.cc
@@ -2544,6 +2544,7 @@ bool URLLoader::ShouldSetLoadWithStorageAccess() const {
auto determine_storage_access_load_outcome =
[&]() -> net::cookie_util::ActivateStorageAccessLoadOutcome {
+ if ((true)) return net::cookie_util::ActivateStorageAccessLoadOutcome::kFailureHeaderDisabled;
if (!url_request_->storage_access_status().IsSet()) {
url_request_->set_storage_access_status(
url_request_->CalculateStorageAccessStatus());
diff --git a/third_party/blink/renderer/modules/cookie_store/cookie_init.idl b/third_party/blink/renderer/modules/cookie_store/cookie_init.idl
--- a/third_party/blink/renderer/modules/cookie_store/cookie_init.idl
+++ b/third_party/blink/renderer/modules/cookie_store/cookie_init.idl
@@ -17,5 +17,5 @@ dictionary CookieInit {
USVString path = "/";
DOMHighResTimeStamp? expires = null;
CookieSameSite sameSite = "strict";
- boolean partitioned = false;
+ boolean partitioned = true;
};
diff --git a/third_party/blink/renderer/modules/cookie_store/cookie_store.cc b/third_party/blink/renderer/modules/cookie_store/cookie_store.cc
--- a/third_party/blink/renderer/modules/cookie_store/cookie_store.cc
+++ b/third_party/blink/renderer/modules/cookie_store/cookie_store.cc
@@ -386,6 +386,7 @@ ScriptPromise<IDLUndefined> CookieStore::set(ScriptState* script_state,
CookieInit* set_options = CookieInit::Create();
set_options->setName(name);
set_options->setValue(value);
+ set_options->setPartitioned(true);
return set(script_state, set_options, exception_state);
}
@@ -409,6 +410,7 @@ ScriptPromise<IDLUndefined> CookieStore::Delete(
set_options->setName(name);
set_options->setValue(name.empty() ? "deleted" : "");
set_options->setExpires(0);
+ set_options->setPartitioned(true);
return DoWrite(script_state, set_options, exception_state);
}
@@ -424,6 +426,7 @@ ScriptPromise<IDLUndefined> CookieStore::Delete(
set_options->setPath(options->path());
set_options->setSameSite(V8CookieSameSite::Enum::kStrict);
set_options->setPartitioned(options->partitioned());
+ set_options->setPartitioned(true);
return DoWrite(script_state, set_options, exception_state);
}
diff --git a/third_party/blink/renderer/modules/cookie_store/cookie_store_delete_options.idl b/third_party/blink/renderer/modules/cookie_store/cookie_store_delete_options.idl
--- a/third_party/blink/renderer/modules/cookie_store/cookie_store_delete_options.idl
+++ b/third_party/blink/renderer/modules/cookie_store/cookie_store_delete_options.idl
@@ -8,5 +8,5 @@ dictionary CookieStoreDeleteOptions {
required USVString name;
USVString? domain = null;
USVString path = "/";
- boolean partitioned = false;
+ boolean partitioned = true;
};
diff --git a/ui/webui/webui_allowlist.cc b/ui/webui/webui_allowlist.cc
--- a/ui/webui/webui_allowlist.cc
+++ b/ui/webui/webui_allowlist.cc
@@ -75,6 +75,7 @@ void WebUIAllowlist::RegisterAutoGrantedPermissions(
void WebUIAllowlist::RegisterAutoGrantedThirdPartyCookies(
const url::Origin& top_level_origin,
const std::vector<ContentSettingsPattern>& origin_patterns) {
+ if ((true)) return;
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
diff --git a/url/url_features.cc b/url/url_features.cc
--- a/url/url_features.cc
+++ b/url/url_features.cc
@@ -10,6 +10,7 @@ namespace url {
BASE_FEATURE(kDisallowSpaceCharacterInURLHostParsing,
"DisallowSpaceCharacterInURLHostParsing",
base::FEATURE_DISABLED_BY_DEFAULT);
+SET_CROMITE_FEATURE_ENABLED(kDisallowSpaceCharacterInURLHostParsing);
bool IsDisallowingSpaceCharacterInURLHostParsing() {
// If the FeatureList isn't available yet, fall back to the feature's default
--