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

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

Issue 542253003: Add a global on/off switch for content settings and expose a toggle on the Website Settings options… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@global-settings
Patch Set: Rebase. Created 6 years, 3 months 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/host_content_settings_map_unittest.cc
diff --git a/chrome/browser/content_settings/host_content_settings_map_unittest.cc b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
index 48c4e060660f49f14764086b9b65ca5817d4d179..e0e65d396dc2c5d56b97180cdeb9b79f7a8d44d4 100644
--- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc
+++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
@@ -1016,3 +1016,70 @@ TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) {
std::string(),
CONTENT_SETTING_DEFAULT);
}
+
+TEST_F(HostContentSettingsMapTest, OverrideAllowedWebsiteSetting) {
+ TestingProfile profile;
+ HostContentSettingsMap* host_content_settings_map =
+ profile.GetHostContentSettingsMap();
+ GURL host("http://example.com/");
+ ContentSettingsPattern pattern =
+ ContentSettingsPattern::FromString("[*.]example.com");
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_GEOLOCATION,
+ std::string(),
+ CONTENT_SETTING_ALLOW);
+
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ host_content_settings_map->GetContentSetting(
+ host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string()));
+
+ // Disabling should override an allowed exception.
+ host_content_settings_map->SetContentSettingOverride(
+ CONTENT_SETTINGS_TYPE_GEOLOCATION, false);
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ host_content_settings_map->GetContentSetting(
+ host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string()));
+
+ host_content_settings_map->SetContentSettingOverride(
+ CONTENT_SETTINGS_TYPE_GEOLOCATION, true);
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ host_content_settings_map->GetContentSetting(
+ host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string()));
+}
+
+TEST_F(HostContentSettingsMapTest, OverrideAllowedDefaultSetting) {
+ TestingProfile profile;
+ HostContentSettingsMap* host_content_settings_map =
+ profile.GetHostContentSettingsMap();
+
+ // Check setting defaults.
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ host_content_settings_map->GetDefaultContentSetting(
+ CONTENT_SETTINGS_TYPE_IMAGES, NULL));
+
+ GURL host("http://example.com/");
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ host_content_settings_map->GetContentSetting(
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
+
+ // Disabling should override an allowed default setting.
+ host_content_settings_map->SetContentSettingOverride(
+ CONTENT_SETTINGS_TYPE_IMAGES, false);
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ host_content_settings_map->GetContentSetting(
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
+
+ // Enabling shouldn't override positively.
+ host_content_settings_map->SetContentSettingOverride(
+ CONTENT_SETTINGS_TYPE_IMAGES, true);
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ host_content_settings_map->GetContentSetting(
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
+ host_content_settings_map->SetDefaultContentSetting(
+ CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK);
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ host_content_settings_map->GetContentSetting(
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
+}
« no previous file with comments | « chrome/browser/content_settings/host_content_settings_map.cc ('k') | chrome/browser/plugins/plugin_info_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698