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 bd92ce5c1ecf3f97b3ed78fd0c527db9c2f6cda3..968dc820793bc0fdceb7ba056cdfc69cc1c0e235 100644 |
| --- a/chrome/browser/content_settings/host_content_settings_map.cc |
| +++ b/chrome/browser/content_settings/host_content_settings_map.cc |
| @@ -203,26 +203,23 @@ ContentSetting HostContentSettingsMap::GetCookieContentSetting( |
| return CONTENT_SETTING_ALLOW; |
| // First get any host-specific settings. |
| - ContentSetting setting = CONTENT_SETTING_DEFAULT; |
| + scoped_ptr<base::Value> setting; |
|
marja
2011/10/19 07:44:31
Would it make sense to call this "value" instead o
Bernhard Bauer
2011/10/19 09:53:50
Done.
|
| for (ConstProviderIterator provider = content_settings_providers_.begin(); |
| provider != content_settings_providers_.end(); |
| ++provider) { |
| if (provider->first == DEFAULT_PROVIDER) |
| continue; |
| - setting = content_settings::GetContentSetting(provider->second, |
| - url, |
| - first_party_url, |
| - CONTENT_SETTINGS_TYPE_COOKIES, |
| - std::string(), |
| - is_off_the_record_); |
| - if (setting != CONTENT_SETTING_DEFAULT) |
| + setting.reset(content_settings::GetContentSettingValueAndPatterns( |
| + provider->second, url, first_party_url, CONTENT_SETTINGS_TYPE_COOKIES, |
| + std::string(), is_off_the_record_, NULL, NULL)); |
| + if (setting.get()) |
| break; |
| } |
| // If no explicit exception has been made and third-party cookies are blocked |
| // by default, apply that rule. |
| - if (setting == CONTENT_SETTING_DEFAULT && BlockThirdPartyCookies()) { |
| + if (!setting.get() && BlockThirdPartyCookies()) { |
| bool strict = CommandLine::ForCurrentProcess()->HasSwitch( |
| switches::kBlockReadingThirdPartyCookies); |
| net::StaticCookiePolicy policy(strict ? |
| @@ -235,14 +232,14 @@ ContentSetting HostContentSettingsMap::GetCookieContentSetting( |
| rv = policy.CanGetCookies(url, first_party_url); |
| DCHECK_NE(net::ERR_IO_PENDING, rv); |
| if (rv != net::OK) |
| - setting = CONTENT_SETTING_BLOCK; |
| + return CONTENT_SETTING_BLOCK; |
| } |
| // If no other policy has changed the setting, use the default. |
| - if (setting == CONTENT_SETTING_DEFAULT) |
| - setting = GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES); |
| + if (setting.get()) |
| + return content_settings::ValueToContentSetting(setting.get()); |
| - return setting; |
| + return GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES); |
| } |
| ContentSetting HostContentSettingsMap::GetContentSetting( |
| @@ -250,58 +247,46 @@ ContentSetting HostContentSettingsMap::GetContentSetting( |
| const GURL& secondary_url, |
| ContentSettingsType content_type, |
| const std::string& resource_identifier) const { |
| - DCHECK_NE(CONTENT_SETTINGS_TYPE_COOKIES, content_type); |
| - DCHECK(content_settings::SupportsResourceIdentifier(content_type) || |
| - resource_identifier.empty()); |
| - |
| - if (ShouldAllowAllContent(secondary_url, content_type)) |
| - return CONTENT_SETTING_ALLOW; |
| - |
| - // Iterate through the list of providers and return the first non-NULL value |
| - // that matches |primary_url| and |secondary_url|. |
| - for (ConstProviderIterator provider = content_settings_providers_.begin(); |
| - provider != content_settings_providers_.end(); |
| - ++provider) { |
| - ContentSetting provided_setting = content_settings::GetContentSetting( |
| - provider->second, primary_url, secondary_url, content_type, |
| - resource_identifier, is_off_the_record_); |
| - if (provided_setting != CONTENT_SETTING_DEFAULT) |
| - return provided_setting; |
| - } |
| - return CONTENT_SETTING_DEFAULT; |
| + scoped_ptr<base::Value> value(GetContentSettingValue( |
| + primary_url, secondary_url, content_type, resource_identifier, |
| + NULL, NULL)); |
| + DCHECK(value.get()); |
| + return content_settings::ValueToContentSetting(value.get()); |
| } |
| -Value* HostContentSettingsMap::GetContentSettingValue( |
| +base::Value* HostContentSettingsMap::GetContentSettingValue( |
| const GURL& primary_url, |
| const GURL& secondary_url, |
| ContentSettingsType content_type, |
| - const std::string& resource_identifier) const { |
| + const std::string& resource_identifier, |
| + ContentSettingsPattern* primary_pattern, |
| + ContentSettingsPattern* secondary_pattern) const { |
| + DCHECK_NE(CONTENT_SETTINGS_TYPE_COOKIES, content_type); |
| + DCHECK(content_settings::SupportsResourceIdentifier(content_type) || |
| + resource_identifier.empty()); |
| + |
| // Check if the scheme of the requesting url is whitelisted. |
| if (ShouldAllowAllContent(secondary_url, content_type)) |
| return Value::CreateIntegerValue(CONTENT_SETTING_ALLOW); |
| - // First check if there are specific settings for the |primary_url| and |
| - // |secondary_url|. The list of |content_settings_providers_| is ordered |
| - // according to their priority. |
| + // The list of |content_settings_providers_| is ordered according to their |
| + // precedence. |
| for (ConstProviderIterator provider = content_settings_providers_.begin(); |
| provider != content_settings_providers_.end(); |
| ++provider) { |
| - base::Value* value = content_settings::GetContentSettingValue( |
| + base::Value* value = content_settings::GetContentSettingValueAndPatterns( |
| provider->second, primary_url, secondary_url, content_type, |
| - resource_identifier, is_off_the_record_); |
| + resource_identifier, is_off_the_record_, |
| + primary_pattern, secondary_pattern); |
| if (value) |
| return value; |
| } |
| - |
| - // For simple content types, the DefaultProvider should always return |
|
marja
2011/10/19 07:44:31
Why was this DCHECK removed, isn't it valid still?
Bernhard Bauer
2011/10/19 09:53:50
When looking up content settings with a non-empty
marja
2011/10/19 10:23:16
Ok.
|
| - // a setting. |
| - DCHECK(ContentTypeHasCompoundValue(content_type)); |
| return NULL; |
| } |
| ContentSettings HostContentSettingsMap::GetContentSettings( |
| - const GURL& primary_url, |
| - const GURL& secondary_url) const { |
| + const GURL& primary_url, |
| + const GURL& secondary_url) const { |
| ContentSettings output; |
| // If we require a resource identifier, set the content settings to default, |
| // otherwise make the defaults explicit. Values for content type |