summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-04 23:49:51 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-04 23:49:51 +0000
commit40bd658fd9aeedc8f2f7cc17c835f41095df9189 (patch)
tree87e9562263a8a641f7d2da19f629a2737d67c041 /chrome/browser/renderer_host
parent1c42268bc05d715b59d1b535e432c0d9ef666113 (diff)
downloadchromium_src-40bd658fd9aeedc8f2f7cc17c835f41095df9189.zip
chromium_src-40bd658fd9aeedc8f2f7cc17c835f41095df9189.tar.gz
chromium_src-40bd658fd9aeedc8f2f7cc17c835f41095df9189.tar.bz2
Remember zoom on a per-host basis.
BUG=567 TEST=Visit a page, zoom in or out, then navigate to a different host. The new page should not be zoomed. Go back, or restart, or open a new tab and navigate to the old page, and it should be zoomed. Review URL: http://codereview.chromium.org/437077 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33886 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/async_resource_handler.cc22
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc32
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h30
3 files changed, 61 insertions, 23 deletions
diff --git a/chrome/browser/renderer_host/async_resource_handler.cc b/chrome/browser/renderer_host/async_resource_handler.cc
index 276e431..91a2bb4 100644
--- a/chrome/browser/renderer_host/async_resource_handler.cc
+++ b/chrome/browser/renderer_host/async_resource_handler.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -7,6 +7,8 @@
#include "base/logging.h"
#include "base/process.h"
#include "base/shared_memory.h"
+#include "chrome/browser/net/chrome_url_request_context.h"
+#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
#include "chrome/common/render_messages.h"
#include "net/base/io_buffer.h"
@@ -97,6 +99,24 @@ bool AsyncResourceHandler::OnRequestRedirected(int request_id,
bool AsyncResourceHandler::OnResponseStarted(int request_id,
ResourceResponse* response) {
+ // For changes to the main frame, inform the renderer of the new URL's zoom
+ // level before the request actually commits. This way the renderer will be
+ // able to set the zoom level precisely at the time the request commits,
+ // avoiding the possibility of zooming the old content or of having to layout
+ // the new content twice.
+ URLRequest* request = rdh_->GetURLRequest(
+ ResourceDispatcherHost::GlobalRequestID(process_id_, request_id));
+ ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request);
+ if (info->resource_type() == ResourceType::MAIN_FRAME) {
+ std::string host(request->url().host());
+ ChromeURLRequestContext* context =
+ static_cast<ChromeURLRequestContext*>(request->context());
+ if (!host.empty() && context) {
+ receiver_->Send(new ViewMsg_SetZoomLevelForLoadingHost(info->route_id(),
+ host, context->host_zoom_map()->GetZoomLevel(host)));
+ }
+ }
+
receiver_->Send(new ViewMsg_Resource_ReceivedResponse(
routing_id_, request_id, response->response_head));
return true;
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 4f6c141..81aefa6 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/chrome_plugin_browsing_context.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/extensions/extension_message_service.h"
+#include "chrome/browser/host_zoom_map.h"
#include "chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h"
#include "chrome/browser/nacl_process_host.h"
#include "chrome/browser/net/chrome_url_request_context.h"
@@ -23,9 +24,9 @@
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/notifications/notifications_prefs_cache.h"
#include "chrome/browser/plugin_service.h"
-#include "chrome/browser/profile.h"
#include "chrome/browser/privacy_blacklist/blacklist.h"
#include "chrome/browser/privacy_blacklist/blacklist_ui.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/audio_renderer_host.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
#include "chrome/browser/renderer_host/database_dispatcher_host.h"
@@ -155,12 +156,12 @@ ResourceMessageFilter::ResourceMessageFilter(
resource_dispatcher_host_(resource_dispatcher_host),
plugin_service_(plugin_service),
print_job_manager_(print_job_manager),
+ profile_(profile),
ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)),
request_context_(request_context),
media_request_context_(profile->GetRequestContextForMedia()),
extensions_request_context_(profile->GetRequestContextForExtensions()),
extensions_message_service_(profile->GetExtensionMessageService()),
- profile_(profile),
render_widget_helper_(render_widget_helper),
audio_renderer_host_(audio_renderer_host),
appcache_dispatcher_host_(
@@ -173,6 +174,7 @@ ResourceMessageFilter::ResourceMessageFilter(
notification_prefs_(
profile->GetDesktopNotificationService()->prefs_cache()),
socket_stream_dispatcher_host_(new SocketStreamDispatcherHost),
+ host_zoom_map_(profile->GetHostZoomMap()),
off_the_record_(profile->IsOffTheRecord()),
next_route_id_callback_(NewCallbackWithReturnValue(
render_widget_helper, &RenderWidgetHelper::GetNextRoutingID)) {
@@ -369,6 +371,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
#endif
IPC_MESSAGE_HANDLER(ViewHostMsg_ResourceTypeStats, OnResourceTypeStats)
IPC_MESSAGE_HANDLER(ViewHostMsg_V8HeapStats, OnV8HeapStats)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomHost, OnDidZoomHost)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ResolveProxy, OnResolveProxy)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetDefaultPrintSettings,
OnGetDefaultPrintSettings)
@@ -843,6 +846,31 @@ void ResourceMessageFilter::OnV8HeapStatsOnUIThread(
static_cast<size_t>(v8_memory_used));
}
+void ResourceMessageFilter::OnDidZoomHost(const std::string& host,
+ int zoom_level) {
+ ChromeThread::PostTask(ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this,
+ &ResourceMessageFilter::UpdateHostZoomLevelsOnUIThread,
+ host, zoom_level));
+}
+
+void ResourceMessageFilter::UpdateHostZoomLevelsOnUIThread(
+ const std::string& host,
+ int zoom_level) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ host_zoom_map_->SetZoomLevel(host, zoom_level);
+
+ // Notify renderers.
+ for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
+ !i.IsAtEnd(); i.Advance()) {
+ RenderProcessHost* render_process_host = i.GetCurrentValue();
+ if (render_process_host->profile() == profile_) {
+ render_process_host->Send(
+ new ViewMsg_SetZoomLevelForCurrentHost(host, zoom_level));
+ }
+ }
+}
+
void ResourceMessageFilter::OnResolveProxy(const GURL& url,
IPC::Message* reply_msg) {
resolve_proxy_msg_helper_.Start(url, reply_msg);
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 7d0eb01..7d5d137 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -36,11 +36,11 @@ class ChromeURLRequestContext;
class DatabaseDispatcherHost;
class DOMStorageDispatcherHost;
class ExtensionMessageService;
+class HostZoomMap;
class NotificationsPrefsCache;
class Profile;
class RenderWidgetHelper;
class SocketStreamDispatcherHost;
-class SpellChecker;
class URLRequestContextGetter;
struct ViewHostMsg_Audio_CreateStream;
struct WebPluginInfo;
@@ -75,10 +75,6 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
public ResolveProxyMsgHelper::Delegate {
public:
// Create the filter.
- // Note: because the lifecycle of the ResourceMessageFilter is not
- // tied to the lifecycle of the object which created it, the
- // ResourceMessageFilter is 'given' ownership of the spellchecker
- // object and must clean it up on exit.
ResourceMessageFilter(ResourceDispatcherHost* resource_dispatcher_host,
int child_id,
AudioRendererHost* audio_renderer_host,
@@ -251,6 +247,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
int v8_memory_used,
base::ProcessId renderer_id);
+ void OnDidZoomHost(const std::string& host, int zoom_level);
+ void UpdateHostZoomLevelsOnUIThread(const std::string& host, int zoom_level);
+
void OnResolveProxy(const GURL& url, IPC::Message* reply_msg);
// ResolveProxyMsgHelper::Delegate implementation:
@@ -336,11 +335,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
PluginService* plugin_service_;
printing::PrintJobManager* print_job_manager_;
- // ID for the RenderProcessHost that corresponds to this channel. This is
- // used by the ResourceDispatcherHost to look up the TabContents that
- // originated URLRequest. Since the RenderProcessHost can be destroyed
- // before this object, we only hold an ID for lookup.
- int child_id_;
+ // The Profile associated with our renderer process. This should only be
+ // accessed on the UI thread!
+ Profile* profile_;
// Helper class for handling PluginProcessHost_ResolveProxy messages (manages
// the requests to the proxy service).
@@ -358,16 +355,6 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
// Used for routing extension messages.
scoped_refptr<ExtensionMessageService> extensions_message_service_;
- // A pointer to the profile associated with this filter.
- //
- // DANGER! Do not dereference this pointer! This class lives on the I/O thread
- // and the profile may only be used on the UI thread. It is used only for
- // determining which notifications to watch for.
- //
- // This is void* to prevent people from accidentally dereferencing it.
- // When registering for observers, cast to Profile*.
- void* profile_;
-
scoped_refptr<RenderWidgetHelper> render_widget_helper_;
// Object that should take care of audio related resource requests.
@@ -389,6 +376,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
// Handles Socket Stream related messages.
scoped_ptr<SocketStreamDispatcherHost> socket_stream_dispatcher_host_;
+ // Handles zoom-related messages.
+ scoped_refptr<HostZoomMap> host_zoom_map_;
+
// Whether this process is used for off the record tabs.
bool off_the_record_;