Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4211)

Unified Diff: chrome/browser/content_settings/content_settings_pref_provider_unittest.cc

Issue 1442083002: Stop inheriting push notification permissions from regular to incognito (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/content_settings/content_settings_pref_provider_unittest.cc
diff --git a/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc b/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc
index 85a30726e4f25ce90f807bb183612eb7df4afc0b..2a0511ca4e87466cd2febc48d917fd27e6eb9d0d 100644
--- a/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc
+++ b/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc
@@ -517,6 +517,71 @@ TEST_F(PrefProviderTest, IncognitoInheritsValueMap) {
normal_provider.ShutdownOnUIThread();
}
+TEST_F(PrefProviderTest, IncognitoDoesNotInheritNotifications) {
+ syncable_prefs::TestingPrefServiceSyncable prefs;
+ PrefProvider::RegisterProfilePrefs(prefs.registry());
+
+ ContentSettingsPattern pattern_1 =
+ ContentSettingsPattern::FromString("google.com");
+ ContentSettingsPattern pattern_2 =
+ ContentSettingsPattern::FromString("www.google.com");
+ ContentSettingsPattern wildcard =
+ ContentSettingsPattern::FromString("*");
+ scoped_ptr<base::Value> value(
+ new base::FundamentalValue(CONTENT_SETTING_ALLOW));
+
+ // Create a normal provider and set a setting.
+ PrefProvider normal_provider(&prefs, false);
Peter Beverloo 2015/11/16 17:14:32 nit: may be worth annotating the boolean parameter
johnme 2015/11/26 17:31:54 Removed from patch, but I've added this elsewhere.
+ normal_provider.SetWebsiteSetting(pattern_1,
+ wildcard,
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+ std::string(),
+ value->DeepCopy());
+
+ // Non-OTR provider, Non-OTR iterator has one setting (pattern 1).
+ {
+ scoped_ptr<RuleIterator> it(normal_provider.GetRuleIterator(
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string(), false));
+ EXPECT_TRUE(it->HasNext());
+ EXPECT_EQ(pattern_1, it->Next().primary_pattern);
+ EXPECT_FALSE(it->HasNext());
+ }
+
+ // Non-OTR provider, OTR iterator has no settings.
+ {
+ scoped_ptr<RuleIterator> it(normal_provider.GetRuleIterator(
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string(), true));
+ EXPECT_FALSE(it->HasNext());
+ }
+
+ // Create an incognito provider and set a setting.
+ PrefProvider incognito_provider(&prefs, true);
Peter Beverloo 2015/11/16 17:14:32 dito
johnme 2015/11/26 17:31:54 Removed from patch, but I've added this elsewhere.
+ incognito_provider.SetWebsiteSetting(pattern_2,
+ wildcard,
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+ std::string(),
+ value->DeepCopy());
+
+ // OTR provider, non-OTR iterator has no settings.
+ {
+ scoped_ptr<RuleIterator> it(incognito_provider.GetRuleIterator(
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string(), false));
+ EXPECT_FALSE(it->HasNext());
+ }
+
+ // OTR provider, OTR iterator has one setting (pattern 2).
+ {
+ scoped_ptr<RuleIterator> it(incognito_provider.GetRuleIterator(
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string(), true));
+ EXPECT_TRUE(it->HasNext());
+ EXPECT_EQ(pattern_2, it->Next().primary_pattern);
+ EXPECT_FALSE(it->HasNext());
+ }
+
+ incognito_provider.ShutdownOnUIThread();
+ normal_provider.ShutdownOnUIThread();
+}
+
TEST_F(PrefProviderTest, ClearAllContentSettingsRules) {
syncable_prefs::TestingPrefServiceSyncable prefs;
PrefProvider::RegisterProfilePrefs(prefs.registry());

Powered by Google App Engine
This is Rietveld 408576698