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

Unified Diff: chrome/renderer/content_settings_observer.cc

Issue 7831075: Delegating the "are images allowed" decision to renderer. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Transmit image settings to the renderer. Draft. Created 9 years, 3 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/renderer/content_settings_observer.cc
diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc
index c89482e6d0bc49b65c2ffc75a21699a8781b12ab..eb8cc1177981041fb835cea2772511ae594b932a 100644
--- a/chrome/renderer/content_settings_observer.cc
+++ b/chrome/renderer/content_settings_observer.cc
@@ -52,6 +52,7 @@ static bool IsWhitelistedForContentSettings(WebFrame* frame) {
} // namespace
ContentSettings ContentSettingsObserver::default_settings_;
+ContentSettingRules ContentSettingsObserver::image_setting_rules_;
ContentSettingsObserver::ContentSettingsObserver(RenderView* render_view)
: RenderViewObserver(render_view),
@@ -73,6 +74,12 @@ void ContentSettingsObserver::SetDefaultContentSettings(
default_settings_ = settings;
}
+// static
+void ContentSettingsObserver::SetImageSettingRules(
+ const ContentSettingRules& rules) {
+ image_setting_rules_ = rules;
+}
+
ContentSetting ContentSettingsObserver::GetContentSetting(
ContentSettingsType type) {
if (type == CONTENT_SETTINGS_TYPE_PLUGINS &&
@@ -196,9 +203,20 @@ bool ContentSettingsObserver::AllowFileSystem(WebFrame* frame) {
bool ContentSettingsObserver::AllowImages(WebFrame* frame,
bool enabled_per_settings) {
- if (enabled_per_settings &&
- AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES)) {
- return true;
+ if (frame->document().securityOrigin().isEmpty() ||
+ frame->top()->document().securityOrigin().isEmpty())
+ return false; // Uninitialized document.
Bernhard Bauer 2011/09/13 17:38:11 Does this change the behavior?
marja 2011/09/15 12:02:00 I moved the IsWhiteListedForContentSettings up, th
+
+ if (enabled_per_settings) {
+ ContentSettingRules::const_iterator it;
+ for (it = image_setting_rules_.begin();
+ it != image_setting_rules_.end(); ++it) {
+ if (it->a.Matches(GURL(frame->document().securityOrigin().toString())) &&
+ it->b.Matches(
+ GURL(frame->top()->document().securityOrigin().toString()))) {
+ return (it->c != CONTENT_SETTING_BLOCK);
Bernhard Bauer 2011/09/13 17:38:11 This simply returns |false| when the setting is BL
marja 2011/09/15 12:02:00 Ahh, true! I added the DidBlockContentType here an
+ }
+ }
}
if (IsWhitelistedForContentSettings(frame))
« chrome/renderer/content_settings_observer.h ('K') | « chrome/renderer/content_settings_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698