| 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 5722d64546fc12797a01ed74db848e80672c451c..998af1a2c9231d1bc9481ee77b7ae3326c8d71de 100644
|
| --- a/chrome/browser/content_settings/host_content_settings_map.cc
|
| +++ b/chrome/browser/content_settings/host_content_settings_map.cc
|
| @@ -294,6 +294,7 @@ void HostContentSettingsMap::GetSettingsForOneType(
|
| void HostContentSettingsMap::SetDefaultContentSetting(
|
| ContentSettingsType content_type,
|
| ContentSetting setting) {
|
| + DCHECK(IsSettingAllowedForType(content_type, setting));
|
| for (DefaultProviderIterator provider =
|
| default_content_settings_providers_.begin();
|
| provider != default_content_settings_providers_.end(); ++provider) {
|
| @@ -306,6 +307,7 @@ void HostContentSettingsMap::SetContentSetting(
|
| ContentSettingsType content_type,
|
| const std::string& resource_identifier,
|
| ContentSetting setting) {
|
| + DCHECK(IsSettingAllowedForType(content_type, setting));
|
| for (ProviderIterator provider = content_settings_providers_.begin();
|
| provider != content_settings_providers_.end();
|
| ++provider) {
|
| @@ -340,6 +342,34 @@ void HostContentSettingsMap::ClearSettingsForOneType(
|
| }
|
| }
|
|
|
| +// static
|
| +bool HostContentSettingsMap::IsSettingAllowedForType(
|
| + ContentSettingsType content_type, ContentSetting setting) {
|
| + // 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));
|
|
|
|
|