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)) |