Chromium Code Reviews| 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. |