| Index: chrome/renderer/content_settings_observer.cc
|
| diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc
|
| index a8d0e241d07c7fc8f64fbf02456103f877951732..b9fc58cb1a301869e3b7f104e6567fe7a4ce676c 100644
|
| --- a/chrome/renderer/content_settings_observer.cc
|
| +++ b/chrome/renderer/content_settings_observer.cc
|
| @@ -55,9 +55,11 @@ static bool IsWhitelistedForContentSettings(WebFrame* frame) {
|
| ContentSettings ContentSettingsObserver::default_settings_;
|
|
|
| ContentSettingsObserver::ContentSettingsObserver(
|
| - content::RenderView* render_view)
|
| + content::RenderView* render_view,
|
| + const ContentSettingsForOneType* image_setting_rules)
|
| : content::RenderViewObserver(render_view),
|
| content::RenderViewObserverTracker<ContentSettingsObserver>(render_view),
|
| + image_setting_rules_(image_setting_rules),
|
| plugins_temporarily_allowed_(false) {
|
| ClearBlockedContentSettings();
|
| }
|
| @@ -120,7 +122,7 @@ void ContentSettingsObserver::DidCommitProvisionalLoad(
|
| NavigationState* state = NavigationState::FromDataSource(frame->dataSource());
|
| if (!state->was_within_same_page()) {
|
| // Clear "block" flags for the new page. This needs to happen before any of
|
| - // allowScripts(), allowImages(), allowPlugins() is called for the new page
|
| + // allowScripts(), allowImage(), allowPlugins() is called for the new page
|
| // so that these functions can correctly detect that a piece of content
|
| // flipped from "not blocked" to "blocked".
|
| ClearBlockedContentSettings();
|
| @@ -200,16 +202,30 @@ bool ContentSettingsObserver::AllowFileSystem(WebFrame* frame) {
|
| bool ContentSettingsObserver::AllowImage(WebFrame* frame,
|
| bool enabled_per_settings,
|
| const WebURL& image_url) {
|
| - if (enabled_per_settings &&
|
| - AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES)) {
|
| - return true;
|
| - }
|
| -
|
| + DCHECK(image_setting_rules_);
|
| if (IsWhitelistedForContentSettings(frame))
|
| return true;
|
|
|
| - DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES, std::string());
|
| - return false; // Other protocols fall through here.
|
| + bool allow = false;
|
| + GURL top_url(frame->top()->document().securityOrigin().toString());
|
| + GURL image_gurl(image_url);
|
| + if (!frame->document().securityOrigin().isEmpty() &&
|
| + !frame->top()->document().securityOrigin().isEmpty() &&
|
| + enabled_per_settings) {
|
| + ContentSettingsForOneType::const_iterator it;
|
| + for (it = image_setting_rules_->begin();
|
| + it != image_setting_rules_->end(); ++it) {
|
| + if (it->primary_pattern.Matches(top_url) &&
|
| + it->secondary_pattern.Matches(image_gurl)) {
|
| + allow = (it->setting != CONTENT_SETTING_BLOCK);
|
| + break;
|
| + }
|
| + }
|
| + }
|
| +
|
| + if (!allow)
|
| + DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES, std::string());
|
| + return allow;
|
| }
|
|
|
| bool ContentSettingsObserver::AllowIndexedDB(WebFrame* frame,
|
|
|