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 82815fc5d988b35d64c32229b33d5e704a9fdafe..a2706b58eed57e3dba620661e8ff32f6577421ac 100644 |
| --- a/chrome/browser/content_settings/host_content_settings_map.cc |
| +++ b/chrome/browser/content_settings/host_content_settings_map.cc |
| @@ -19,7 +19,6 @@ |
| #include "chrome/browser/content_settings/content_settings_pref_provider.h" |
| #include "chrome/browser/content_settings/content_settings_provider.h" |
| #include "chrome/browser/content_settings/content_settings_rule.h" |
| -#include "chrome/browser/content_settings/content_settings_utils.h" |
|
marja
2011/12/06 09:47:12
I don't think you should remove this include, this
markusheintz_
2011/12/06 16:29:59
Done.
|
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/prefs/pref_service.h" |
| #include "chrome/common/chrome_notification_types.h" |
| @@ -68,17 +67,10 @@ bool ContentTypeHasCompoundValue(ContentSettingsType type) { |
| return type == CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE; |
| } |
| -ContentSetting GetDefaultSetting( |
| - content_settings::RuleIterator* rule_iterator) { |
| - ContentSettingsPattern wildcard = ContentSettingsPattern::Wildcard(); |
| - while (rule_iterator->HasNext()) { |
| - content_settings::Rule rule = rule_iterator->Next(); |
| - if (rule.primary_pattern == wildcard && |
| - rule.secondary_pattern == wildcard) { |
| - return content_settings::ValueToContentSetting(rule.value.get()); |
| - } |
| - } |
| - return CONTENT_SETTING_DEFAULT; |
| +// Returns true if the |content_type| supports a resource identifier. |
| +// Resource identifiers are supported (but not required) for plug-ins. |
| +bool SupportsResourceIdentifier(ContentSettingsType content_type) { |
| + return content_type == CONTENT_SETTINGS_TYPE_PLUGINS; |
| } |
| } // namespace |
| @@ -132,7 +124,16 @@ ContentSetting HostContentSettingsMap::GetDefaultContentSettingFromProvider( |
| content_settings::ProviderInterface* provider) const { |
| scoped_ptr<content_settings::RuleIterator> rule_iterator( |
| provider->GetRuleIterator(content_type, "", false)); |
| - return GetDefaultSetting(rule_iterator.get()); |
| + |
| + ContentSettingsPattern wildcard = ContentSettingsPattern::Wildcard(); |
| + while (rule_iterator->HasNext()) { |
| + content_settings::Rule rule = rule_iterator->Next(); |
| + if (rule.primary_pattern == wildcard && |
| + rule.secondary_pattern == wildcard) { |
| + return content_settings::ValueToContentSetting(rule.value.get()); |
| + } |
| + } |
| + return CONTENT_SETTING_DEFAULT; |
| } |
| ContentSetting HostContentSettingsMap::GetDefaultContentSetting( |
| @@ -168,6 +169,7 @@ ContentSetting HostContentSettingsMap::GetContentSetting( |
| const GURL& secondary_url, |
| ContentSettingsType content_type, |
| const std::string& resource_identifier) const { |
| + DCHECK(!ContentTypeHasCompoundValue(content_type)); |
| scoped_ptr<base::Value> value(GetWebsiteSetting( |
| primary_url, secondary_url, content_type, resource_identifier, NULL)); |
| return content_settings::ValueToContentSetting(value.get()); |
| @@ -177,7 +179,7 @@ void HostContentSettingsMap::GetSettingsForOneType( |
| ContentSettingsType content_type, |
| const std::string& resource_identifier, |
| ContentSettingsForOneType* settings) const { |
| - DCHECK(content_settings::SupportsResourceIdentifier(content_type) || |
| + DCHECK(SupportsResourceIdentifier(content_type) || |
| resource_identifier.empty()); |
| DCHECK(settings); |
| @@ -207,7 +209,7 @@ void HostContentSettingsMap::GetSettingsForOneType( |
| void HostContentSettingsMap::SetDefaultContentSetting( |
| ContentSettingsType content_type, |
| ContentSetting setting) { |
| - DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); |
| + DCHECK(!ContentTypeHasCompoundValue(content_type)); |
| DCHECK(IsSettingAllowedForType(setting, content_type)); |
| base::Value* value = NULL; |
| @@ -228,7 +230,7 @@ void HostContentSettingsMap::SetWebsiteSetting( |
| const std::string& resource_identifier, |
| base::Value* value) { |
| DCHECK(IsValueAllowedForType(value, content_type)); |
| - DCHECK(content_settings::SupportsResourceIdentifier(content_type) || |
| + DCHECK(SupportsResourceIdentifier(content_type) || |
| resource_identifier.empty()); |
| for (ProviderIterator provider = content_settings_providers_.begin(); |
| provider != content_settings_providers_.end(); |
| @@ -250,7 +252,7 @@ void HostContentSettingsMap::SetContentSetting( |
| ContentSettingsType content_type, |
| const std::string& resource_identifier, |
| ContentSetting setting) { |
| - DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); |
| + DCHECK(!ContentTypeHasCompoundValue(content_type)); |
| base::Value* value = NULL; |
| if (setting != CONTENT_SETTING_DEFAULT) |
| value = Value::CreateIntegerValue(setting); |
| @@ -270,6 +272,7 @@ void HostContentSettingsMap::AddExceptionForURL( |
| // TODO(markusheintz): Until the UI supports pattern pairs, both urls must |
| // match. |
| DCHECK(primary_url == secondary_url); |
| + DCHECK(!ContentTypeHasCompoundValue(content_type)); |
| // Make sure there is no entry that would override the pattern we are about |
| // to insert for exactly this URL. |
| @@ -415,7 +418,7 @@ base::Value* HostContentSettingsMap::GetWebsiteSetting( |
| ContentSettingsType content_type, |
| const std::string& resource_identifier, |
| content_settings::SettingInfo* info) const { |
| - DCHECK(content_settings::SupportsResourceIdentifier(content_type) || |
| + DCHECK(SupportsResourceIdentifier(content_type) || |
| resource_identifier.empty()); |
| // Check if the scheme of the requesting url is whitelisted. |