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

Unified Diff: chrome/browser/host_content_settings_map.cc

Issue 4643007: Move click-to-play to about:flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 10 years, 1 month 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/host_content_settings_map.cc
diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc
index a7dda7e68810ccbfcb0da4c38b1f4310214a2220..2f90bfdca22a5b664e79933bf7efff1e9450bb22 100644
--- a/chrome/browser/host_content_settings_map.cc
+++ b/chrome/browser/host_content_settings_map.cc
@@ -100,6 +100,20 @@ static bool ShouldAllowAllContent(const GURL& url) {
url.SchemeIs(chrome::kGearsScheme) ||
url.SchemeIs(chrome::kUserScriptScheme);
}
+
+// Map ASK for the plugins content type to BLOCK if click-to-play is
+// not enabled.
+ContentSetting ClickToPlayFixup(ContentSettingsType content_type,
+ ContentSetting setting) {
+ if (setting == CONTENT_SETTING_ASK &&
+ content_type == CONTENT_SETTINGS_TYPE_PLUGINS &&
+ !CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableClickToPlay)) {
+ return CONTENT_SETTING_BLOCK;
+ }
+ return setting;
+}
+
} // namespace
@@ -432,6 +446,10 @@ void HostContentSettingsMap::SetDefaultContentSetting(
ContentSetting setting) {
DCHECK(kTypeNames[content_type] != NULL); // Don't call this for Geolocation.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(content_type != CONTENT_SETTINGS_TYPE_PLUGINS ||
+ setting != CONTENT_SETTING_ASK ||
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableClickToPlay));
PrefService* prefs = profile_->GetPrefs();
// The default settings may not be directly modified for OTR sessions.
@@ -474,6 +492,10 @@ void HostContentSettingsMap::SetContentSetting(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_NE(RequiresResourceIdentifier(content_type),
resource_identifier.empty());
+ DCHECK(content_type != CONTENT_SETTINGS_TYPE_PLUGINS ||
+ setting != CONTENT_SETTING_ASK ||
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableClickToPlay));
const Pattern pattern(original_pattern.CanonicalizePattern());
@@ -796,6 +818,10 @@ void HostContentSettingsMap::GetSettingsFromDictionary(
if (settings->settings[CONTENT_SETTINGS_TYPE_COOKIES] ==
CONTENT_SETTING_ASK)
settings->settings[CONTENT_SETTINGS_TYPE_COOKIES] = CONTENT_SETTING_BLOCK;
+
+ settings->settings[CONTENT_SETTINGS_TYPE_PLUGINS] =
+ ClickToPlayFixup(CONTENT_SETTINGS_TYPE_PLUGINS,
+ settings->settings[CONTENT_SETTINGS_TYPE_PLUGINS]);
}
void HostContentSettingsMap::GetResourceSettingsFromDictionary(
@@ -820,7 +846,8 @@ void HostContentSettingsMap::GetResourceSettingsFromDictionary(
DCHECK(found);
(*settings)[ContentSettingsTypeResourceIdentifierPair(
ContentSettingsType(type), resource_identifier)] =
- ContentSetting(setting);
+ ClickToPlayFixup(ContentSettingsType(type),
+ ContentSetting(setting));
}
break;
« no previous file with comments | « chrome/browser/gtk/options/content_filter_page_gtk.cc ('k') | chrome/browser/host_content_settings_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698