Index: chrome/browser/content_settings/host_content_settings_map.cc |
diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc |
index b226a6e8aa374350c0ea6e95b822fb6aa5a4b0e4..eff33f65288c443b8ee10ae1d5fdcc98d2b8d274 100644 |
--- a/chrome/browser/content_settings/host_content_settings_map.cc |
+++ b/chrome/browser/content_settings/host_content_settings_map.cc |
@@ -293,6 +293,7 @@ void HostContentSettingsMap::GetSettingsForOneType( |
void HostContentSettingsMap::SetDefaultContentSetting( |
ContentSettingsType content_type, |
ContentSetting setting) { |
+ DCHECK(IsSettingAllowedForType(setting, content_type)); |
for (DefaultProviderIterator provider = |
default_content_settings_providers_.begin(); |
provider != default_content_settings_providers_.end(); ++provider) { |
@@ -305,6 +306,7 @@ void HostContentSettingsMap::SetContentSetting( |
ContentSettingsType content_type, |
const std::string& resource_identifier, |
ContentSetting setting) { |
+ DCHECK(IsSettingAllowedForType(setting, content_type)); |
for (ProviderIterator provider = content_settings_providers_.begin(); |
provider != content_settings_providers_.end(); |
++provider) { |
@@ -339,6 +341,34 @@ void HostContentSettingsMap::ClearSettingsForOneType( |
} |
} |
+// static |
+bool HostContentSettingsMap::IsSettingAllowedForType( |
+ ContentSetting setting, ContentSettingsType content_type) { |
+ // Prerendering doesn't have settings. |
+ if (content_type == CONTENT_SETTINGS_TYPE_PRERENDER) |
+ return false; |
+ |
+ // For all other types, DEFAULT, ALLOW and BLOCK are always allowed. |
+ if (setting == CONTENT_SETTING_DEFAULT || |
+ setting == CONTENT_SETTING_ALLOW || |
+ setting == CONTENT_SETTING_BLOCK) { |
+ return true; |
+ } |
+ switch (content_type) { |
+ case CONTENT_SETTINGS_TYPE_COOKIES: |
+ return (setting == CONTENT_SETTING_SESSION_ONLY); |
+ case CONTENT_SETTINGS_TYPE_PLUGINS: |
+ return (setting == CONTENT_SETTING_ASK && |
+ CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableClickToPlay)); |
+ case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
+ case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
+ return (setting == CONTENT_SETTING_ASK); |
+ default: |
+ return false; |
+ } |
+} |
+ |
void HostContentSettingsMap::SetBlockThirdPartyCookies(bool block) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |