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

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: fixes 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..2946e770e24a5b1f46dccde5701496752157d5ea 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -323,7 +323,9 @@ ProfileImpl::ProfileImpl(
Delegate* delegate,
CreateMode create_mode,
base::SequencedTaskRunner* sequenced_task_runner)
- : path_(path),
+ : zoom_callback_(base::Bind(&ProfileImpl::OnZoomLevelChanged,
+ base::Unretained(this))),
+ path_(path),
ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)),
host_content_settings_map_(NULL),
last_session_exit_type_(EXIT_NORMAL),
@@ -568,8 +570,7 @@ void ProfileImpl::InitHostZoomMap() {
}
}
- registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
- content::Source<HostZoomMap>(host_zoom_map));
+ host_zoom_map->AddZoomLevelChangedCallback(zoom_callback_);
}
FilePath ProfileImpl::last_selected_directory() {
@@ -583,6 +584,9 @@ void ProfileImpl::set_last_selected_directory(const FilePath& path) {
ProfileImpl::~ProfileImpl() {
MaybeSendDestroyedNotification();
+ HostZoomMap::GetForBrowserContext(this)->RemoveZoomLevelChangedCallback(
+ zoom_callback_);
+
bool prefs_loaded = prefs_->GetInitializationStatus() !=
PrefService::INITIALIZATION_STATUS_WAITING;
@@ -924,23 +928,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();
}
@@ -951,6 +938,21 @@ void ProfileImpl::OnDefaultZoomLevelChanged() {
pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel));
}
+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));
+ }
+}
+
#if defined(ENABLE_SESSION_SERVICE)
void ProfileImpl::StopCreateSessionServiceTimer() {
create_session_service_timer_.Stop();

Powered by Google App Engine
This is Rietveld 408576698