From 5ce8156ee901cdf6769f0c97eea983d774691a47 Mon Sep 17 00:00:00 2001 From: Lily Chen Date: Mon, 26 Oct 2020 17:05:33 +0000 Subject: [PATCH] Remove unused emergency settings for SameSite cookie rollout This removes the feature and param for an emergency setting that was never used. This is now obsolete because SameSite-by-default cookies is now enabled by default. Bug: 1045122 Change-Id: I6528907276c986c8de7c69e3bad71c08b4f3d6d1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495352 Reviewed-by: Maksim Orlovich Commit-Queue: Lily Chen Cr-Commit-Position: refs/heads/master@{#820792} --- services/network/cookie_settings.cc | 35 +---------------- services/network/cookie_settings.h | 4 +- services/network/cookie_settings_unittest.cc | 40 -------------------- services/network/public/cpp/features.cc | 8 ---- services/network/public/cpp/features.h | 7 ---- 5 files changed, 5 insertions(+), 89 deletions(-) diff --git a/services/network/cookie_settings.cc b/services/network/cookie_settings.cc index 581e395660e465..628c8547d42114 100644 --- a/services/network/cookie_settings.cc +++ b/services/network/cookie_settings.cc @@ -8,55 +8,24 @@ #include "base/bind.h" #include "base/callback.h" -#include "base/strings/string_split.h" -#include "components/content_settings/core/common/content_settings_utils.h" #include "net/base/net_errors.h" #include "net/cookies/cookie_util.h" #include "net/cookies/static_cookie_policy.h" -#include "services/network/public/cpp/features.h" namespace network { namespace { + bool IsDefaultSetting(const ContentSettingPatternSource& setting) { return setting.primary_pattern.MatchesAllHosts() && setting.secondary_pattern.MatchesAllHosts(); } -void AppendEmergencyLegacyCookieAccess( - ContentSettingsForOneType* settings_for_legacy_cookie_access) { - if (!base::FeatureList::IsEnabled(features::kEmergencyLegacyCookieAccess)) - return; - - std::vector patterns = - SplitString(features::kEmergencyLegacyCookieAccessParam.Get(), ",", - base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); - - for (const auto& pattern_str : patterns) { - // Only primary pattern and the setting actually looked at here. - settings_for_legacy_cookie_access->push_back(ContentSettingPatternSource( - ContentSettingsPattern::FromString(pattern_str), - ContentSettingsPattern::Wildcard(), - /* legacy, see CookieSettingsBase::GetCookieAccessSemanticsForDomain */ - base::Value::FromUniquePtrValue( - content_settings::ContentSettingToValue(CONTENT_SETTING_ALLOW)), - std::string(), false)); - } -} - } // namespace -CookieSettings::CookieSettings() { - AppendEmergencyLegacyCookieAccess(&settings_for_legacy_cookie_access_); -} +CookieSettings::CookieSettings() = default; CookieSettings::~CookieSettings() = default; -void CookieSettings::set_content_settings_for_legacy_cookie_access( - const ContentSettingsForOneType& settings) { - settings_for_legacy_cookie_access_ = settings; - AppendEmergencyLegacyCookieAccess(&settings_for_legacy_cookie_access_); -} - DeleteCookiePredicate CookieSettings::CreateDeleteCookieOnExitPredicate() const { if (!HasSessionOnlyOrigins()) diff --git a/services/network/cookie_settings.h b/services/network/cookie_settings.h index 84eae4224702f1..949ad155508d7d 100644 --- a/services/network/cookie_settings.h +++ b/services/network/cookie_settings.h @@ -58,7 +58,9 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CookieSettings } void set_content_settings_for_legacy_cookie_access( - const ContentSettingsForOneType& settings); + const ContentSettingsForOneType& settings) { + settings_for_legacy_cookie_access_ = settings; + } void set_storage_access_grants(const ContentSettingsForOneType& settings) { storage_access_grants_ = settings; diff --git a/services/network/cookie_settings_unittest.cc b/services/network/cookie_settings_unittest.cc index 4e902b522880d6..0d0a06b4a89287 100644 --- a/services/network/cookie_settings_unittest.cc +++ b/services/network/cookie_settings_unittest.cc @@ -502,45 +502,5 @@ TEST_F(CookieSettingsTest, } } -TEST_F(CookieSettingsTest, CookieAccessSemanticsEmergencyOverride) { - base::test::ScopedFeatureList feature_list; - - feature_list.InitWithFeaturesAndParameters( - {{net::features::kSameSiteByDefaultCookies, {}}, - {features::kEmergencyLegacyCookieAccess, - {{features::kEmergencyLegacyCookieAccessParamName, - "example.org, [*.]example.gov"}}}}, - {} /* disabled_features*/); - CookieSettings settings; - settings.set_content_settings_for_legacy_cookie_access( - {CreateSetting(kDomainWildcardPattern, "*", CONTENT_SETTING_ALLOW)}); - - const struct { - net::CookieAccessSemantics status; - std::string cookie_domain; - } kTestCases[] = { - // These three test cases are LEGACY because they match the setting. - {net::CookieAccessSemantics::LEGACY, kDomain}, - {net::CookieAccessSemantics::LEGACY, kDotDomain}, - // Subdomain also matches pattern. - {net::CookieAccessSemantics::LEGACY, kSubDomain}, - // This test case defaults into NONLEGACY. - {net::CookieAccessSemantics::NONLEGACY, kOtherDomain}, - - // things that got pushed via experiment config. - {net::CookieAccessSemantics::LEGACY, "example.org"}, - {net::CookieAccessSemantics::NONLEGACY, "sub.example.org"}, - {net::CookieAccessSemantics::LEGACY, "example.gov"}, - {net::CookieAccessSemantics::LEGACY, "sub.example.gov"}, - {net::CookieAccessSemantics::NONLEGACY, "example.gov.uk"}, - }; - - for (const auto& test : kTestCases) { - EXPECT_EQ(test.status, - settings.GetCookieAccessSemanticsForDomain(test.cookie_domain)) - << test.cookie_domain; - } -} - } // namespace } // namespace network diff --git a/services/network/public/cpp/features.cc b/services/network/public/cpp/features.cc index abbb1b3bd21d65..40a5377c57a8c8 100644 --- a/services/network/public/cpp/features.cc +++ b/services/network/public/cpp/features.cc @@ -152,14 +152,6 @@ const base::Feature "DeriveOriginFromUrlForNeitherGetNorHeadRequestWhenHavingSpecialAccess", base::FEATURE_DISABLED_BY_DEFAULT}; -// Emergency switch for legacy cookie access semantics on given patterns, as -// specified by the param, comma separated. -const base::Feature kEmergencyLegacyCookieAccess{ - "EmergencyLegacyCookieAccess", base::FEATURE_DISABLED_BY_DEFAULT}; -const char kEmergencyLegacyCookieAccessParamName[] = "Patterns"; -const base::FeatureParam kEmergencyLegacyCookieAccessParam{ - &kEmergencyLegacyCookieAccess, kEmergencyLegacyCookieAccessParamName, ""}; - // Controls whether a |request_initiator| that mismatches // |request_initiator_origin_lock| leads to 1) failing the HTTP request and 2) // calling mojo::ReportBadMessage (on desktop platforms, where NetworkService diff --git a/services/network/public/cpp/features.h b/services/network/public/cpp/features.h index 1e602b31c177e1..a836a51eadcc6c 100644 --- a/services/network/public/cpp/features.h +++ b/services/network/public/cpp/features.h @@ -58,13 +58,6 @@ extern const base::Feature kDisableKeepaliveFetch; COMPONENT_EXPORT(NETWORK_CPP) extern const base::Feature kDeriveOriginFromUrlForNeitherGetNorHeadRequestWhenHavingSpecialAccess; -COMPONENT_EXPORT(NETWORK_CPP) -extern const base::Feature kEmergencyLegacyCookieAccess; -COMPONENT_EXPORT(NETWORK_CPP) -extern const char kEmergencyLegacyCookieAccessParamName[]; -COMPONENT_EXPORT(NETWORK_CPP) -extern const base::FeatureParam kEmergencyLegacyCookieAccessParam; - COMPONENT_EXPORT(NETWORK_CPP) extern const base::Feature kRequestInitiatorSiteLockEnfocement; COMPONENT_EXPORT(NETWORK_CPP)