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

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: Code review comments. 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..20b558917eec8135c39c2cd3a8daee6c2ae4ba85 100644
--- a/chrome/renderer/content_settings_observer.cc
+++ b/chrome/renderer/content_settings_observer.cc
@@ -53,9 +53,11 @@ static bool IsWhitelistedForContentSettings(WebFrame* frame) {
ContentSettings ContentSettingsObserver::default_settings_;
-ContentSettingsObserver::ContentSettingsObserver(RenderView* render_view)
+ContentSettingsObserver::ContentSettingsObserver(
+ RenderView* render_view, ContentSettingRules* image_setting_rules)
: RenderViewObserver(render_view),
RenderViewObserverTracker<ContentSettingsObserver>(render_view),
+ image_setting_rules_(image_setting_rules),
plugins_temporarily_allowed_(false) {
ClearBlockedContentSettings();
}
@@ -196,13 +198,29 @@ bool ContentSettingsObserver::AllowFileSystem(WebFrame* frame) {
bool ContentSettingsObserver::AllowImages(WebFrame* frame,
bool enabled_per_settings) {
- if (enabled_per_settings &&
- AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES)) {
+ if (IsWhitelistedForContentSettings(frame))
return true;
+
+ if (frame->document().securityOrigin().isEmpty() ||
+ frame->top()->document().securityOrigin().isEmpty()) {
+ DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES, std::string());
+ return false; // Uninitialized document.
}
- if (IsWhitelistedForContentSettings(frame))
- return true;
+ 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()))) {
+ bool allow = (it->c != CONTENT_SETTING_BLOCK);
Bernhard Bauer 2011/09/15 12:52:19 You already have a call to DidBlockContentType bel
marja 2011/09/15 16:00:03 Done.
+ if (!allow)
+ DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES, std::string());
+ return allow;
+ }
+ }
+ }
DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES, std::string());
return false; // Other protocols fall through here.
« 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