diff options
Diffstat (limited to 'chrome')
6 files changed, 19 insertions, 49 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)); |