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

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: Remove ref counts, improve comments. 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 557912c456ca5e219b09193bed6709e443dfd9cc..17b006c5d3f3aa5152aacf0037e9752a7698868a 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -71,6 +71,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"
@@ -627,11 +628,10 @@ 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;
+
#if defined(SPDY_PROXY_AUTH_ORIGIN)
DataReductionProxyChromeSettings* data_reduction_proxy_chrome_settings =
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(this);
@@ -724,53 +724,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);
}
@@ -833,6 +786,16 @@ Profile::ProfileType ProfileImpl::GetProfileType() const {
return REGULAR_PROFILE;
}
+double ProfileImpl::GetDefaultZoomLevel() const {
+ return pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel);
+}
+
+scoped_ptr<content::ZoomLevelPrefsDelegate>
+ProfileImpl::CreateZoomLevelPrefsDelegate() {
+ return scoped_ptr<content::ZoomLevelPrefsDelegate>(
+ new browser::ZoomLevelPrefsDelegateImpl);
+}
+
base::FilePath ProfileImpl::GetPath() const {
return path_;
}
@@ -1141,8 +1104,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(
@@ -1150,11 +1112,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