Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1861)

Unified Diff: chrome/browser/profiles/profile_impl.cc

Issue 393133002: Migrate HostZoomMap to live in StoragePartition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to r288093. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_impl.cc
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 8c67ad0498aefc23ea83aad6d7d1165bc2d50e8f..3dcdc4cdb8d24c0c73a25fa3de385c901dc2f1e4 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -70,6 +70,7 @@
#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h"
+#include "chrome/browser/ui/zoom/zoom_level_prefs_delegate_impl.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
@@ -619,8 +620,6 @@ void ProfileImpl::DoFinalInit() {
session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES;
}
- InitHostZoomMap();
-
// Make sure we initialize the ProfileIOData after everything else has been
// initialized that we might be reading from the IO thread.
@@ -690,53 +689,6 @@ void ProfileImpl::DoFinalInit() {
gcm::PushMessagingServiceImpl::InitializeForProfile(this);
}
-void ProfileImpl::InitHostZoomMap() {
- HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
- host_zoom_map->SetDefaultZoomLevel(
- prefs_->GetDouble(prefs::kDefaultZoomLevel));
-
- const base::DictionaryValue* host_zoom_dictionary =
- prefs_->GetDictionary(prefs::kPerHostZoomLevels);
- // Careful: The returned value could be NULL if the pref has never been set.
- if (host_zoom_dictionary != NULL) {
- std::vector<std::string> keys_to_remove;
- for (base::DictionaryValue::Iterator i(*host_zoom_dictionary); !i.IsAtEnd();
- i.Advance()) {
- const std::string& host(i.key());
- double zoom_level = 0;
-
- bool success = i.value().GetAsDouble(&zoom_level);
- DCHECK(success);
-
- // Filter out A) the empty host, B) zoom levels equal to the default; and
- // remember them, so that we can later erase them from Prefs.
- // Values of type A and B could have been stored due to crbug.com/364399.
- // Values of type B could further have been stored before the default zoom
- // level was set to its current value. In either case, SetZoomLevelForHost
- // will ignore type B values, thus, to have consistency with HostZoomMap's
- // internal state, these values must also be removed from Prefs.
- if (host.empty() ||
- content::ZoomValuesEqual(zoom_level,
- host_zoom_map->GetDefaultZoomLevel())) {
- keys_to_remove.push_back(host);
- continue;
- }
-
- host_zoom_map->SetZoomLevelForHost(host, zoom_level);
- }
-
- DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels);
- base::DictionaryValue* host_zoom_dictionary = update.Get();
- for (std::vector<std::string>::const_iterator it = keys_to_remove.begin();
- it != keys_to_remove.end(); ++it) {
- host_zoom_dictionary->RemoveWithoutPathExpansion(*it, NULL);
- }
- }
-
- zoom_subscription_ = host_zoom_map->AddZoomLevelChangedCallback(
- base::Bind(&ProfileImpl::OnZoomLevelChanged, base::Unretained(this)));
-}
-
base::FilePath ProfileImpl::last_selected_directory() {
return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory);
}
@@ -799,6 +751,14 @@ Profile::ProfileType ProfileImpl::GetProfileType() const {
return REGULAR_PROFILE;
}
+double ProfileImpl::GetDefaultZoomLevel() const {
+ return pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel);
+}
+
+content::ZoomLevelPrefsDelegate* ProfileImpl::CreateZoomLevelPrefsDelegate() {
+ return new browser::ZoomLevelPrefsDelegateImpl;
+}
+
base::FilePath ProfileImpl::GetPath() const {
return path_;
}
@@ -1107,8 +1067,7 @@ history::TopSites* ProfileImpl::GetTopSitesWithoutCreating() {
}
void ProfileImpl::OnDefaultZoomLevelChanged() {
- HostZoomMap::GetForBrowserContext(this)->SetDefaultZoomLevel(
- pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel));
+ BrowserContext::SetDefaultZoomLevel(this, GetDefaultZoomLevel());
}
void ProfileImpl::OnZoomLevelChanged(
@@ -1116,11 +1075,10 @@ void ProfileImpl::OnZoomLevelChanged(
if (change.mode != HostZoomMap::ZOOM_CHANGED_FOR_HOST)
return;
- HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
double level = change.zoom_level;
DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels);
base::DictionaryValue* host_zoom_dictionary = update.Get();
- if (content::ZoomValuesEqual(level, host_zoom_map->GetDefaultZoomLevel()))
+ if (content::ZoomValuesEqual(level, GetDefaultZoomLevel()))
host_zoom_dictionary->RemoveWithoutPathExpansion(change.host, NULL);
else
host_zoom_dictionary->SetDoubleWithoutPathExpansion(change.host, level);

Powered by Google App Engine
This is Rietveld 408576698