summaryrefslogtreecommitdiffstats
path: root/chrome/browser/content_settings/host_content_settings_map.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/content_settings/host_content_settings_map.cc')
-rw-r--r--chrome/browser/content_settings/host_content_settings_map.cc38
1 files changed, 21 insertions, 17 deletions
diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc
index 82815fc..ddd7eb7 100644
--- a/chrome/browser/content_settings/host_content_settings_map.cc
+++ b/chrome/browser/content_settings/host_content_settings_map.cc
@@ -68,17 +68,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 +125,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 +170,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 +180,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 +210,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 +231,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 +253,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 +273,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 +419,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.