summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rwxr-xr-xchrome/chrome_browser.gypi2
-rw-r--r--chrome/common/common_param_traits.h44
-rw-r--r--chrome/common/page_zoom.h14
-rw-r--r--chrome/common/pref_names.cc6
-rw-r--r--chrome/common/pref_names.h3
-rw-r--r--chrome/common/render_messages_internal.h26
-rw-r--r--chrome/renderer/render_thread.cc31
-rw-r--r--chrome/renderer/render_thread.h2
-rw-r--r--chrome/renderer/render_view.cc60
-rw-r--r--chrome/renderer/render_view.h8
-rw-r--r--chrome/test/testing_profile.h1
-rw-r--r--webkit/tools/test_shell/event_sending_controller.cc10
-rw-r--r--webkit/tools/test_shell/layout_test_controller.cc4
25 files changed, 405 insertions, 101 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_;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index c34bc49..7c403d6 100755
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -969,6 +969,8 @@
'browser/history/visit_tracker.h',
'browser/history/visitsegment_database.cc',
'browser/history/visitsegment_database.h',
+ 'browser/host_zoom_map.cc',
+ 'browser/host_zoom_map.h',
'browser/hung_renderer_dialog.h',
'browser/icon_loader.h',
'browser/icon_loader.cc',
diff --git a/chrome/common/common_param_traits.h b/chrome/common/common_param_traits.h
index cb0ba43..98f6bfb 100644
--- a/chrome/common/common_param_traits.h
+++ b/chrome/common/common_param_traits.h
@@ -14,6 +14,7 @@
#include <vector>
#include "app/gfx/native_widget_types.h"
+#include "chrome/common/page_zoom.h"
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/transport_dib.h"
#include "ipc/ipc_message_utils.h"
@@ -90,14 +91,36 @@ template <>
struct ParamTraits<gfx::NativeWindow> {
typedef gfx::NativeWindow param_type;
static void Write(Message* m, const param_type& p) {
- m->WriteIntPtr(reinterpret_cast<intptr_t>(p));
+ WriteParam(m, reinterpret_cast<intptr_t>(p));
}
static bool Read(const Message* m, void** iter, param_type* r) {
- DCHECK_EQ(sizeof(param_type), sizeof(intptr_t));
- return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r));
+ intptr_t value;
+ if (!ReadParam(m, iter, &value))
+ return false;
+ *r = reinterpret_cast<param_type>(value);
+ return true;
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ LogParam(reinterpret_cast<intptr_t>(p), l);
+ }
+};
+
+
+template <>
+struct ParamTraits<PageZoom::Function> {
+ typedef PageZoom::Function param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, static_cast<int>(p));
+ }
+ static bool Read(const Message* m, void** iter, param_type* r) {
+ int value;
+ if (!ReadParam(m, iter, &value))
+ return false;
+ *r = static_cast<param_type>(value);
+ return true;
}
static void Log(const param_type& p, std::wstring* l) {
- l->append(StringPrintf(L"0x%X", p));
+ LogParam(static_cast<int>(p), l);
}
};
@@ -106,16 +129,17 @@ template <>
struct ParamTraits<WindowOpenDisposition> {
typedef WindowOpenDisposition param_type;
static void Write(Message* m, const param_type& p) {
- m->WriteInt(p);
+ WriteParam(m, static_cast<int>(p));
}
static bool Read(const Message* m, void** iter, param_type* r) {
- int temp;
- bool res = m->ReadInt(iter, &temp);
- *r = static_cast<WindowOpenDisposition>(temp);
- return res;
+ int value;
+ if (!ReadParam(m, iter, &value))
+ return false;
+ *r = static_cast<param_type>(value);
+ return true;
}
static void Log(const param_type& p, std::wstring* l) {
- l->append(StringPrintf(L"%d", p));
+ LogParam(static_cast<int>(p), l);
}
};
diff --git a/chrome/common/page_zoom.h b/chrome/common/page_zoom.h
index ddd83ea..fa2f5bb 100644
--- a/chrome/common/page_zoom.h
+++ b/chrome/common/page_zoom.h
@@ -1,22 +1,22 @@
-// 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.
#ifndef CHROME_COMMON_PAGE_ZOOM_H_
#define CHROME_COMMON_PAGE_ZOOM_H_
-// This enum is the parameter to various text/page zoom commands so we know
-// what the specific zoom command is.
class PageZoom {
public:
+ // This enum is the parameter to various text/page zoom commands so we know
+ // what the specific zoom command is.
enum Function {
- SMALLER = -1,
- STANDARD = 0,
- LARGER = 1,
+ ZOOM_OUT = -1,
+ RESET = 0,
+ ZOOM_IN = 1,
};
private:
- PageZoom() {} // For scoping only.
+ DISALLOW_IMPLICIT_CONSTRUCTORS(PageZoom);
};
#endif // CHROME_COMMON_PAGE_ZOOM_H_
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index c13da00..acd77db 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.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.
@@ -294,6 +294,10 @@ const wchar_t kDesktopNotificationAllowedOrigins[] =
const wchar_t kDesktopNotificationDeniedOrigins[] =
L"profile.notification_denied_sites";
+// Dictionary that maps hostnames to zoom levels. Hosts not in this pref will
+// be displayed at the default zoom level.
+const wchar_t kPerHostZoomLevels[] = L"profile.per_host_zoom_levels";
+
// *************** LOCAL STATE ***************
// These are attached to the machine/installation
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index f2f30b2..d3095b1 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.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.
@@ -117,6 +117,7 @@ extern const wchar_t kNTPPromoLineRemaining[];
extern const wchar_t kNTPPromoImageRemaining[];
extern const wchar_t kDesktopNotificationAllowedOrigins[];
extern const wchar_t kDesktopNotificationDeniedOrigins[];
+extern const wchar_t kPerHostZoomLevels[];
// Local state
extern const wchar_t kMetricsClientID[];
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index ff93124..342dbe0 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -24,6 +24,7 @@
#include "chrome/common/extensions/update_manifest.h"
#include "chrome/common/nacl_types.h"
#include "chrome/common/notification_type.h"
+#include "chrome/common/page_zoom.h"
#include "chrome/common/transport_dib.h"
#include "chrome/common/view_types.h"
#include "ipc/ipc_channel_handle.h"
@@ -347,9 +348,24 @@ IPC_BEGIN_MESSAGES(View)
// will handle communication with inspected page DevToolsAgent.
IPC_MESSAGE_ROUTED0(ViewMsg_SetupDevToolsClient)
- // Change the zoom level in the renderer.
+ // Change the zoom level for the current main frame. If the level actually
+ // changes, a ViewHostMsg_DidZoomHost message will be sent back to the browser
+ // telling it what host got zoomed and what its current zoom level is.
IPC_MESSAGE_ROUTED1(ViewMsg_Zoom,
- int /* One of PageZoom::Function */)
+ PageZoom::Function /* function */)
+
+ // Set the zoom level for a particular hostname that the renderer is in the
+ // process of loading. This will be stored, to be used if the load commits
+ // and ignored otherwise.
+ IPC_MESSAGE_ROUTED2(ViewMsg_SetZoomLevelForLoadingHost,
+ std::string /* host */,
+ int /* zoom_level */)
+
+ // Set the zoom level for a particular hostname, so all render views
+ // displaying this host can update their zoom levels to match.
+ IPC_MESSAGE_CONTROL2(ViewMsg_SetZoomLevelForCurrentHost,
+ std::string /* host */,
+ int /* zoom_level */)
// Change encoding of page in the renderer.
IPC_MESSAGE_ROUTED1(ViewMsg_SetPageEncoding,
@@ -1551,6 +1567,12 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_MESSAGE_ROUTED1(ViewHostMsg_UploadProgress_ACK,
int /* request_id */)
+ // Sent when the renderer changes the zoom level for a particular host, so the
+ // browser can update its records.
+ IPC_MESSAGE_CONTROL2(ViewHostMsg_DidZoomHost,
+ std::string /* host */,
+ int /* zoom_level */)
+
#if defined(OS_WIN)
// Duplicates a shared memory handle from the renderer to the browser. Then
// the renderer can flush the handle.
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index b30a69c..a4b36a6 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -50,6 +50,7 @@
#include "chrome/renderer/net/render_dns_master.h"
#include "chrome/renderer/render_process.h"
#include "chrome/renderer/render_view.h"
+#include "chrome/renderer/render_view_visitor.h"
#include "chrome/renderer/renderer_webkitclient_impl.h"
#include "chrome/renderer/renderer_web_database_observer.h"
#include "chrome/renderer/socket_stream_dispatcher.h"
@@ -63,6 +64,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebCrossOriginPreflightResultCache.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFontCache.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
#include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h"
#include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h"
@@ -117,6 +119,27 @@ class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter {
}
};
#endif
+
+class RenderViewZoomer : public RenderViewVisitor {
+ public:
+ RenderViewZoomer(const std::string& host, int zoom_level)
+ : host_(host),
+ zoom_level_(zoom_level) {
+ }
+
+ virtual bool Visit(RenderView* render_view) {
+ WebView* webview = render_view->webview(); // Guaranteed non-NULL.
+ if (GURL(webview->mainFrame()->url()).host() == host_)
+ webview->setZoomLevel(false, zoom_level_);
+ return true;
+ }
+
+ private:
+ std::string host_;
+ int zoom_level_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer);
+};
} // namespace
// When we run plugins in process, we actually run them on the render thread,
@@ -243,6 +266,12 @@ void RenderThread::OnResetVisitedLinks() {
WebView::resetVisitedLinkState();
}
+void RenderThread::OnSetZoomLevelForCurrentHost(const std::string& host,
+ int zoom_level) {
+ RenderViewZoomer zoomer(host, zoom_level);
+ RenderView::ForEach(&zoomer);
+}
+
void RenderThread::OnUpdateUserScripts(
base::SharedMemoryHandle scripts) {
DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle";
@@ -297,6 +326,8 @@ void RenderThread::OnControlMessageReceived(const IPC::Message& msg) {
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_SetZoomLevelForCurrentHost,
+ OnSetZoomLevelForCurrentHost)
IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID)
IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors)
// TODO(port): removed from render_messages_internal.h;
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index 305607a..ef880eb 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -154,7 +154,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 OnUpdateUserScripts(base::SharedMemoryHandle table);
void OnSetExtensionFunctionNames(const std::vector<std::string>& names);
void OnPageActionsUpdated(const std::string& extension_id,
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index c164f63..c47cd25 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -436,6 +436,8 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
IPC_MESSAGE_HANDLER(ViewMsg_DeterminePageText, OnDeterminePageText)
IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
+ IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingHost,
+ OnSetZoomLevelForLoadingHost)
IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault,
OnResetPageEncodingToDefault)
@@ -1043,6 +1045,17 @@ void RenderView::UpdateURL(WebFrame* frame) {
if (!frame->parent()) {
// Top-level navigation.
+ // Set zoom level.
+ HostZoomLevels::iterator host =
+ host_zoom_levels_.find(GURL(request.url()).host());
+ if (host != host_zoom_levels_.end()) {
+ webview()->setZoomLevel(false, host->second);
+ // This zoom level was merely recorded transiently for this load. We can
+ // erase it now. If at some point we reload this page, the browser will
+ // send us a new, up-to-date zoom level.
+ host_zoom_levels_.erase(host);
+ }
+
// Update contents MIME type for main frame.
params.contents_mime_type = ds->response().mimeType().utf8();
@@ -2132,14 +2145,13 @@ void RenderView::didReceiveServerRedirectForProvisionalLoad(WebFrame* frame) {
std::vector<GURL> redirects;
GetRedirectChain(data_source, &redirects);
if (redirects.size() >= 2) {
- Send(new ViewHostMsg_DidRedirectProvisionalLoad(
- routing_id_, page_id_, redirects[redirects.size() - 2],
- redirects[redirects.size() - 1]));
+ Send(new ViewHostMsg_DidRedirectProvisionalLoad(routing_id_, page_id_,
+ redirects[redirects.size() - 2], redirects.back()));
}
}
-void RenderView::didFailProvisionalLoad(
- WebFrame* frame, const WebURLError& error) {
+void RenderView::didFailProvisionalLoad(WebFrame* frame,
+ const WebURLError& error) {
// Notify the browser that we failed a provisional load with an error.
//
// Note: It is important this notification occur before DidStopLoading so the
@@ -2220,8 +2232,8 @@ void RenderView::didReceiveDocumentData(
}
}
-void RenderView::didCommitProvisionalLoad(
- WebFrame* frame, bool is_new_navigation) {
+void RenderView::didCommitProvisionalLoad(WebFrame* frame,
+ bool is_new_navigation) {
NavigationState* navigation_state =
NavigationState::FromDataSource(frame->dataSource());
@@ -2963,21 +2975,25 @@ void RenderView::DnsPrefetch(const std::vector<std::string>& host_names) {
Send(new ViewHostMsg_DnsPrefetch(host_names));
}
-void RenderView::OnZoom(int function) {
- static const bool kZoomIsTextOnly = false;
- switch (function) {
- case PageZoom::SMALLER:
- webview()->zoomOut(kZoomIsTextOnly);
- break;
- case PageZoom::STANDARD:
- webview()->zoomDefault();
- break;
- case PageZoom::LARGER:
- webview()->zoomIn(kZoomIsTextOnly);
- break;
- default:
- NOTREACHED();
- }
+void RenderView::OnZoom(PageZoom::Function function) {
+ if (!webview()) // Not sure if this can happen, but no harm in being safe.
+ return;
+
+ int zoom_level = webview()->zoomLevel();
+ 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));
+}
+
+void RenderView::OnSetZoomLevelForLoadingHost(std::string host,
+ int zoom_level) {
+ host_zoom_levels_[host] = 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 d53c998..57cc845 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -24,6 +24,7 @@
#include "chrome/common/edit_command.h"
#include "chrome/common/navigation_gesture.h"
#include "chrome/common/notification_type.h"
+#include "chrome/common/page_zoom.h"
#include "chrome/common/renderer_preferences.h"
#include "chrome/common/view_types.h"
#include "chrome/renderer/automation/dom_automation_controller.h"
@@ -451,6 +452,8 @@ class RenderView : public RenderWidget,
FRIEND_TEST(RenderViewTest, MacTestCmdUp);
#endif
+ typedef std::map<std::string, int> HostZoomLevels;
+
explicit RenderView(RenderThreadBase* render_thread,
const WebPreferences& webkit_preferences);
@@ -552,7 +555,8 @@ class RenderView : public RenderWidget,
void OnCancelDownload(int32 download_id);
void OnFind(int request_id, const string16&, const WebKit::WebFindOptions&);
void OnDeterminePageText();
- void OnZoom(int function);
+ void OnZoom(PageZoom::Function function);
+ void OnSetZoomLevelForLoadingHost(std::string host, int zoom_level);
void OnSetPageEncoding(const std::string& encoding_name);
void OnResetPageEncodingToDefault();
void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
@@ -1007,6 +1011,8 @@ class RenderView : public RenderWidget,
typedef std::map<WebKit::WebView*, RenderView*> ViewMap;
+ HostZoomLevels host_zoom_levels_;
+
DISALLOW_COPY_AND_ASSIGN(RenderView);
};
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index b7f5ed8..7d6451c 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -146,6 +146,7 @@ class TestingProfile : public Profile {
}
virtual net::SSLConfigService* GetSSLConfigService() { return NULL; }
virtual BlacklistManager* GetBlacklistManager() { return NULL; }
+ virtual HostZoomMap* GetHostZoomMap() { return NULL; }
void set_session_service(SessionService* session_service) {
session_service_ = session_service;
}
diff --git a/webkit/tools/test_shell/event_sending_controller.cc b/webkit/tools/test_shell/event_sending_controller.cc
index a14ffdf..e177bf7 100644
--- a/webkit/tools/test_shell/event_sending_controller.cc
+++ b/webkit/tools/test_shell/event_sending_controller.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.
@@ -616,25 +616,25 @@ void EventSendingController::DoLeapForward(int milliseconds) {
// WebKit/WebView/WebView.mm)
void EventSendingController::textZoomIn(
const CppArgumentList& args, CppVariant* result) {
- webview()->zoomIn(true);
+ webview()->setZoomLevel(true, webview()->zoomLevel() + 1);
result->SetNull();
}
void EventSendingController::textZoomOut(
const CppArgumentList& args, CppVariant* result) {
- webview()->zoomOut(true);
+ webview()->setZoomLevel(true, webview()->zoomLevel() - 1);
result->SetNull();
}
void EventSendingController::zoomPageIn(
const CppArgumentList& args, CppVariant* result) {
- webview()->zoomIn(false);
+ webview()->setZoomLevel(false, webview()->zoomLevel() + 1);
result->SetNull();
}
void EventSendingController::zoomPageOut(
const CppArgumentList& args, CppVariant* result) {
- webview()->zoomOut(false);
+ webview()->setZoomLevel(false, webview()->zoomLevel() - 1);
result->SetNull();
}
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc
index ecd92bb..bdac11f 100644
--- a/webkit/tools/test_shell/layout_test_controller.cc
+++ b/webkit/tools/test_shell/layout_test_controller.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.
@@ -425,7 +425,7 @@ void LayoutTestController::objCIdentityIsEqual(
void LayoutTestController::Reset() {
if (shell_) {
- shell_->webView()->zoomDefault();
+ shell_->webView()->setZoomLevel(false, 0);
shell_->webView()->setTabKeyCyclesThroughElements(true);
}
dump_as_text_ = false;