diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-30 20:20:01 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-30 20:20:01 +0000 |
commit | 433819da3ead5c8ef282c3068c61c8ecfc2e31c7 (patch) | |
tree | 7aa109eaf3c5809ea878f84bf2a8873b8c101d5e | |
parent | 07286bd43719ee728a238ad1cfe1547de9e661d5 (diff) | |
download | chromium_src-433819da3ead5c8ef282c3068c61c8ecfc2e31c7.zip chromium_src-433819da3ead5c8ef282c3068c61c8ecfc2e31c7.tar.gz chromium_src-433819da3ead5c8ef282c3068c61c8ecfc2e31c7.tar.bz2 |
Fix api misunderstanding.
BUG=32719
TEST=none
Review URL: http://codereview.chromium.org/554145
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37645 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/render_thread.cc | 7 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 30 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 8 |
3 files changed, 20 insertions, 25 deletions
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 1123790..5b059ff 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -149,11 +149,8 @@ class RenderViewContentSettingsSetter : public RenderViewVisitor { } virtual bool Visit(RenderView* render_view) { - // |render_view->webview()| is guaranteed non-NULL. - WebFrame* frame = render_view->webview()->mainFrame(); - if (GURL(frame->url()).host() == host_) { - render_view->ApplyContentSettings(frame, content_settings_); - } + if (GURL(render_view->webview()->mainFrame()->url()).host() == host_) + render_view->SetContentSettings(content_settings_); return true; } diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 183fbd3..ad16f25 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1084,16 +1084,8 @@ void RenderView::OnSetInitialFocus(bool reverse) { /////////////////////////////////////////////////////////////////////////////// -void RenderView::ApplyContentSettings( - WebKit::WebFrame* frame, - const ContentSettings& settings) { - // CONTENT_SETTING_ASK is only valid for cookies. - allowImages(frame, settings.settings[CONTENT_SETTINGS_TYPE_IMAGES] == - CONTENT_SETTING_ALLOW); - allowScript(frame, settings.settings[CONTENT_SETTINGS_TYPE_JAVASCRIPT] == - CONTENT_SETTING_ALLOW); - allowPlugins(frame, settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] == - CONTENT_SETTING_ALLOW); +void RenderView::SetContentSettings(const ContentSettings& settings) { + current_content_settings_ = settings; } // Tell the embedding application that the URL of the active page has changed @@ -1153,7 +1145,7 @@ void RenderView::UpdateURL(WebFrame* frame) { HostContentSettings::iterator host_content_settings = host_content_settings_.find(GURL(request.url()).host()); if (host_content_settings != host_content_settings_.end()) { - ApplyContentSettings(frame, host_content_settings->second); + 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 @@ -2031,15 +2023,17 @@ void RenderView::willClose(WebFrame* frame) { bool RenderView::allowPlugins(WebFrame* frame, bool enabled_per_settings) { if (!enabled_per_settings) return false; - // TODO(darin): Apply policy from content settings. - return true; + // CONTENT_SETTING_ASK is only valid for cookies. + return current_content_settings_.settings[CONTENT_SETTINGS_TYPE_PLUGINS] != + CONTENT_SETTING_BLOCK; } bool RenderView::allowImages(WebFrame* frame, bool enabled_per_settings) { if (!enabled_per_settings) return false; - // TODO(darin): Apply policy from content settings. - return true; + // CONTENT_SETTING_ASK is only valid for cookies. + return current_content_settings_.settings[CONTENT_SETTINGS_TYPE_IMAGES] != + CONTENT_SETTING_BLOCK; } void RenderView::loadURLExternally( @@ -2671,8 +2665,10 @@ void RenderView::didRunInsecureContent( bool RenderView::allowScript(WebFrame* frame, bool enabled_per_settings) { if (enabled_per_settings) { - // TODO(darin): Apply policy from content settings. - return true; + // CONTENT_SETTING_ASK is only valid for cookies. + return + current_content_settings_.settings[CONTENT_SETTINGS_TYPE_JAVASCRIPT] != + CONTENT_SETTING_BLOCK; } WebSecurityOrigin origin = frame->securityOrigin(); diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index c94229c..6d50216 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -262,9 +262,9 @@ class RenderView : public RenderWidget, return notification_provider_.get(); } - // Shortcut for calling allowImages(), allowScripts(), allowPlugins(). - void ApplyContentSettings(WebKit::WebFrame* frame, - const ContentSettings& settings); + // Sets the content settings that back allowScripts(), allowImages(), and + // allowPlugins(). + void SetContentSettings(const ContentSettings& settings); // WebKit::WebWidgetClient // Most methods are handled by RenderWidget. @@ -1035,6 +1035,8 @@ class RenderView : public RenderWidget, HostContentSettings host_content_settings_; HostZoomLevels host_zoom_levels_; + ContentSettings current_content_settings_; + // The SessionStorage namespace that we're assigned to has an ID, and that ID // is passed to us upon creation. WebKit asks for this ID upon first use and // uses it whenever asking the browser process to allocate new storage areas. |