summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser.cc28
-rw-r--r--chrome/browser/browser.h7
-rw-r--r--chrome/browser/browser_prefs.cc4
-rw-r--r--chrome/browser/host_zoom_map.cc69
-rw-r--r--chrome/browser/host_zoom_map.h60
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc9
-rw-r--r--chrome/browser/net/chrome_url_request_context.h8
-rw-r--r--chrome/browser/profile.cc20
-rw-r--r--chrome/browser/profile.h6
-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
12 files changed, 246 insertions, 49 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 32cb834..f913e72 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 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.
@@ -37,6 +37,7 @@
#include "chrome/browser/find_bar_controller.h"
#include "chrome/browser/google_url_tracker.h"
#include "chrome/browser/google_util.h"
+#include "chrome/browser/host_zoom_map.h"
#include "chrome/browser/location_bar.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/net/browser_url_util.h"
@@ -1125,19 +1126,12 @@ void Browser::FindPrevious() {
FindInPage(true, false);
}
-void Browser::ZoomIn() {
- UserMetrics::RecordAction("ZoomPlus", profile_);
- GetSelectedTabContents()->render_view_host()->Zoom(PageZoom::LARGER);
-}
-
-void Browser::ZoomReset() {
- UserMetrics::RecordAction("ZoomNormal", profile_);
- GetSelectedTabContents()->render_view_host()->Zoom(PageZoom::STANDARD);
-}
-
-void Browser::ZoomOut() {
- UserMetrics::RecordAction("ZoomMinus", profile_);
- GetSelectedTabContents()->render_view_host()->Zoom(PageZoom::SMALLER);
+void Browser::Zoom(PageZoom::Function zoom_function) {
+ static const char* kActions[] = { "ZoomMinus", "ZoomNormal", "ZoomPlus" };
+ UserMetrics::RecordComputedAction(
+ kActions[zoom_function - PageZoom::ZOOM_OUT], profile_);
+ TabContents* tab_contents = GetSelectedTabContents();
+ tab_contents->render_view_host()->Zoom(zoom_function);
}
void Browser::FocusToolbar() {
@@ -1523,9 +1517,9 @@ void Browser::ExecuteCommandWithDisposition(
case IDC_FIND_PREVIOUS: FindPrevious(); break;
// Zoom
- case IDC_ZOOM_PLUS: ZoomIn(); break;
- case IDC_ZOOM_NORMAL: ZoomReset(); break;
- case IDC_ZOOM_MINUS: ZoomOut(); break;
+ case IDC_ZOOM_PLUS: Zoom(PageZoom::ZOOM_IN); break;
+ case IDC_ZOOM_NORMAL: Zoom(PageZoom::RESET); break;
+ case IDC_ZOOM_MINUS: Zoom(PageZoom::ZOOM_OUT); break;
// Focus various bits of UI
case IDC_FOCUS_TOOLBAR: FocusToolbar(); break;
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 6507c98..fd7c63d 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 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.
@@ -21,6 +21,7 @@
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/browser/toolbar_model.h"
#include "chrome/common/notification_registrar.h"
+#include "chrome/common/page_zoom.h"
#include "chrome/common/pref_member.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
@@ -390,9 +391,7 @@ class Browser : public TabStripModelDelegate,
void FindPrevious();
// Zoom
- void ZoomIn();
- void ZoomReset();
- void ZoomOut();
+ void Zoom(PageZoom::Function zoom_function);
// Focus various bits of UI
void FocusToolbar();
diff --git a/chrome/browser/browser_prefs.cc b/chrome/browser/browser_prefs.cc
index f96b39e..ae3abf9 100644
--- a/chrome/browser/browser_prefs.cc
+++ b/chrome/browser/browser_prefs.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.
@@ -16,6 +16,7 @@
#include "chrome/browser/external_protocol_handler.h"
#include "chrome/browser/form_field_history_manager.h"
#include "chrome/browser/google_url_tracker.h"
+#include "chrome/browser/host_zoom_map.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/net/dns_global.h"
#include "chrome/browser/page_info_model.h"
@@ -94,6 +95,7 @@ void RegisterUserPrefs(PrefService* user_prefs) {
ExtensionsUI::RegisterUserPrefs(user_prefs);
NewTabUI::RegisterUserPrefs(user_prefs);
BlockedPopupContainer::RegisterUserPrefs(user_prefs);
+ HostZoomMap::RegisterUserPrefs(user_prefs);
DevToolsManager::RegisterUserPrefs(user_prefs);
#if defined(TOOLKIT_GTK)
BrowserWindowGtk::RegisterUserPrefs(user_prefs);
diff --git a/chrome/browser/host_zoom_map.cc b/chrome/browser/host_zoom_map.cc
new file mode 100644
index 0000000..2c6393ca
--- /dev/null
+++ b/chrome/browser/host_zoom_map.cc
@@ -0,0 +1,69 @@
+// 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.
+
+#include "chrome/browser/host_zoom_map.h"
+
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/profile.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
+
+HostZoomMap::HostZoomMap(Profile* profile) : profile_(profile) {
+ const DictionaryValue* host_zoom_dictionary =
+ profile_->GetPrefs()->GetDictionary(prefs::kPerHostZoomLevels);
+ // Careful: The returned value could be NULL if the pref has never been set.
+ if (host_zoom_dictionary != NULL) {
+ for (DictionaryValue::key_iterator i(host_zoom_dictionary->begin_keys());
+ i != host_zoom_dictionary->end_keys(); ++i) {
+ std::wstring wide_host(*i);
+ int zoom_level = 0;
+ bool success = host_zoom_dictionary->GetIntegerWithoutPathExpansion(
+ wide_host, &zoom_level);
+ DCHECK(success);
+ host_zoom_levels_[WideToUTF8(wide_host)] = zoom_level;
+ }
+ }
+}
+
+// static
+void HostZoomMap::RegisterUserPrefs(PrefService* prefs) {
+ prefs->RegisterDictionaryPref(prefs::kPerHostZoomLevels);
+}
+
+int HostZoomMap::GetZoomLevel(const std::string& host) const {
+ AutoLock auto_lock(lock_);
+ HostZoomLevels::const_iterator i(host_zoom_levels_.find(host));
+ return (i == host_zoom_levels_.end()) ? 0 : i->second;
+}
+
+void HostZoomMap::SetZoomLevel(const std::string& host, int level) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ if (host.empty())
+ return;
+
+ {
+ AutoLock auto_lock(lock_);
+ if (level == 0)
+ host_zoom_levels_.erase(host);
+ else
+ host_zoom_levels_[host] = level;
+ }
+
+ // Persist new zoom level if we're not off the record.
+ if (!profile_->IsOffTheRecord()) {
+ DictionaryValue* host_zoom_dictionary =
+ profile_->GetPrefs()->GetMutableDictionary(prefs::kPerHostZoomLevels);
+ std::wstring wide_host(UTF8ToWide(host));
+ if (level == 0) {
+ host_zoom_dictionary->RemoveWithoutPathExpansion(wide_host, NULL);
+ } else {
+ host_zoom_dictionary->SetWithoutPathExpansion(wide_host,
+ Value::CreateIntegerValue(level));
+ }
+ }
+}
+
+HostZoomMap::~HostZoomMap() {
+}
diff --git a/chrome/browser/host_zoom_map.h b/chrome/browser/host_zoom_map.h
new file mode 100644
index 0000000..1cf86be
--- /dev/null
+++ b/chrome/browser/host_zoom_map.h
@@ -0,0 +1,60 @@
+// 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.
+
+// Maps hostnames to custom zoom levels. Written on the UI thread and read on
+// the IO thread. One instance per profile.
+
+#ifndef CHROME_BROWSER_HOST_ZOOM_MAP_H_
+#define CHROME_BROWSER_HOST_ZOOM_MAP_H_
+
+#include <map>
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/lock.h"
+#include "base/ref_counted.h"
+
+class PrefService;
+class Profile;
+
+class HostZoomMap : public base::RefCountedThreadSafe<HostZoomMap> {
+ public:
+ explicit HostZoomMap(Profile* profile);
+
+ static void RegisterUserPrefs(PrefService* prefs);
+
+ // Returns the zoom level for a given hostname. In most cases, there is no
+ // custom zoom level, and this returns 0. Otherwise, returns the saved zoom
+ // level, which may be positive (to zoom in) or negative (to zoom out).
+ //
+ // This may be called on any thread.
+ int GetZoomLevel(const std::string& host) const;
+
+ // Sets the zoom level for a given hostname to |level|. If the level is 0,
+ // the host is erased from the saved preferences; otherwise the new value is
+ // written out.
+ //
+ // This should only be called on the UI thread.
+ void SetZoomLevel(const std::string& host, int level);
+
+ private:
+ friend class base::RefCountedThreadSafe<HostZoomMap>;
+
+ typedef std::map<std::string, int> HostZoomLevels;
+
+ ~HostZoomMap();
+
+ // The profile we're associated with.
+ Profile* profile_;
+
+ // Copy of the pref data, so that we can read it on the IO thread.
+ HostZoomLevels host_zoom_levels_;
+
+ // Used around accesses to |host_zoom_levels_| to guarantee thread safety.
+ mutable Lock lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(HostZoomMap);
+};
+
+#endif // CHROME_BROWSER_HOST_ZOOM_MAP_H_
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index bf008aa..51b5517 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -756,10 +756,11 @@ ChromeURLRequestContext::ChromeURLRequestContext(
referrer_charset_ = other->referrer_charset_;
// Set ChromeURLRequestContext members
- appcache_service_ = other->appcache_service_;
- blacklist_manager_ = other->blacklist_manager_;
extension_paths_ = other->extension_paths_;
user_script_dir_path_ = other->user_script_dir_path_;
+ appcache_service_ = other->appcache_service_;
+ host_zoom_map_ = other->host_zoom_map_;
+ blacklist_manager_ = other->blacklist_manager_;
is_media_ = other->is_media_;
is_off_the_record_ = other->is_off_the_record_;
}
@@ -829,6 +830,8 @@ ChromeURLRequestContextFactory::ChromeURLRequestContextFactory(Profile* profile)
cookie_policy_type_ = net::CookiePolicy::FromInt(
prefs->GetInteger(prefs::kCookieBehavior));
+ host_zoom_map_ = profile->GetHostZoomMap();
+
blacklist_manager_ = profile->GetBlacklistManager();
// TODO(eroman): this doesn't look safe; sharing between IO and UI threads!
@@ -846,7 +849,6 @@ ChromeURLRequestContextFactory::ChromeURLRequestContextFactory(Profile* profile)
if (profile->GetUserScriptMaster())
user_script_dir_path_ = profile->GetUserScriptMaster()->user_script_dir();
- // TODO(eroman): this doesn't look safe; sharing between IO and UI threads!
ssl_config_service_ = profile->GetSSLConfigService();
profile_dir_path_ = profile->GetPath();
@@ -868,6 +870,7 @@ void ChromeURLRequestContextFactory::ApplyProfileParametersToContext(
context->set_cookie_policy_type(cookie_policy_type_);
context->set_extension_paths(extension_paths_);
context->set_user_script_dir_path(user_script_dir_path_);
+ context->set_host_zoom_map(host_zoom_map_);
context->set_blacklist_manager(blacklist_manager_.get());
context->set_strict_transport_security_state(
strict_transport_security_state_);
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index 0d9bed040..55c497a 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_
#include "base/file_path.h"
+#include "chrome/browser/host_zoom_map.h"
#include "chrome/browser/net/url_request_context_getter.h"
#include "chrome/common/appcache/chrome_appcache_service.h"
#include "chrome/common/notification_registrar.h"
@@ -178,6 +179,8 @@ class ChromeURLRequestContext : public URLRequestContext {
virtual bool AllowSendingCookies(const URLRequest* request) const;
+ const HostZoomMap* host_zoom_map() const { return host_zoom_map_; }
+
// Gets the Privacy Blacklist, if any for this context.
const Blacklist* GetBlacklist() const;
@@ -243,6 +246,9 @@ class ChromeURLRequestContext : public URLRequestContext {
void set_extension_paths(const ExtensionPaths& paths) {
extension_paths_ = paths;
}
+ void set_host_zoom_map(HostZoomMap* host_zoom_map) {
+ host_zoom_map_ = host_zoom_map;
+ }
void set_blacklist_manager(BlacklistManager* blacklist_manager);
void set_appcache_service(ChromeAppCacheService* service) {
appcache_service_ = service;
@@ -266,6 +272,7 @@ class ChromeURLRequestContext : public URLRequestContext {
FilePath user_script_dir_path_;
scoped_refptr<ChromeAppCacheService> appcache_service_;
+ scoped_refptr<HostZoomMap> host_zoom_map_;
scoped_refptr<BlacklistManager> blacklist_manager_;
bool is_media_;
@@ -308,6 +315,7 @@ class ChromeURLRequestContextFactory {
net::CookiePolicy::Type cookie_policy_type_;
ChromeURLRequestContext::ExtensionPaths extension_paths_;
FilePath user_script_dir_path_;
+ scoped_refptr<HostZoomMap> host_zoom_map_;
scoped_refptr<BlacklistManager> blacklist_manager_;
net::StrictTransportSecurityState* strict_transport_security_state_;
scoped_refptr<net::SSLConfigService> ssl_config_service_;
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index 5cdeb3e..530c902 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.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.
@@ -29,6 +29,7 @@
#include "chrome/browser/spellcheck_host.h"
#include "chrome/browser/strict_transport_security_persister.h"
#include "chrome/browser/history/history.h"
+#include "chrome/browser/host_zoom_map.h"
#include "chrome/browser/in_process_webkit/webkit_context.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/net/ssl_config_service_manager.h"
@@ -403,6 +404,14 @@ class OffTheRecordProfileImpl : public Profile,
return GetOriginalProfile()->GetSSLConfigService();
}
+ virtual HostZoomMap* GetHostZoomMap() {
+ // Need to use a separate map from the normal one to avoid persisting zoom
+ // changes in OTR mode.
+ if (!host_zoom_map_)
+ host_zoom_map_ = new HostZoomMap(this);
+ return host_zoom_map_.get();
+ }
+
virtual BlacklistManager* GetBlacklistManager() {
return GetOriginalProfile()->GetBlacklistManager();
}
@@ -525,6 +534,8 @@ class OffTheRecordProfileImpl : public Profile,
scoped_refptr<ChromeURLRequestContextGetter> extensions_request_context_;
+ scoped_refptr<HostZoomMap> host_zoom_map_;
+
// The download manager that only stores downloaded items in memory.
scoped_refptr<DownloadManager> download_manager_;
@@ -560,6 +571,7 @@ ProfileImpl::ProfileImpl(const FilePath& path)
request_context_(NULL),
media_request_context_(NULL),
extensions_request_context_(NULL),
+ host_zoom_map_(NULL),
blacklist_manager_(NULL),
blacklist_manager_created_(false),
history_service_created_(false),
@@ -952,6 +964,12 @@ net::SSLConfigService* ProfileImpl::GetSSLConfigService() {
return ssl_config_service_manager_->Get();
}
+HostZoomMap* ProfileImpl::GetHostZoomMap() {
+ if (!host_zoom_map_)
+ host_zoom_map_ = new HostZoomMap(this);
+ return host_zoom_map_.get();
+}
+
BlacklistManager* ProfileImpl::GetBlacklistManager() {
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnablePrivacyBlacklists)) {
diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h
index 51abbb3..2a1c065 100644
--- a/chrome/browser/profile.h
+++ b/chrome/browser/profile.h
@@ -43,6 +43,7 @@ class ExtensionMessageService;
class ExtensionsService;
class FaviconService;
class HistoryService;
+class HostZoomMap;
class NavigationController;
class NTPResourceCache;
class PasswordStore;
@@ -287,6 +288,9 @@ class Profile {
// Returns the SSLConfigService for this profile.
virtual net::SSLConfigService* GetSSLConfigService() = 0;
+ // Returns the Hostname <-> Zoom Level map for this profile.
+ virtual HostZoomMap* GetHostZoomMap() = 0;
+
// Returns the Privacy Blacklist Manager for this profile.
virtual BlacklistManager* GetBlacklistManager() = 0;
@@ -433,6 +437,7 @@ class ProfileImpl : public Profile,
virtual URLRequestContextGetter* GetRequestContextForMedia();
virtual URLRequestContextGetter* GetRequestContextForExtensions();
virtual net::SSLConfigService* GetSSLConfigService();
+ virtual HostZoomMap* GetHostZoomMap();
virtual BlacklistManager* GetBlacklistManager();
virtual SessionService* GetSessionService();
virtual void ShutdownSessionService();
@@ -516,6 +521,7 @@ class ProfileImpl : public Profile,
scoped_ptr<SSLConfigServiceManager> ssl_config_service_manager_;
+ scoped_refptr<HostZoomMap> host_zoom_map_;
scoped_refptr<BlacklistManager> blacklist_manager_;
scoped_refptr<DownloadManager> download_manager_;
scoped_refptr<HistoryService> history_service_;
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_;