summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/android/preferences/website_preference_bridge.cc15
-rw-r--r--chrome/browser/browsing_data/cookies_tree_model.cc4
-rw-r--r--chrome/browser/content_settings/content_settings_browsertest.cc12
-rw-r--r--chrome/browser/content_settings/cookie_settings_factory_unittest.cc16
-rw-r--r--chrome/browser/extensions/extension_special_storage_policy_unittest.cc10
-rw-r--r--chrome/browser/net/chrome_network_delegate_unittest.cc11
-rw-r--r--components/content_settings/core/browser/cookie_settings.cc15
-rw-r--r--components/content_settings/core/browser/cookie_settings.h6
-rw-r--r--components/content_settings/core/browser/cookie_settings_unittest.cc41
9 files changed, 39 insertions, 91 deletions
diff --git a/chrome/browser/android/preferences/website_preference_bridge.cc b/chrome/browser/android/preferences/website_preference_bridge.cc
index 7d68c30..f044ab9 100644
--- a/chrome/browser/android/preferences/website_preference_bridge.cc
+++ b/chrome/browser/android/preferences/website_preference_bridge.cc
@@ -462,19 +462,14 @@ static void SetCookieSettingForOrigin(JNIEnv* env,
jint value,
jboolean is_incognito) {
GURL url(ConvertJavaStringToUTF8(env, origin));
- ContentSettingsPattern primary_pattern(
- ContentSettingsPattern::FromURLNoWildcard(url));
- ContentSettingsPattern secondary_pattern(ContentSettingsPattern::Wildcard());
- ContentSetting setting = CONTENT_SETTING_DEFAULT;
- if (value == -1) {
+ ContentSetting setting = static_cast<ContentSetting>(value);
+ if (setting == CONTENT_SETTING_DEFAULT) {
GetCookieSettings()->ResetCookieSetting(url);
} else {
- setting = value ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
- GetCookieSettings()->SetCookieSetting(primary_pattern, secondary_pattern,
- setting);
+ GetCookieSettings()->SetCookieSetting(url, setting);
}
- WebSiteSettingsUmaUtil::LogPermissionChange(
- CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting);
+ WebSiteSettingsUmaUtil::LogPermissionChange(CONTENT_SETTINGS_TYPE_COOKIES,
+ setting);
}
static jboolean IsContentSettingsPatternValid(
diff --git a/chrome/browser/browsing_data/cookies_tree_model.cc b/chrome/browser/browsing_data/cookies_tree_model.cc
index 26a67f6..a8fc041 100644
--- a/chrome/browser/browsing_data/cookies_tree_model.cc
+++ b/chrome/browser/browsing_data/cookies_tree_model.cc
@@ -765,9 +765,7 @@ void CookieTreeHostNode::CreateContentException(
setting == CONTENT_SETTING_SESSION_ONLY);
if (CanCreateContentException()) {
cookie_settings->ResetCookieSetting(url_);
- cookie_settings->SetCookieSetting(
- ContentSettingsPattern::FromURL(url_),
- ContentSettingsPattern::Wildcard(), setting);
+ cookie_settings->SetCookieSetting(url_, setting);
}
}
diff --git a/chrome/browser/content_settings/content_settings_browsertest.cc b/chrome/browser/content_settings/content_settings_browsertest.cc
index 65ecc14..7af3c5d 100644
--- a/chrome/browser/content_settings/content_settings_browsertest.cc
+++ b/chrome/browser/content_settings/content_settings_browsertest.cc
@@ -166,9 +166,7 @@ IN_PROC_BROWSER_TEST_F(ContentSettingsTest, AllowCookiesUsingExceptions) {
ui_test_utils::NavigateToURL(browser(), url);
ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
- settings->SetCookieSetting(
- ContentSettingsPattern::FromURL(url),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW);
+ settings->SetCookieSetting(url, CONTENT_SETTING_ALLOW);
ui_test_utils::NavigateToURL(browser(), url);
ASSERT_FALSE(GetCookies(browser()->profile(), url).empty());
@@ -180,9 +178,7 @@ IN_PROC_BROWSER_TEST_F(ContentSettingsTest, BlockCookiesUsingExceptions) {
GURL url = embedded_test_server()->GetURL("/setcookie.html");
content_settings::CookieSettings* settings =
CookieSettingsFactory::GetForProfile(browser()->profile()).get();
- settings->SetCookieSetting(ContentSettingsPattern::FromURL(url),
- ContentSettingsPattern::Wildcard(),
- CONTENT_SETTING_BLOCK);
+ settings->SetCookieSetting(url, CONTENT_SETTING_BLOCK);
ui_test_utils::NavigateToURL(browser(), url);
ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
@@ -212,9 +208,7 @@ IN_PROC_BROWSER_TEST_F(ContentSettingsTest,
ui_test_utils::NavigateToURL(browser(), url);
ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
- settings->SetCookieSetting(
- ContentSettingsPattern::FromURL(url),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_SESSION_ONLY);
+ settings->SetCookieSetting(url, CONTENT_SETTING_SESSION_ONLY);
ui_test_utils::NavigateToURL(browser(), url);
ASSERT_FALSE(GetCookies(browser()->profile(), url).empty());
}
diff --git a/chrome/browser/content_settings/cookie_settings_factory_unittest.cc b/chrome/browser/content_settings/cookie_settings_factory_unittest.cc
index beed137..a9cbafa 100644
--- a/chrome/browser/content_settings/cookie_settings_factory_unittest.cc
+++ b/chrome/browser/content_settings/cookie_settings_factory_unittest.cc
@@ -41,9 +41,7 @@ TEST_F(CookieSettingsFactoryTest, IncognitoBehaviorOfBlockingRules) {
// Modify the regular cookie settings after the incognito cookie settings have
// been instantiated.
- cookie_settings_->SetCookieSetting(
- ContentSettingsPattern::FromURL(kBlockedSite),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_BLOCK);
+ cookie_settings_->SetCookieSetting(kBlockedSite, CONTENT_SETTING_BLOCK);
// The modification should apply to the regular profile and incognito profile.
EXPECT_FALSE(
@@ -53,9 +51,7 @@ TEST_F(CookieSettingsFactoryTest, IncognitoBehaviorOfBlockingRules) {
// Modify an incognito cookie setting and check that this does not propagate
// into regular mode.
- incognito_settings->SetCookieSetting(
- ContentSettingsPattern::FromURL(kHttpsSite),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_BLOCK);
+ incognito_settings->SetCookieSetting(kHttpsSite, CONTENT_SETTING_BLOCK);
EXPECT_TRUE(cookie_settings_->IsReadingCookieAllowed(kHttpsSite, kHttpsSite));
EXPECT_FALSE(
incognito_settings->IsReadingCookieAllowed(kHttpsSite, kHttpsSite));
@@ -76,9 +72,7 @@ TEST_F(CookieSettingsFactoryTest, IncognitoBehaviorOfBlockingEverything) {
// A whitelisted item set in incognito mode should only apply to incognito
// mode.
- incognito_settings->SetCookieSetting(
- ContentSettingsPattern::FromURL(kAllowedSite),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW);
+ incognito_settings->SetCookieSetting(kAllowedSite, CONTENT_SETTING_ALLOW);
EXPECT_TRUE(
incognito_settings->IsReadingCookieAllowed(kAllowedSite, kAllowedSite));
EXPECT_FALSE(
@@ -86,9 +80,7 @@ TEST_F(CookieSettingsFactoryTest, IncognitoBehaviorOfBlockingEverything) {
// A whitelisted item set in regular mode should apply to regular and
// incognito mode.
- cookie_settings_->SetCookieSetting(
- ContentSettingsPattern::FromURL(kHttpsSite),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW);
+ cookie_settings_->SetCookieSetting(kHttpsSite, CONTENT_SETTING_ALLOW);
EXPECT_TRUE(
incognito_settings->IsReadingCookieAllowed(kHttpsSite, kHttpsSite));
EXPECT_TRUE(cookie_settings_->IsReadingCookieAllowed(kHttpsSite, kHttpsSite));
diff --git a/chrome/browser/extensions/extension_special_storage_policy_unittest.cc b/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
index 7ce7aaf..542ca9c 100644
--- a/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
+++ b/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
@@ -331,17 +331,13 @@ TEST_F(ExtensionSpecialStoragePolicyTest, HasSessionOnlyOrigins) {
EXPECT_FALSE(policy_->HasSessionOnlyOrigins());
// Or the session-onlyness can affect individual origins.
- ContentSettingsPattern pattern =
- ContentSettingsPattern::FromString("pattern.com");
-
- cookie_settings->SetCookieSetting(pattern,
- ContentSettingsPattern::Wildcard(),
- CONTENT_SETTING_SESSION_ONLY);
+ GURL url("http://pattern.com");
+ cookie_settings->SetCookieSetting(url, CONTENT_SETTING_SESSION_ONLY);
EXPECT_TRUE(policy_->HasSessionOnlyOrigins());
// Clearing an origin-specific rule.
- cookie_settings->ResetCookieSetting(GURL("http://pattern.com"));
+ cookie_settings->ResetCookieSetting(url);
EXPECT_FALSE(policy_->HasSessionOnlyOrigins());
}
diff --git a/chrome/browser/net/chrome_network_delegate_unittest.cc b/chrome/browser/net/chrome_network_delegate_unittest.cc
index 868e53d..b6feec3 100644
--- a/chrome/browser/net/chrome_network_delegate_unittest.cc
+++ b/chrome/browser/net/chrome_network_delegate_unittest.cc
@@ -499,10 +499,7 @@ TEST_F(ChromeNetworkDelegatePrivacyModeTest, EnablePrivacyIfCookiesBlocked) {
EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kBlockedSite,
kEmptyFirstPartySite));
- cookie_settings_->SetCookieSetting(
- ContentSettingsPattern::FromURL(kBlockedSite),
- ContentSettingsPattern::Wildcard(),
- CONTENT_SETTING_BLOCK);
+ cookie_settings_->SetCookieSetting(kBlockedSite, CONTENT_SETTING_BLOCK);
EXPECT_TRUE(network_delegate_->CanEnablePrivacyMode(kBlockedSite,
kEmptyFirstPartySite));
}
@@ -530,10 +527,8 @@ TEST_F(ChromeNetworkDelegatePrivacyModeTest,
EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite,
kBlockedFirstPartySite));
- cookie_settings_->SetCookieSetting(
- ContentSettingsPattern::FromURL(kBlockedFirstPartySite),
- ContentSettingsPattern::Wildcard(),
- CONTENT_SETTING_BLOCK);
+ cookie_settings_->SetCookieSetting(kBlockedFirstPartySite,
+ CONTENT_SETTING_BLOCK);
// Privacy mode is disabled as kAllowedSite is still getting cookies
EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite,
kBlockedFirstPartySite));
diff --git a/components/content_settings/core/browser/cookie_settings.cc b/components/content_settings/core/browser/cookie_settings.cc
index ebcc382..475b642 100644
--- a/components/content_settings/core/browser/cookie_settings.cc
+++ b/components/content_settings/core/browser/cookie_settings.cc
@@ -92,17 +92,12 @@ void CookieSettings::SetDefaultCookieSetting(ContentSetting setting) {
CONTENT_SETTINGS_TYPE_COOKIES, setting);
}
-void CookieSettings::SetCookieSetting(
- const ContentSettingsPattern& primary_pattern,
- const ContentSettingsPattern& secondary_pattern,
- ContentSetting setting) {
+void CookieSettings::SetCookieSetting(const GURL& primary_url,
+ ContentSetting setting) {
DCHECK(IsValidSetting(setting));
- if (setting == CONTENT_SETTING_SESSION_ONLY) {
- DCHECK(secondary_pattern == ContentSettingsPattern::Wildcard());
- }
- host_content_settings_map_->SetContentSetting(
- primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES,
- std::string(), setting);
+ host_content_settings_map_->SetContentSettingDefaultScope(
+ primary_url, GURL(), CONTENT_SETTINGS_TYPE_COOKIES, std::string(),
+ setting);
}
void CookieSettings::ResetCookieSetting(const GURL& primary_url) {
diff --git a/components/content_settings/core/browser/cookie_settings.h b/components/content_settings/core/browser/cookie_settings.h
index f3c6279..26ffa80 100644
--- a/components/content_settings/core/browser/cookie_settings.h
+++ b/components/content_settings/core/browser/cookie_settings.h
@@ -77,12 +77,10 @@ class CookieSettings : public RefcountedKeyedService {
// This should only be called on the UI thread.
void SetDefaultCookieSetting(ContentSetting setting);
- // Sets the cookie setting for the given patterns.
+ // Sets the cookie setting for the given url.
//
// This should only be called on the UI thread.
- void SetCookieSetting(const ContentSettingsPattern& primary_pattern,
- const ContentSettingsPattern& secondary_pattern,
- ContentSetting setting);
+ void SetCookieSetting(const GURL& primary_url, ContentSetting setting);
// Resets the cookie setting for the given url.
//
diff --git a/components/content_settings/core/browser/cookie_settings_unittest.cc b/components/content_settings/core/browser/cookie_settings_unittest.cc
index ab2f1c8..c1d0ef7 100644
--- a/components/content_settings/core/browser/cookie_settings_unittest.cc
+++ b/components/content_settings/core/browser/cookie_settings_unittest.cc
@@ -51,9 +51,7 @@ class CookieSettingsTest : public testing::Test {
};
TEST_F(CookieSettingsTest, TestWhitelistedScheme) {
- cookie_settings_->SetCookieSetting(ContentSettingsPattern::Wildcard(),
- ContentSettingsPattern::Wildcard(),
- CONTENT_SETTING_BLOCK);
+ cookie_settings_->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
EXPECT_FALSE(cookie_settings_->IsReadingCookieAllowed(kHttpSite, kChromeURL));
EXPECT_TRUE(cookie_settings_->IsReadingCookieAllowed(kHttpsSite, kChromeURL));
EXPECT_TRUE(cookie_settings_->IsReadingCookieAllowed(kChromeURL, kHttpSite));
@@ -69,9 +67,7 @@ TEST_F(CookieSettingsTest, TestWhitelistedScheme) {
}
TEST_F(CookieSettingsTest, CookiesBlockSingle) {
- cookie_settings_->SetCookieSetting(
- ContentSettingsPattern::FromURL(kBlockedSite),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_BLOCK);
+ cookie_settings_->SetCookieSetting(kBlockedSite, CONTENT_SETTING_BLOCK);
EXPECT_FALSE(
cookie_settings_->IsReadingCookieAllowed(kBlockedSite, kBlockedSite));
}
@@ -94,9 +90,7 @@ TEST_F(CookieSettingsTest, CookiesAllowThirdParty) {
}
TEST_F(CookieSettingsTest, CookiesExplicitBlockSingleThirdParty) {
- cookie_settings_->SetCookieSetting(
- ContentSettingsPattern::FromURL(kBlockedSite),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_BLOCK);
+ cookie_settings_->SetCookieSetting(kBlockedSite, CONTENT_SETTING_BLOCK);
EXPECT_FALSE(
cookie_settings_->IsReadingCookieAllowed(kBlockedSite, kFirstPartySite));
EXPECT_FALSE(
@@ -106,9 +100,8 @@ TEST_F(CookieSettingsTest, CookiesExplicitBlockSingleThirdParty) {
}
TEST_F(CookieSettingsTest, CookiesExplicitSessionOnly) {
- cookie_settings_->SetCookieSetting(
- ContentSettingsPattern::FromURL(kBlockedSite),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_SESSION_ONLY);
+ cookie_settings_->SetCookieSetting(kBlockedSite,
+ CONTENT_SETTING_SESSION_ONLY);
EXPECT_TRUE(
cookie_settings_->IsReadingCookieAllowed(kBlockedSite, kFirstPartySite));
EXPECT_TRUE(
@@ -124,9 +117,7 @@ TEST_F(CookieSettingsTest, CookiesExplicitSessionOnly) {
}
TEST_F(CookieSettingsTest, CookiesThirdPartyBlockedExplicitAllow) {
- cookie_settings_->SetCookieSetting(
- ContentSettingsPattern::FromURL(kAllowedSite),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW);
+ cookie_settings_->SetCookieSetting(kAllowedSite, CONTENT_SETTING_ALLOW);
prefs_.SetBoolean(prefs::kBlockThirdPartyCookies, true);
EXPECT_TRUE(
cookie_settings_->IsReadingCookieAllowed(kAllowedSite, kFirstPartySite));
@@ -142,15 +133,13 @@ TEST_F(CookieSettingsTest, CookiesThirdPartyBlockedExplicitAllow) {
}
TEST_F(CookieSettingsTest, CookiesThirdPartyBlockedAllSitesAllowed) {
- cookie_settings_->SetCookieSetting(
- ContentSettingsPattern::FromURL(kAllowedSite),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW);
+ cookie_settings_->SetCookieSetting(kAllowedSite, CONTENT_SETTING_ALLOW);
prefs_.SetBoolean(prefs::kBlockThirdPartyCookies, true);
- // As an example for a pattern that matches all hosts but not all origins,
+ // As an example for a url that matches all hosts but not all origins,
// match all HTTPS sites.
- cookie_settings_->SetCookieSetting(kAllHttpsSitesPattern,
- ContentSettingsPattern::Wildcard(),
- CONTENT_SETTING_ALLOW);
+ settings_map_->SetContentSetting(
+ kAllHttpsSitesPattern, ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_COOKIES, std::string(), CONTENT_SETTING_ALLOW);
cookie_settings_->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY);
// |kAllowedSite| should be allowed.
@@ -196,9 +185,7 @@ TEST_F(CookieSettingsTest, CookiesBlockEverything) {
TEST_F(CookieSettingsTest, CookiesBlockEverythingExceptAllowed) {
cookie_settings_->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
- cookie_settings_->SetCookieSetting(
- ContentSettingsPattern::FromURL(kAllowedSite),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW);
+ cookie_settings_->SetCookieSetting(kAllowedSite, CONTENT_SETTING_ALLOW);
EXPECT_FALSE(cookie_settings_->IsReadingCookieAllowed(kFirstPartySite,
kFirstPartySite));
EXPECT_FALSE(cookie_settings_->IsSettingCookieAllowed(kFirstPartySite,
@@ -215,9 +202,7 @@ TEST_F(CookieSettingsTest, CookiesBlockEverythingExceptAllowed) {
}
TEST_F(CookieSettingsTest, ExtensionsRegularSettings) {
- cookie_settings_->SetCookieSetting(
- ContentSettingsPattern::FromURL(kBlockedSite),
- ContentSettingsPattern::Wildcard(), CONTENT_SETTING_BLOCK);
+ cookie_settings_->SetCookieSetting(kBlockedSite, CONTENT_SETTING_BLOCK);
// Regular cookie settings also apply to extensions.
EXPECT_FALSE(