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

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 291677. 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 bfe1a9bb1fcb88fc6923f8f5f1a00889f289a833..2b2cb52224e42c8d2f00f928cfc39273579b7113 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -73,6 +73,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_store_impl.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
@@ -547,11 +548,6 @@ void ProfileImpl::DoFinalInit() {
prefs::kSupervisedUserId,
base::Bind(&ProfileImpl::UpdateProfileSupervisedUserIdCache,
base::Unretained(this)));
- pref_change_registrar_.Add(
- prefs::kDefaultZoomLevel,
- base::Bind(&ProfileImpl::OnDefaultZoomLevelChanged,
- base::Unretained(this)));
-
// Changes in the profile avatar.
pref_change_registrar_.Add(
prefs::kProfileAvatarIndex,
@@ -655,12 +651,11 @@ void ProfileImpl::DoFinalInit() {
session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES;
}
- InitHostZoomMap();
-
base::Callback<void(bool)> data_reduction_proxy_unavailable;
scoped_ptr<data_reduction_proxy::DataReductionProxyParams>
data_reduction_proxy_params;
scoped_ptr<DataReductionProxyChromeConfigurator> chrome_configurator;
+
#if defined(SPDY_PROXY_AUTH_ORIGIN)
DataReductionProxyChromeSettings* data_reduction_proxy_chrome_settings =
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(this);
@@ -768,53 +763,6 @@ void ProfileImpl::DoFinalInit() {
#endif
}
-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);
}
@@ -877,6 +825,12 @@ Profile::ProfileType ProfileImpl::GetProfileType() const {
return REGULAR_PROFILE;
}
+scoped_ptr<content::ZoomLevelPrefsStore>
+ProfileImpl::CreateZoomLevelPrefsStore() {
+ return scoped_ptr<content::ZoomLevelPrefsStore>(
+ new chrome::ZoomLevelPrefsStoreImpl);
+}
+
base::FilePath ProfileImpl::GetPath() const {
return path_;
}
@@ -1184,26 +1138,6 @@ history::TopSites* ProfileImpl::GetTopSitesWithoutCreating() {
return top_sites_.get();
}
-void ProfileImpl::OnDefaultZoomLevelChanged() {
- HostZoomMap::GetForBrowserContext(this)->SetDefaultZoomLevel(
- pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel));
-}
-
-void ProfileImpl::OnZoomLevelChanged(
- const HostZoomMap::ZoomLevelChange& change) {
-
- 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()))
- host_zoom_dictionary->RemoveWithoutPathExpansion(change.host, NULL);
- else
- host_zoom_dictionary->SetDoubleWithoutPathExpansion(change.host, level);
-}
-
#if defined(ENABLE_SESSION_SERVICE)
void ProfileImpl::StopCreateSessionServiceTimer() {
create_session_service_timer_.Stop();

Powered by Google App Engine
This is Rietveld 408576698