Chromium Code Reviews| 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 b0baa0425bf6024d7d1ca7959f192a8d9a8dfac3..81896095de15df63b1e4bbcde16b8f07187249f4 100644 |
| --- a/chrome/browser/content_settings/host_content_settings_map.cc |
| +++ b/chrome/browser/content_settings/host_content_settings_map.cc |
| @@ -237,36 +237,55 @@ void HostContentSettingsMap::SetDefaultContentSetting( |
| DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); |
| DCHECK(IsSettingAllowedForType(setting, content_type)); |
| - content_settings_providers_[DEFAULT_PROVIDER]->SetContentSetting( |
| + base::Value* value = Value::CreateIntegerValue(setting); |
| + content_settings_providers_[DEFAULT_PROVIDER]->SetWebsiteSetting( |
| ContentSettingsPattern::Wildcard(), |
| ContentSettingsPattern::Wildcard(), |
| content_type, |
| std::string(), |
| - setting); |
| + value); |
| } |
| -void HostContentSettingsMap::SetContentSetting( |
| +void HostContentSettingsMap::SetWebsiteSetting( |
| const ContentSettingsPattern& primary_pattern, |
| const ContentSettingsPattern& secondary_pattern, |
| ContentSettingsType content_type, |
| const std::string& resource_identifier, |
| - ContentSetting setting) { |
| - DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); |
| - DCHECK(IsSettingAllowedForType(setting, content_type)); |
| + base::Value* value) { |
| + DCHECK(IsValueAllowedForType(value, content_type)); |
| DCHECK(content_settings::SupportsResourceIdentifier(content_type) || |
| resource_identifier.empty()); |
| for (ProviderIterator provider = content_settings_providers_.begin(); |
| provider != content_settings_providers_.end(); |
| ++provider) { |
| - provider->second->SetContentSetting( |
| + bool owned = provider->second->SetWebsiteSetting( |
|
Bernhard Bauer
2011/11/15 15:40:28
You could inline this and just do |if (provider->.
markusheintz_
2011/11/15 17:36:58
Done.
|
| primary_pattern, |
| secondary_pattern, |
| content_type, |
| resource_identifier, |
| - setting); |
| + value); |
| + if (owned) |
| + break; |
| } |
| } |
| +void HostContentSettingsMap::SetContentSetting( |
| + const ContentSettingsPattern& primary_pattern, |
| + const ContentSettingsPattern& secondary_pattern, |
| + ContentSettingsType content_type, |
| + const std::string& resource_identifier, |
| + ContentSetting setting) { |
| + DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); |
| + base::Value* value = NULL; |
| + if (setting != CONTENT_SETTING_DEFAULT) |
| + value = Value::CreateIntegerValue(setting); |
| + SetWebsiteSetting(primary_pattern, |
| + secondary_pattern, |
| + content_type, |
| + resource_identifier, |
| + value); |
| +} |
| + |
| void HostContentSettingsMap::AddExceptionForURL( |
| const GURL& primary_url, |
| const GURL& secondary_url, |
| @@ -301,6 +320,12 @@ void HostContentSettingsMap::ClearSettingsForOneType( |
| } |
| } |
| +bool HostContentSettingsMap::IsValueAllowedForType( |
| + const base::Value* value, ContentSettingsType type) { |
| + return IsSettingAllowedForType( |
| + content_settings::ValueToContentSetting(value), type); |
| +} |
| + |
| // static |
| bool HostContentSettingsMap::IsSettingAllowedForType( |
| ContentSetting setting, ContentSettingsType content_type) { |