Chromium Code Reviews| Index: content/renderer/render_view.cc |
| =================================================================== |
| --- content/renderer/render_view.cc (revision 81920) |
| +++ content/renderer/render_view.cc (working copy) |
| @@ -276,29 +276,6 @@ |
| result->push_back(urls[i]); |
| } |
| -// True if |frame| contains content that is white-listed for content settings. |
| -static bool IsWhitelistedForContentSettings(WebFrame* frame) { |
| - WebSecurityOrigin origin = frame->securityOrigin(); |
| - if (origin.isEmpty()) |
| - return false; // Uninitialized document? |
| - |
| - if (EqualsASCII(origin.protocol(), chrome::kChromeUIScheme)) |
| - return true; // Browser UI elements should still work. |
| - |
| - // If the scheme is ftp: or file:, an empty file name indicates a directory |
| - // listing, which requires JavaScript to function properly. |
| - GURL frame_url = frame->url(); |
| - const char* kDirProtocols[] = { "ftp", "file" }; |
| - for (size_t i = 0; i < arraysize(kDirProtocols); ++i) { |
| - if (EqualsASCII(origin.protocol(), kDirProtocols[i])) { |
| - return frame_url.SchemeIs(kDirProtocols[i]) && |
| - frame_url.ExtractFileName().empty(); |
| - } |
| - } |
| - |
| - return false; |
| -} |
| - |
| static bool WebAccessibilityNotificationToViewHostMsg( |
| WebAccessibilityNotification notification, |
| ViewHostMsg_AccessibilityNotification_Type::Value* type) { |
| @@ -418,9 +395,6 @@ |
| accessibility_ack_pending_(false), |
| p2p_socket_dispatcher_(NULL), |
| session_storage_namespace_id_(session_storage_namespace_id) { |
| - |
| - ClearBlockedContentSettings(); |
| - |
| routing_id_ = routing_id; |
| if (opener_id != MSG_ROUTING_NONE) |
| opener_id_ = opener_id; |
| @@ -681,8 +655,6 @@ |
| IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
| IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) |
| IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
| - IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForLoadingURL, |
| - OnSetContentSettingsForLoadingURL) |
| IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) |
| IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| OnSetZoomLevelForLoadingURL) |
| @@ -1023,10 +995,6 @@ |
| /////////////////////////////////////////////////////////////////////////////// |
| -void RenderView::SetContentSettings(const ContentSettings& settings) { |
| - current_content_settings_ = settings; |
| -} |
| - |
| // Tell the embedding application that the URL of the active page has changed |
| void RenderView::UpdateURL(WebFrame* frame) { |
| WebDataSource* ds = frame->dataSource(); |
| @@ -1094,33 +1062,6 @@ |
| if (!frame->parent()) { |
| // Top-level navigation. |
|
pastarmovj
2011/04/18 16:09:23
Do you want to preserve one empty line here.
jam
2011/04/18 16:50:10
Done.
|
| - |
| - // Clear "block" flags for the new page. This needs to happen before any of |
| - // allowScripts(), allowImages(), 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(); |
| - |
| - // Set content settings. Default them from the parent window if one exists. |
| - // This makes sure about:blank windows work as expected. |
| - HostContentSettings::iterator host_content_settings = |
| - host_content_settings_.find(GURL(request.url())); |
| - if (host_content_settings != host_content_settings_.end()) { |
| - SetContentSettings(host_content_settings->second); |
| - |
| - // These content settings were merely recorded transiently for this load. |
| - // We can erase them now. If at some point we reload this page, the |
| - // browser will send us new, up-to-date content settings. |
| - host_content_settings_.erase(host_content_settings); |
| - } else if (frame->opener()) { |
| - // The opener's view is not guaranteed to be non-null (it could be |
| - // detached from its page but not yet destructed). |
| - if (WebView* opener_view = frame->opener()->view()) { |
| - RenderView* opener = FromWebView(opener_view); |
| - SetContentSettings(opener->current_content_settings_); |
| - } |
| - } |
| - |
| // Set zoom level, but don't do it for full-page plugin since they don't use |
| // the same zoom settings. |
| HostZoomLevels::iterator host_zoom = |
| @@ -2108,22 +2049,6 @@ |
| FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameWillClose(frame)); |
| } |
| -bool RenderView::allowImages(WebFrame* frame, bool enabled_per_settings) { |
| - 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 RenderView::allowPlugins(WebFrame* frame, bool enabled_per_settings) { |
| - return WebFrameClient::allowPlugins(frame, enabled_per_settings); |
| -} |
| - |
| void RenderView::loadURLExternally( |
| WebFrame* frame, const WebURLRequest& request, |
| WebNavigationPolicy policy) { |
| @@ -2882,17 +2807,36 @@ |
| target)); |
| } |
| -bool RenderView::allowScript(WebFrame* frame, bool enabled_per_settings) { |
| - if (enabled_per_settings && |
| - AllowContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT)) |
| - return true; |
| +bool RenderView::allowImages(WebFrame* frame, bool enabled_per_settings) { |
| + ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
| + RenderViewObserver* observer; |
| + while ((observer = it.GetNext()) != NULL) |
| + if (!observer->AllowImages(frame, enabled_per_settings)) |
| + return false; |
| - if (IsWhitelistedForContentSettings(frame)) |
| - return true; |
| + return true; |
| +} |
| - return false; // Other protocols fall through here. |
| +bool RenderView::allowPlugins(WebFrame* frame, bool enabled_per_settings) { |
| + ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
| + RenderViewObserver* observer; |
| + while ((observer = it.GetNext()) != NULL) |
| + if (!observer->AllowPlugins(frame, enabled_per_settings)) |
| + return false; |
| + |
| + return true; |
| } |
| +bool RenderView::allowScript(WebFrame* frame, bool enabled_per_settings) { |
| + ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
| + RenderViewObserver* observer; |
| + while ((observer = it.GetNext()) != NULL) |
| + if (!observer->AllowScript(frame, enabled_per_settings)) |
| + return false; |
| + |
| + return true; |
| +} |
| + |
| bool RenderView::allowDatabase( |
| WebFrame* frame, const WebString& name, const WebString& display_name, |
| unsigned long estimated_size) { |
| @@ -2913,11 +2857,11 @@ |
| return result; |
| } |
| void RenderView::didNotAllowScript(WebKit::WebFrame* frame) { |
| - DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()); |
| + FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidNotAllowScript(frame)); |
| } |
| void RenderView::didNotAllowPlugins(WebKit::WebFrame* frame) { |
| - DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); |
| + FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidNotAllowPlugins(frame)); |
| } |
| void RenderView::didExhaustMemoryAvailableForScript(WebFrame* frame) { |
| @@ -3469,26 +3413,6 @@ |
| } |
| } |
| -bool RenderView::AllowContentType(ContentSettingsType settings_type) { |
| - // CONTENT_SETTING_ASK is only valid for cookies. |
| - return current_content_settings_.settings[settings_type] != |
| - CONTENT_SETTING_BLOCK; |
| -} |
| - |
| -void RenderView::DidBlockContentType(ContentSettingsType settings_type, |
| - const std::string& resource_identifier) { |
| - if (!content_blocked_[settings_type]) { |
| - content_blocked_[settings_type] = true; |
| - Send(new ViewHostMsg_ContentBlocked(routing_id_, settings_type, |
| - resource_identifier)); |
| - } |
| -} |
| - |
| -void RenderView::ClearBlockedContentSettings() { |
| - for (size_t i = 0; i < arraysize(content_blocked_); ++i) |
| - content_blocked_[i] = false; |
| -} |
| - |
| WebPlugin* RenderView::CreatePepperPlugin( |
| WebFrame* frame, |
| const WebPluginParams& params, |
| @@ -3549,12 +3473,6 @@ |
| zoomLevelChanged(); |
| } |
| -void RenderView::OnSetContentSettingsForLoadingURL( |
| - const GURL& url, |
| - const ContentSettings& content_settings) { |
| - host_content_settings_[url] = content_settings; |
| -} |
| - |
| void RenderView::OnSetZoomLevelForLoadingURL(const GURL& url, |
| double zoom_level) { |
| host_zoom_levels_[url] = zoom_level; |