summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-23 23:53:00 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-23 23:53:00 +0000
commit89805c18c0ce6ab0e5c68d58688921b7d3340236 (patch)
tree3b2e22880285173c4a811b28f7a9b81c70549cb0 /content
parent149b7affaa3ece75d56ddfcf1177bf45c17182e5 (diff)
downloadchromium_src-89805c18c0ce6ab0e5c68d58688921b7d3340236.zip
chromium_src-89805c18c0ce6ab0e5c68d58688921b7d3340236.tar.gz
chromium_src-89805c18c0ce6ab0e5c68d58688921b7d3340236.tar.bz2
Remove Profile code from HostZoomMap.
BUG=76788 Review URL: http://codereview.chromium.org/7067005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86367 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/DEPS1
-rw-r--r--content/browser/host_zoom_map.cc46
-rw-r--r--content/browser/host_zoom_map.h7
-rw-r--r--content/browser/renderer_host/render_message_filter.cc37
-rw-r--r--content/browser/renderer_host/render_message_filter.h14
-rw-r--r--content/browser/renderer_host/render_view_host.h1
-rw-r--r--content/common/notification_type.h4
7 files changed, 10 insertions, 100 deletions
diff --git a/content/browser/DEPS b/content/browser/DEPS
index 8b300cf..511995f 100644
--- a/content/browser/DEPS
+++ b/content/browser/DEPS
@@ -55,7 +55,6 @@ include_rules = [
"+chrome/browser/prefs/pref_change_registrar.h",
"+chrome/browser/prefs/pref_service.h",
- "+chrome/browser/prefs/scoped_user_pref_update.h",
"+chrome/common/pref_names.h",
# http://crbug.com/77090
diff --git a/content/browser/host_zoom_map.cc b/content/browser/host_zoom_map.cc
index dc7b227..101bb28 100644
--- a/content/browser/host_zoom_map.cc
+++ b/content/browser/host_zoom_map.cc
@@ -8,10 +8,6 @@
#include "base/string_piece.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/prefs/scoped_user_pref_update.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/pref_names.h"
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
@@ -22,30 +18,10 @@
using WebKit::WebView;
-HostZoomMap::HostZoomMap(Profile* profile)
- : profile_(profile), default_zoom_level_(0.0) {
-
+HostZoomMap::HostZoomMap() : default_zoom_level_(0.0) {
registrar_.Add(
this, NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW,
NotificationService::AllSources());
-
- base::AutoLock auto_lock(lock_);
- host_zoom_levels_.clear();
- 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) {
- const std::string& host(*i);
- double zoom_level = 0;
-
- bool success = host_zoom_dictionary->GetDoubleWithoutPathExpansion(
- host, &zoom_level);
- DCHECK(success);
- host_zoom_levels_[host] = zoom_level;
- }
- }
}
double HostZoomMap::GetZoomLevel(const GURL& url) const {
@@ -69,22 +45,8 @@ void HostZoomMap::SetZoomLevel(const GURL& url, double level) {
}
NotificationService::current()->Notify(NotificationType::ZOOM_LEVEL_CHANGED,
- Source<Profile>(profile_),
- NotificationService::NoDetails());
-
- // If we're in incognito mode, don't persist changes to the prefs. We'll keep
- // them in memory only so they will be forgotten on exiting incognito.
- if (profile_->IsOffTheRecord())
- return;
-
- DictionaryPrefUpdate update(profile_->GetPrefs(), prefs::kPerHostZoomLevels);
- DictionaryValue* host_zoom_dictionary = update.Get();
- if (level == default_zoom_level_) {
- host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL);
- } else {
- host_zoom_dictionary->SetWithoutPathExpansion(
- host, Value::CreateDoubleValue(level));
- }
+ Source<HostZoomMap>(this),
+ Details<const std::string>(&host));
}
double HostZoomMap::GetTemporaryZoomLevel(int render_process_id,
@@ -129,7 +91,7 @@ void HostZoomMap::SetTemporaryZoomLevel(int render_process_id,
}
NotificationService::current()->Notify(NotificationType::ZOOM_LEVEL_CHANGED,
- Source<Profile>(profile_),
+ Source<HostZoomMap>(this),
NotificationService::NoDetails());
}
diff --git a/content/browser/host_zoom_map.h b/content/browser/host_zoom_map.h
index 7631dd8..3ae44a1 100644
--- a/content/browser/host_zoom_map.h
+++ b/content/browser/host_zoom_map.h
@@ -21,7 +21,6 @@
#include "content/common/notification_registrar.h"
class GURL;
-class Profile;
// HostZoomMap needs to be deleted on the UI thread because it listens
// to notifications on there (and holds a NotificationRegistrar).
@@ -30,7 +29,7 @@ class HostZoomMap :
public base::RefCountedThreadSafe<HostZoomMap,
BrowserThread::DeleteOnUIThread> {
public:
- explicit HostZoomMap(Profile* profile);
+ HostZoomMap();
// Returns the zoom level for a given url. The zoom level is determined by
// the host portion of the URL, or (in the absence of a host) the complete
@@ -69,6 +68,7 @@ class HostZoomMap :
const NotificationSource& source,
const NotificationDetails& details);
+ double default_zoom_level() const { return default_zoom_level_; }
void set_default_zoom_level(double level) { default_zoom_level_ = level; }
private:
@@ -79,9 +79,6 @@ class HostZoomMap :
~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_;
double default_zoom_level_;
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index e94b6a1..0f7d310 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -28,7 +28,6 @@
#include "content/browser/browser_thread.h"
#include "content/browser/child_process_security_policy.h"
#include "content/browser/content_browser_client.h"
-#include "content/browser/host_zoom_map.h"
#include "content/browser/plugin_process_host.h"
#include "content/browser/plugin_service.h"
#include "content/browser/ppapi_plugin_process_host.h"
@@ -292,7 +291,6 @@ RenderMessageFilter::RenderMessageFilter(
notification_prefs_(
DesktopNotificationServiceFactory::GetForProfile(profile)->
prefs_cache()),
- host_zoom_map_(profile->GetHostZoomMap()),
incognito_(profile->IsOffTheRecord()),
webkit_context_(profile->GetWebKitContext()),
render_process_id_(render_process_id) {
@@ -375,7 +373,6 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER(ViewHostMsg_RevealFolderInOS, OnRevealFolderInOS)
IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateSharedMemoryBuffer,
OnAllocateSharedMemoryBuffer)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL)
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(ViewHostMsg_AllocTransportDIB, OnAllocTransportDIB)
IPC_MESSAGE_HANDLER(ViewHostMsg_FreeTransportDIB, OnFreeTransportDIB)
@@ -674,40 +671,6 @@ void RenderMessageFilter::OnAllocateSharedMemoryBuffer(
shared_buf.GiveToProcess(peer_handle(), handle);
}
-void RenderMessageFilter::OnDidZoomURL(const IPC::Message& message,
- double zoom_level,
- bool remember,
- const GURL& url) {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &RenderMessageFilter::UpdateHostZoomLevelsOnUIThread,
- zoom_level, remember, url, render_process_id_, message.routing_id()));
-}
-
-void RenderMessageFilter::UpdateHostZoomLevelsOnUIThread(
- double zoom_level,
- bool remember,
- const GURL& url,
- int render_process_id,
- int render_view_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (remember) {
- host_zoom_map_->SetZoomLevel(url, zoom_level);
- // Notify renderers from this profile.
- 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_SetZoomLevelForCurrentURL(url, zoom_level));
- }
- }
- } else {
- host_zoom_map_->SetTemporaryZoomLevel(
- render_process_id, render_view_id, zoom_level);
- }
-}
-
net::URLRequestContext* RenderMessageFilter::GetRequestContextForURL(
const GURL& url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h
index d1702c0..ab7f84b 100644
--- a/content/browser/renderer_host/render_message_filter.h
+++ b/content/browser/renderer_host/render_message_filter.h
@@ -29,7 +29,6 @@
struct FontDescriptor;
class ExtensionInfoMap;
class HostContentSettingsMap;
-class HostZoomMap;
class NotificationsPrefsCache;
class Profile;
class RenderWidgetHelper;
@@ -180,16 +179,6 @@ class RenderMessageFilter : public BrowserMessageFilter {
// in the renderer on POSIX due to the sandbox.
void OnAllocateSharedMemoryBuffer(uint32 buffer_size,
base::SharedMemoryHandle* handle);
- void OnDidZoomURL(const IPC::Message& message,
- double zoom_level,
- bool remember,
- const GURL& url);
- void UpdateHostZoomLevelsOnUIThread(double zoom_level,
- bool remember,
- const GURL& url,
- int render_process_id,
- int render_view_id);
-
void OnResolveProxy(const GURL& url, IPC::Message* reply_msg);
// Browser side transport DIB allocation
@@ -254,9 +243,6 @@ class RenderMessageFilter : public BrowserMessageFilter {
// Desktop Notifications permission messages.
scoped_refptr<NotificationsPrefsCache> notification_prefs_;
- // Handles zoom-related messages.
- scoped_refptr<HostZoomMap> host_zoom_map_;
-
// Whether this process is used for incognito tabs.
bool incognito_;
diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h
index bd2e06c..9544061 100644
--- a/content/browser/renderer_host/render_view_host.h
+++ b/content/browser/renderer_host/render_view_host.h
@@ -444,6 +444,7 @@ class RenderViewHost : public RenderWidgetHost {
void OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params);
void OnScriptEvalResponse(int id, const ListValue& result);
+ void OnDidZoomURL(double zoom_level, bool remember, const GURL& url);
#if defined(OS_MACOSX)
void OnMsgShowPopup(const ViewHostMsg_ShowPopup_Params& params);
diff --git a/content/common/notification_type.h b/content/common/notification_type.h
index 5b73578..ad81546 100644
--- a/content/common/notification_type.h
+++ b/content/common/notification_type.h
@@ -1259,7 +1259,9 @@ class NotificationType {
BOOKMARK_CONTEXT_MENU_SHOWN,
#endif
- // Sent when the zoom level changes. The source is the profile.
+ // Sent when the zoom level changes. The source is the HostZoomMap. The
+ // details is a string of the hostname for which the zoom changed. In case
+ // of a temporary zoom level change, the details is an empty string.
ZOOM_LEVEL_CHANGED,
// Sent when the tab's closeable state has changed due to increase/decrease