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 16ad3a22d66fa5b1d1767958a305407092dec33f..3890cf0ca343468934c6477a10efcbaed92a28b3 100644 |
| --- a/chrome/browser/content_settings/host_content_settings_map.cc |
| +++ b/chrome/browser/content_settings/host_content_settings_map.cc |
| @@ -160,6 +160,7 @@ void HostContentSettingsMap::RegisterUserPrefs(PrefService* prefs) { |
| ContentSetting HostContentSettingsMap::GetDefaultContentSetting( |
| ContentSettingsType content_type) const { |
| + DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); |
| ContentSetting setting = CONTENT_SETTING_DEFAULT; |
| for (ConstDefaultProviderIterator provider = |
| default_content_settings_providers_.begin(); |
| @@ -178,8 +179,11 @@ ContentSetting HostContentSettingsMap::GetDefaultContentSetting( |
| ContentSettings HostContentSettingsMap::GetDefaultContentSettings() const { |
| ContentSettings output(CONTENT_SETTING_DEFAULT); |
| - for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) |
| + for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| + if (i == CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE) |
| + continue; |
|
wtc
2011/09/02 18:53:22
It may be a good idea to explain why we skip
CONTE
markusheintz_
2011/09/02 19:39:12
Done.
|
| output.settings[i] = GetDefaultContentSetting(ContentSettingsType(i)); |
| + } |
| return output; |
| } |
| @@ -231,6 +235,37 @@ ContentSetting HostContentSettingsMap::GetContentSetting( |
| primary_url, secondary_url, content_type, resource_identifier); |
| } |
| +Value* HostContentSettingsMap::GetContentSettingValue( |
| + const GURL& primary_url, |
| + const GURL& secondary_url, |
| + ContentSettingsType content_type, |
| + const std::string& resource_identifier) const { |
| + // 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. So iterate through the list of providers and |
| + // break when the first non |NULL| value is returned. |
|
wtc
2011/09/02 18:53:22
Nit: thanks for the comments! You can omit the la
markusheintz_
2011/09/02 19:39:12
Done.
|
| + for (ConstProviderIterator provider = content_settings_providers_.begin(); |
| + provider != content_settings_providers_.end(); |
| + ++provider) { |
| + Value* value = (*provider)->GetContentSettingValue( |
| + primary_url, secondary_url, content_type, resource_identifier); |
| + if (value) |
| + return value; |
| + } |
| + |
| + // If no specific settings were found for the |primary_url|, |secondary_url| |
| + // pair, then the default value for the given |content_type| should be |
| + // returned. For CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE the default is |
| + // 'no filter available'. That's why we return |NULL| for this content type. |
| + if (content_type == CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE) |
| + return NULL; |
| + return Value::CreateIntegerValue(GetDefaultContentSetting(content_type)); |
| +} |
| + |
| ContentSetting HostContentSettingsMap::GetContentSettingInternal( |
| const GURL& primary_url, |
| const GURL& secondary_url, |
| @@ -277,7 +312,8 @@ ContentSettings HostContentSettingsMap::GetContentSettings( |
| // A managed default content setting has the highest priority and hence |
| // will overwrite any previously set value. |
| if (output.settings[j] == CONTENT_SETTING_DEFAULT && |
| - j != CONTENT_SETTINGS_TYPE_PLUGINS) { |
| + j != CONTENT_SETTINGS_TYPE_PLUGINS && |
| + j != CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE) { |
| output.settings[j] = GetDefaultContentSetting(ContentSettingsType(j)); |
| } |
| } |
| @@ -289,6 +325,8 @@ ContentSettings HostContentSettingsMap::GetNonDefaultContentSettings( |
| const GURL& secondary_url) const { |
| ContentSettings output(CONTENT_SETTING_DEFAULT); |
| for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j) { |
| + if (j == CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE) |
| + continue; |
| output.settings[j] = GetNonDefaultContentSetting( |
| primary_url, |
| secondary_url, |
| @@ -341,6 +379,7 @@ void HostContentSettingsMap::GetSettingsForOneType( |
| void HostContentSettingsMap::SetDefaultContentSetting( |
| ContentSettingsType content_type, |
| ContentSetting setting) { |
| + DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); |
| DCHECK(IsSettingAllowedForType(setting, content_type)); |
| for (DefaultProviderIterator provider = |
| default_content_settings_providers_.begin(); |
| @@ -355,6 +394,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(IsSettingAllowedForType(setting, content_type)); |
| DCHECK_NE(content_settings::RequiresResourceIdentifier(content_type), |
| resource_identifier.empty()); |