IPC per-host content settings to the renderers.
BUG=32719
TEST=none
Review URL: http://codereview.chromium.org/549218
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37628 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index 2d47a43d..1123790 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -88,6 +88,7 @@
using WebKit::WebCache;
using WebKit::WebCrossOriginPreflightResultCache;
using WebKit::WebFontCache;
+using WebKit::WebFrame;
using WebKit::WebRuntimeFeatures;
using WebKit::WebSecurityPolicy;
using WebKit::WebScriptController;
@@ -139,6 +140,30 @@
};
#endif
+class RenderViewContentSettingsSetter : public RenderViewVisitor {
+ public:
+ RenderViewContentSettingsSetter(const std::string& host,
+ const ContentSettings& content_settings)
+ : host_(host),
+ content_settings_(content_settings) {
+ }
+
+ 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_);
+ }
+ return true;
+ }
+
+ private:
+ std::string host_;
+ ContentSettings content_settings_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderViewContentSettingsSetter);
+};
+
class RenderViewZoomer : public RenderViewVisitor {
public:
RenderViewZoomer(const std::string& host, int zoom_level)
@@ -284,6 +309,13 @@
WebView::resetVisitedLinkState();
}
+void RenderThread::OnSetContentSettingsForCurrentHost(
+ const std::string& host,
+ const ContentSettings& content_settings) {
+ RenderViewContentSettingsSetter setter(host, content_settings);
+ RenderView::ForEach(&setter);
+}
+
void RenderThread::OnSetZoomLevelForCurrentHost(const std::string& host,
int zoom_level) {
RenderViewZoomer zoomer(host, zoom_level);
@@ -343,6 +375,8 @@
IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks)
IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Add, OnAddVisitedLinks)
IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Reset, OnResetVisitedLinks)
+ IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForCurrentHost,
+ OnSetContentSettingsForCurrentHost)
IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentHost,
OnSetZoomLevelForCurrentHost)
IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID)