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

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

Issue 12039058: content: convert zoom notifications to observer usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 695e92e9f2c79145d89e436bcff37e1636172aaf..b35b92a6cd904041c9784a1d1cf0a8ba887c9d46 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -568,8 +568,7 @@ void ProfileImpl::InitHostZoomMap() {
}
}
- registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
- content::Source<HostZoomMap>(host_zoom_map));
+ content::HostZoomMap::Observer::Observe(host_zoom_map);
}
FilePath ProfileImpl::last_selected_directory() {
@@ -914,6 +913,21 @@ history::TopSites* ProfileImpl::GetTopSitesWithoutCreating() {
return top_sites_;
}
+void ProfileImpl::OnZoomLevelChanged(const std::string& host) {
+ if (host.empty())
+ return;
+ HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
+ double level = host_zoom_map->GetZoomLevel(host);
+ DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels);
+ DictionaryValue* host_zoom_dictionary = update.Get();
+ if (level == host_zoom_map->GetDefaultZoomLevel()) {
+ host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL);
+ } else {
+ host_zoom_dictionary->SetWithoutPathExpansion(
+ host, Value::CreateDoubleValue(level));
+ }
+}
+
void ProfileImpl::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
@@ -924,23 +938,6 @@ void ProfileImpl::Observe(int type,
registrar_.Remove(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED,
content::Source<Profile>(this));
break;
- case content::NOTIFICATION_ZOOM_LEVEL_CHANGED: {
- const std::string& host =
- *(content::Details<const std::string>(details).ptr());
- if (!host.empty()) {
- HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
- double level = host_zoom_map->GetZoomLevel(host);
- DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels);
- DictionaryValue* host_zoom_dictionary = update.Get();
- if (level == host_zoom_map->GetDefaultZoomLevel()) {
- host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL);
- } else {
- host_zoom_dictionary->SetWithoutPathExpansion(
- host, Value::CreateDoubleValue(level));
- }
- }
- break;
- }
default:
NOTREACHED();
}

Powered by Google App Engine
This is Rietveld 408576698