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

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: callbacks 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..79aa120a202e26f8db16a510be1f713ffd77fe36 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -568,8 +568,9 @@ void ProfileImpl::InitHostZoomMap() {
}
}
- registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
- content::Source<HostZoomMap>(host_zoom_map));
+ host_zoom_map->AddZoomLevelChangedCallback(
+ base::Bind(&ProfileImpl::OnZoomLevelChanged,
+ base::Unretained(this)));
}
FilePath ProfileImpl::last_selected_directory() {
@@ -583,6 +584,10 @@ void ProfileImpl::set_last_selected_directory(const FilePath& path) {
ProfileImpl::~ProfileImpl() {
MaybeSendDestroyedNotification();
+ HostZoomMap::GetForBrowserContext(this)->RemoveZoomLevelChangedCallback(
+ base::Bind(&ProfileImpl::OnZoomLevelChanged,
+ base::Unretained(this)));
+
bool prefs_loaded = prefs_->GetInitializationStatus() !=
PrefService::INITIALIZATION_STATUS_WAITING;
@@ -914,6 +919,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 +944,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