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 fba2d9ac628830df83a307800db94810df0baab4..53ab01626e5cb0c4228cfac145ca5a40cb4ce930 100644 |
--- a/chrome/browser/content_settings/host_content_settings_map.cc |
+++ b/chrome/browser/content_settings/host_content_settings_map.cc |
@@ -83,13 +83,14 @@ bool SupportsResourceIdentifier(ContentSettingsType content_type) { |
} // namespace |
HostContentSettingsMap::HostContentSettingsMap( |
- PrefService* prefs, |
- bool incognito) : |
+ PrefService* prefs, |
+ bool incognito) : |
#ifndef NDEBUG |
used_from_thread_id_(base::PlatformThread::CurrentId()), |
#endif |
prefs_(prefs), |
- is_off_the_record_(incognito) { |
+ is_off_the_record_(incognito), |
+ override_(prefs_, is_off_the_record_) { |
content_settings::ObservableProvider* policy_provider = |
new content_settings::PolicyProvider(prefs_); |
policy_provider->AddObserver(this); |
@@ -165,6 +166,7 @@ void HostContentSettingsMap::RegisterProfilePrefs( |
content_settings::DefaultProvider::RegisterProfilePrefs(registry); |
content_settings::PrefProvider::RegisterProfilePrefs(registry); |
content_settings::PolicyProvider::RegisterProfilePrefs(registry); |
+ content_settings::OverrideProvider::RegisterProfilePrefs(registry); |
} |
ContentSetting HostContentSettingsMap::GetDefaultContentSettingFromProvider( |
@@ -410,6 +412,64 @@ base::Time HostContentSettingsMap::GetLastUsageByPattern( |
primary_pattern, secondary_pattern, content_type); |
} |
+ContentSetting HostContentSettingsMap::GetContentSettingWithoutOverride( |
+ const GURL& primary_url, |
+ const GURL& secondary_url, |
+ ContentSettingsType content_type, |
+ const std::string& resource_identifier) { |
+ scoped_ptr<base::Value> value(GetWebsiteSettingWithoutOverride( |
+ primary_url, secondary_url, content_type, resource_identifier, NULL)); |
+ return content_settings::ValueToContentSetting(value.get()); |
+} |
+ |
+base::Value* HostContentSettingsMap::GetWebsiteSettingWithoutOverride( |
+ const GURL& primary_url, |
+ const GURL& secondary_url, |
+ ContentSettingsType content_type, |
+ const std::string& resource_identifier, |
+ content_settings::SettingInfo* info) const { |
+ ContentSettingsPattern* primary_pattern = NULL; |
+ ContentSettingsPattern* secondary_pattern = NULL; |
+ if (info) { |
+ primary_pattern = &info->primary_pattern; |
+ secondary_pattern = &info->secondary_pattern; |
+ } |
+ |
+ // 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::GetContentSettingValueAndPatterns( |
+ provider->second, primary_url, secondary_url, content_type, |
+ resource_identifier, is_off_the_record_, |
+ primary_pattern, secondary_pattern); |
+ if (value) { |
+ if (info) |
+ info->source = kProviderSourceMap[provider->first]; |
+ return value; |
+ } |
+ } |
+ |
+ if (info) { |
+ info->source = content_settings::SETTING_SOURCE_NONE; |
+ info->primary_pattern = ContentSettingsPattern(); |
+ info->secondary_pattern = ContentSettingsPattern(); |
+ } |
+ return NULL; |
+} |
+ |
+void HostContentSettingsMap::SetContentSettingOverride( |
+ ContentSettingsType content_type, |
+ bool is_enabled) { |
+ override_.SetContentSetting(content_type, is_enabled); |
+} |
+ |
+bool HostContentSettingsMap::GetContentSettingOverride( |
+ ContentSettingsType content_type) { |
+ return override_.IsEnabled(content_type); |
+} |
+ |
void HostContentSettingsMap::AddObserver(content_settings::Observer* observer) { |
observers_.AddObserver(observer); |
} |
@@ -715,41 +775,23 @@ base::Value* HostContentSettingsMap::GetWebsiteSetting( |
return new base::FundamentalValue(CONTENT_SETTING_ALLOW); |
} |
- ContentSettingsPattern* primary_pattern = NULL; |
- ContentSettingsPattern* secondary_pattern = NULL; |
- if (info) { |
- primary_pattern = &info->primary_pattern; |
- secondary_pattern = &info->secondary_pattern; |
- } |
- |
- // 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::GetContentSettingValueAndPatterns( |
- provider->second, primary_url, secondary_url, content_type, |
- resource_identifier, is_off_the_record_, |
- primary_pattern, secondary_pattern); |
- if (value) { |
- if (info) |
- info->source = kProviderSourceMap[provider->first]; |
- return value; |
+ // Check if the content setting is globally disabled. |
+ if (!override_.IsEnabled(content_type)) { |
+ if (info) { |
+ info->source = content_settings::SETTING_SOURCE_USER; |
+ info->primary_pattern = ContentSettingsPattern::Wildcard(); |
+ info->secondary_pattern = ContentSettingsPattern::Wildcard(); |
} |
+ return new base::FundamentalValue(CONTENT_SETTING_BLOCK); |
} |
- if (info) { |
- info->source = content_settings::SETTING_SOURCE_NONE; |
- info->primary_pattern = ContentSettingsPattern(); |
- info->secondary_pattern = ContentSettingsPattern(); |
- } |
- return NULL; |
+ return GetWebsiteSettingWithoutOverride( |
+ primary_url, secondary_url, content_type, resource_identifier, info); |
} |
// static |
HostContentSettingsMap::ProviderType |
- HostContentSettingsMap::GetProviderTypeFromSource( |
- const std::string& source) { |
+HostContentSettingsMap::GetProviderTypeFromSource(const std::string& source) { |
for (size_t i = 0; i < arraysize(kProviderNames); ++i) { |
if (source == kProviderNames[i]) |
return static_cast<ProviderType>(i); |