summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 01:09:33 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 01:09:33 +0000
commit779c33638f4b10def2d103f4703fa5bf58899aec (patch)
tree7034c81d156706a56b8101d507c87cc7045e9cc9
parent12cbfda3f72e24147789eed981e68c373ba1c14f (diff)
downloadchromium_src-779c33638f4b10def2d103f4703fa5bf58899aec.zip
chromium_src-779c33638f4b10def2d103f4703fa5bf58899aec.tar.gz
chromium_src-779c33638f4b10def2d103f4703fa5bf58899aec.tar.bz2
A few fixes for the HostZoomMap:
* Persist changes from Incognito (per UI leads) * Clear the zoom settings when the user does "reset to defaults" in prefs BUG=none TEST=Open incognito, change a zoom level, restart, see that it's persisted Review URL: http://codereview.chromium.org/551213 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37595 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/host_zoom_map.cc28
-rw-r--r--chrome/browser/host_zoom_map.h9
-rw-r--r--chrome/browser/options_util.cc2
-rw-r--r--chrome/browser/profile.cc8
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc6
5 files changed, 28 insertions, 25 deletions
diff --git a/chrome/browser/host_zoom_map.cc b/chrome/browser/host_zoom_map.cc
index 2c6393ca..88afb92 100644
--- a/chrome/browser/host_zoom_map.cc
+++ b/chrome/browser/host_zoom_map.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -51,19 +51,23 @@ void HostZoomMap::SetZoomLevel(const std::string& host, int level) {
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));
- }
+ 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));
}
}
+void HostZoomMap::ResetToDefaults() {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+
+ host_zoom_levels_.clear();
+ profile_->GetPrefs()->ClearPref(prefs::kPerHostZoomLevels);
+}
+
HostZoomMap::~HostZoomMap() {
}
diff --git a/chrome/browser/host_zoom_map.h b/chrome/browser/host_zoom_map.h
index 1cf86be..f64ca6b 100644
--- a/chrome/browser/host_zoom_map.h
+++ b/chrome/browser/host_zoom_map.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
+// any thread. One instance per profile.
#ifndef CHROME_BROWSER_HOST_ZOOM_MAP_H_
#define CHROME_BROWSER_HOST_ZOOM_MAP_H_
@@ -38,6 +38,11 @@ class HostZoomMap : public base::RefCountedThreadSafe<HostZoomMap> {
// This should only be called on the UI thread.
void SetZoomLevel(const std::string& host, int level);
+ // Resets all zoom levels.
+ //
+ // This should only be called on the UI thread.
+ void ResetToDefaults();
+
private:
friend class base::RefCountedThreadSafe<HostZoomMap>;
diff --git a/chrome/browser/options_util.cc b/chrome/browser/options_util.cc
index 6562c3d..9ef6f60 100644
--- a/chrome/browser/options_util.cc
+++ b/chrome/browser/options_util.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/host_content_settings_map.h"
+#include "chrome/browser/host_zoom_map.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
@@ -66,6 +67,7 @@ void OptionsUtil::ResetToDefaults(Profile* profile) {
};
profile->GetDownloadManager()->ResetAutoOpenFiles();
profile->GetHostContentSettingsMap()->ResetToDefaults();
+ profile->GetHostZoomMap()->ResetToDefaults();
for (size_t i = 0; i < arraysize(kUserPrefs); ++i)
prefs->ClearPref(kUserPrefs[i]);
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index c197a78..4e83acd 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -415,11 +415,7 @@ class OffTheRecordProfileImpl : public Profile,
}
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();
+ return profile_->GetHostZoomMap();
}
virtual Blacklist* GetPrivacyBlacklist() {
@@ -546,8 +542,6 @@ class OffTheRecordProfileImpl : public Profile,
scoped_ptr<HostContentSettingsMap> host_content_settings_map_;
- scoped_refptr<HostZoomMap> host_zoom_map_;
-
// The download manager that only stores downloaded items in memory.
scoped_refptr<DownloadManager> download_manager_;
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index dcf5d30..51d4aae 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -899,10 +899,8 @@ void ResourceMessageFilter::UpdateHostZoomLevelsOnUIThread(
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));
- }
+ render_process_host->Send(
+ new ViewMsg_SetZoomLevelForCurrentHost(host, zoom_level));
}
}