Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1499)

Unified Diff: chrome/browser/content_settings/host_content_settings_map.cc

Issue 7029031: Content settings extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync & review Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 b226a6e8aa374350c0ea6e95b822fb6aa5a4b0e4..eff33f65288c443b8ee10ae1d5fdcc98d2b8d274 100644
--- a/chrome/browser/content_settings/host_content_settings_map.cc
+++ b/chrome/browser/content_settings/host_content_settings_map.cc
@@ -293,6 +293,7 @@ void HostContentSettingsMap::GetSettingsForOneType(
void HostContentSettingsMap::SetDefaultContentSetting(
ContentSettingsType content_type,
ContentSetting setting) {
+ DCHECK(IsSettingAllowedForType(setting, content_type));
for (DefaultProviderIterator provider =
default_content_settings_providers_.begin();
provider != default_content_settings_providers_.end(); ++provider) {
@@ -305,6 +306,7 @@ void HostContentSettingsMap::SetContentSetting(
ContentSettingsType content_type,
const std::string& resource_identifier,
ContentSetting setting) {
+ DCHECK(IsSettingAllowedForType(setting, content_type));
for (ProviderIterator provider = content_settings_providers_.begin();
provider != content_settings_providers_.end();
++provider) {
@@ -339,6 +341,34 @@ void HostContentSettingsMap::ClearSettingsForOneType(
}
}
+// static
+bool HostContentSettingsMap::IsSettingAllowedForType(
+ ContentSetting setting, ContentSettingsType content_type) {
+ // Prerendering doesn't have settings.
+ if (content_type == CONTENT_SETTINGS_TYPE_PRERENDER)
+ return false;
+
+ // For all other types, DEFAULT, ALLOW and BLOCK are always allowed.
+ if (setting == CONTENT_SETTING_DEFAULT ||
+ setting == CONTENT_SETTING_ALLOW ||
+ setting == CONTENT_SETTING_BLOCK) {
+ return true;
+ }
+ switch (content_type) {
+ case CONTENT_SETTINGS_TYPE_COOKIES:
+ return (setting == CONTENT_SETTING_SESSION_ONLY);
+ case CONTENT_SETTINGS_TYPE_PLUGINS:
+ return (setting == CONTENT_SETTING_ASK &&
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableClickToPlay));
+ case CONTENT_SETTINGS_TYPE_GEOLOCATION:
+ case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
+ return (setting == CONTENT_SETTING_ASK);
+ default:
+ return false;
+ }
+}
+
void HostContentSettingsMap::SetBlockThirdPartyCookies(bool block) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));

Powered by Google App Engine
This is Rietveld 408576698