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

Unified Diff: chrome/browser/dom_ui/core_options_handler.cc

Issue 3304015: Use PrefChangeRegistrar everywhere (Closed)
Patch Set: final version for commit Created 10 years, 3 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
« no previous file with comments | « chrome/browser/dom_ui/core_options_handler.h ('k') | chrome/browser/dom_ui/ntp_resource_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/core_options_handler.cc
diff --git a/chrome/browser/dom_ui/core_options_handler.cc b/chrome/browser/dom_ui/core_options_handler.cc
index 2739ebc3515518834dccdb75a8234fe4b938cb8c..849e768bbe01ea0353ec32633ffb043601a1ddb7 100644
--- a/chrome/browser/dom_ui/core_options_handler.cc
+++ b/chrome/browser/dom_ui/core_options_handler.cc
@@ -88,6 +88,13 @@ void CoreOptionsHandler::Uninitialize() {
}
}
+DOMMessageHandler* CoreOptionsHandler::Attach(DOMUI* dom_ui) {
+ DOMMessageHandler* result = DOMMessageHandler::Attach(dom_ui);
+ DCHECK(dom_ui_);
+ registrar_.Init(dom_ui_->GetProfile()->GetPrefs());
+ return result;
+}
+
void CoreOptionsHandler::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -138,9 +145,7 @@ Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) {
}
void CoreOptionsHandler::ObservePref(const std::string& pref_name) {
- DCHECK(dom_ui_);
- PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs();
- pref_service->AddPrefObserver(pref_name.c_str(), this);
+ registrar_.Add(pref_name.c_str(), this);
}
void CoreOptionsHandler::SetPref(const std::string& pref_name,
@@ -185,9 +190,7 @@ void CoreOptionsHandler::ProcessUserMetric(Value::ValueType pref_type,
}
void CoreOptionsHandler::StopObservingPref(const std::string& path) {
- DCHECK(dom_ui_);
- PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs();
- pref_service->RemovePrefObserver(path.c_str(), this);
+ registrar_.Remove(path.c_str(), this);
}
void CoreOptionsHandler::HandleFetchPrefs(const ListValue* args) {
« no previous file with comments | « chrome/browser/dom_ui/core_options_handler.h ('k') | chrome/browser/dom_ui/ntp_resource_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698