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 94150e65b4ff6968ee426bb3a351b9eb13b55024..a4c47b534ab4a8939479d226bee9b6cf51be159d 100644 |
| --- a/chrome/renderer/content_settings_observer.cc |
| +++ b/chrome/renderer/content_settings_observer.cc |
| @@ -75,6 +75,11 @@ void ContentSettingsObserver::SetDefaultContentSettings( |
| default_settings_ = settings; |
| } |
| +void ContentSettingsObserver::SetImageSettingRules( |
| + const ContentSettingsForOneType* image_setting_rules) { |
| + image_setting_rules_ = image_setting_rules; |
| +} |
| + |
| ContentSetting ContentSettingsObserver::GetContentSetting( |
| ContentSettingsType type) { |
| // Don't call this for plug-ins. |
| @@ -118,7 +123,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(); |
| @@ -198,16 +203,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; |
| - } |
| - |
| if (IsWhitelistedForContentSettings(frame)) |
| return true; |
| - DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES, std::string()); |
| - return false; // Other protocols fall through here. |
| + bool allow = false; |
|
Bernhard Bauer
2011/10/20 09:21:53
I think we may want to default to allow?
marja
2011/10/20 11:44:22
Shouldn't we default to enabled_per_settings inste
Bernhard Bauer
2011/10/20 11:58:24
OK (although in practice |enabled_per_settings| is
marja
2011/10/20 14:41:15
Done.
|
| + GURL top_url(frame->top()->document().securityOrigin().toString()); |
|
Bernhard Bauer
2011/10/20 09:21:53
Argh, I just noticed that per http://crbug.com/100
marja
2011/10/20 11:44:22
There is the gotcha that "a unique security origin
Bernhard Bauer
2011/10/20 11:58:24
Plus, it means that file:/// content setting patte
marja
2011/10/20 14:41:15
I changed this to be frame->document().url() and p
jochen (gone - plz use gerrit)
2011/10/20 15:32:15
I'd prefer if we'd stick to the security origin. O
Bernhard Bauer
2011/10/20 15:37:09
How would that work if we use the main frame URL?
jochen (gone - plz use gerrit)
2011/10/20 19:01:21
sorry for being unclear, I meant opening the frame
marja
2011/10/21 09:52:58
I uploaded a version which falls back to document.
|
| + GURL image_gurl(image_url); |
| + if (image_setting_rules_ && |
| + !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, |