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(); |
} |