diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-23 07:17:54 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-23 07:17:54 +0000 |
commit | 9d797f394f319b754ed91a981dab566d764d2c2e (patch) | |
tree | aee695b1c2af9d540e3fe99d834de015f70665cf /chrome/renderer | |
parent | 97c9e77b34099c518f85571f6d36e178d7695b23 (diff) | |
download | chromium_src-9d797f394f319b754ed91a981dab566d764d2c2e.zip chromium_src-9d797f394f319b754ed91a981dab566d764d2c2e.tar.gz chromium_src-9d797f394f319b754ed91a981dab566d764d2c2e.tar.bz2 |
Send content settings based on the URL to the renderer instead of just the host.
BUG=36025
TEST=manual
Review URL: http://codereview.chromium.org/1744003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/render_thread.cc | 19 | ||||
-rw-r--r-- | chrome/renderer/render_thread.h | 2 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 33 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 10 |
4 files changed, 31 insertions, 33 deletions
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index b7fb2af..ce746e4 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -61,6 +61,7 @@ #include "chrome/renderer/user_script_slave.h" #include "ipc/ipc_message.h" #include "ipc/ipc_platform_file.h" +#include "net/base/net_util.h" #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" #include "third_party/WebKit/WebKit/chromium/public/WebCache.h" #include "third_party/WebKit/WebKit/chromium/public/WebColor.h" @@ -171,14 +172,14 @@ class RenderViewContentSettingsSetter : public RenderViewVisitor { class RenderViewZoomer : public RenderViewVisitor { public: - RenderViewZoomer(const std::string& host, int zoom_level) - : host_(host), - zoom_level_(zoom_level) { + RenderViewZoomer(const GURL& url, int zoom_level) + : zoom_level_(zoom_level) { + host_ = net::GetHostOrSpecFromURL(url); } virtual bool Visit(RenderView* render_view) { WebView* webview = render_view->webview(); // Guaranteed non-NULL. - if (GURL(webview->mainFrame()->url()).host() == host_) + if (net::GetHostOrSpecFromURL(GURL(webview->mainFrame()->url())) == host_) webview->setZoomLevel(false, zoom_level_); return true; } @@ -457,9 +458,9 @@ void RenderThread::OnSetContentSettingsForCurrentURL( RenderView::ForEach(&setter); } -void RenderThread::OnSetZoomLevelForCurrentHost(const std::string& host, - int zoom_level) { - RenderViewZoomer zoomer(host, zoom_level); +void RenderThread::OnSetZoomLevelForCurrentURL(const GURL& url, + int zoom_level) { + RenderViewZoomer zoomer(url, zoom_level); RenderView::ForEach(&zoomer); } @@ -531,8 +532,8 @@ void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Reset, OnResetVisitedLinks) IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForCurrentURL, OnSetContentSettingsForCurrentURL) - IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentHost, - OnSetZoomLevelForCurrentHost) + IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, + OnSetZoomLevelForCurrentURL) IPC_MESSAGE_HANDLER(ViewMsg_SetIsIncognitoProcess, OnSetIsIncognitoProcess) IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors) diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h index ba5c849..680668c 100644 --- a/chrome/renderer/render_thread.h +++ b/chrome/renderer/render_thread.h @@ -209,7 +209,7 @@ class RenderThread : public RenderThreadBase, void OnUpdateVisitedLinks(base::SharedMemoryHandle table); void OnAddVisitedLinks(const VisitedLinkSlave::Fingerprints& fingerprints); void OnResetVisitedLinks(); - void OnSetZoomLevelForCurrentHost(const std::string& host, int zoom_level); + void OnSetZoomLevelForCurrentURL(const GURL& url, int zoom_level); void OnSetContentSettingsForCurrentURL( const GURL& url, const ContentSettings& content_settings); void OnUpdateUserScripts(base::SharedMemoryHandle table); diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 3364d16..9c3d1bd 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -594,10 +594,10 @@ void RenderView::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) - IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForLoadingHost, - OnSetContentSettingsForLoadingHost) - IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingHost, - OnSetZoomLevelForLoadingHost) + IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForLoadingURL, + OnSetContentSettingsForLoadingURL) + IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, + OnSetZoomLevelForLoadingURL) IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, OnResetPageEncodingToDefault) @@ -1235,7 +1235,7 @@ void RenderView::UpdateURL(WebFrame* frame) { // 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()).host()); + host_content_settings_.find(GURL(request.url())); if (host_content_settings != host_content_settings_.end()) { SetContentSettings(host_content_settings->second); @@ -1251,7 +1251,7 @@ void RenderView::UpdateURL(WebFrame* frame) { // Set zoom level. HostZoomLevels::iterator host_zoom = - host_zoom_levels_.find(GURL(request.url()).host()); + host_zoom_levels_.find(GURL(request.url())); if (host_zoom != host_zoom_levels_.end()) { webview()->setZoomLevel(false, host_zoom->second); // This zoom level was merely recorded transiently for this load. We can @@ -3596,23 +3596,20 @@ void RenderView::OnZoom(PageZoom::Function function) { int new_zoom_level = webview()->setZoomLevel(false, (function == PageZoom::RESET) ? 0 : (zoom_level + function)); - // Tell the browser which host got zoomed so it can update the saved values. - // Pages like the safe browsing interstitial can have empty hosts; don't - // record those. - std::string host(GURL(webview()->mainFrame()->url()).host()); - if (!host.empty()) - Send(new ViewHostMsg_DidZoomHost(host, new_zoom_level)); + // Tell the browser which url got zoomed so it can update the saved values. + Send(new ViewHostMsg_DidZoomURL( + GURL(webview()->mainFrame()->url()), new_zoom_level)); } -void RenderView::OnSetContentSettingsForLoadingHost( - std::string host, +void RenderView::OnSetContentSettingsForLoadingURL( + const GURL& url, const ContentSettings& content_settings) { - host_content_settings_[host] = content_settings; + host_content_settings_[url] = content_settings; } -void RenderView::OnSetZoomLevelForLoadingHost(std::string host, - int zoom_level) { - host_zoom_levels_[host] = zoom_level; +void RenderView::OnSetZoomLevelForLoadingURL(const GURL& url, + int zoom_level) { + host_zoom_levels_[url] = zoom_level; } void RenderView::OnSetPageEncoding(const std::string& encoding_name) { diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 837c617..3a0b497 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -549,8 +549,8 @@ class RenderView : public RenderWidget, #endif FRIEND_TEST(RenderViewTest, JSBlockSentAfterPageLoad); - typedef std::map<std::string, ContentSettings> HostContentSettings; - typedef std::map<std::string, int> HostZoomLevels; + typedef std::map<GURL, ContentSettings> HostContentSettings; + typedef std::map<GURL, int> HostZoomLevels; explicit RenderView(RenderThreadBase* render_thread, const WebPreferences& webkit_preferences, @@ -653,10 +653,10 @@ class RenderView : public RenderWidget, void OnStopFinding(const ViewMsg_StopFinding_Params& params); void OnFindReplyAck(); void OnDeterminePageLanguage(); - void OnSetContentSettingsForLoadingHost( - std::string host, const ContentSettings& content_settings); + void OnSetContentSettingsForLoadingURL( + const GURL& url, const ContentSettings& content_settings); void OnZoom(PageZoom::Function function); - void OnSetZoomLevelForLoadingHost(std::string host, int zoom_level); + void OnSetZoomLevelForLoadingURL(const GURL& url, int zoom_level); void OnSetPageEncoding(const std::string& encoding_name); void OnResetPageEncodingToDefault(); void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url); |