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

Unified Diff: chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc

Issue 23494053: Remove NOTIFICATION_SYSTEM_SETTING_CHANGED, switch CrosSettings to base::CallbackRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 7 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
Index: chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
index 7ef79d1255778914daa0d6f57006eb8b9f578af0..cfd738a90322420e9c6f48f5689ab220bc23347d 100644
--- a/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
@@ -167,7 +167,16 @@ void CoreChromeOSOptionsHandler::ObservePref(const std::string& pref_name) {
}
if (!CrosSettings::IsCrosSettings(pref_name))
return ::options::CoreOptionsHandler::ObservePref(pref_name);
- CrosSettings::Get()->AddSettingsObserver(pref_name.c_str(), this);
+
+ scoped_ptr<CrosSettings::ObserverSubscription> subscription =
+ CrosSettings::Get()->AddSettingsObserver(
+ pref_name.c_str(),
+ base::Bind(&CoreChromeOSOptionsHandler::NotifySettingsChanged,
+ base::Unretained(this),
+ pref_name));
+ linked_ptr<CrosSettings::ObserverSubscription> subscription_linked(
+ subscription.release());
Mattias Nissler (ping if slow) 2013/09/18 09:09:48 Shouldn't you be able to just declare |subscriptio
Avi (use Gerrit) 2013/09/18 16:41:44 Done.
+ pref_subscription_map_.insert(make_pair(pref_name, subscription_linked));
}
void CoreChromeOSOptionsHandler::SetPref(const std::string& pref_name,
@@ -195,7 +204,7 @@ void CoreChromeOSOptionsHandler::StopObservingPref(const std::string& path) {
return; // We unregister those in the destructor.
// Unregister this instance from observing prefs of chrome os settings.
if (CrosSettings::IsCrosSettings(path))
- CrosSettings::Get()->RemoveSettingsObserver(path.c_str(), this);
+ pref_subscription_map_.erase(path);
else // Call base class to handle regular preferences.
::options::CoreOptionsHandler::StopObservingPref(path);
}
@@ -208,17 +217,6 @@ void CoreChromeOSOptionsHandler::GetLocalizedValues(
AddAccountUITweaksLocalizedValues(localized_strings);
}
-void CoreChromeOSOptionsHandler::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) {
- NotifySettingsChanged(content::Details<std::string>(details).ptr());
- return;
- }
- ::options::CoreOptionsHandler::Observe(type, source, details);
-}
-
void CoreChromeOSOptionsHandler::SelectNetworkCallback(
const base::ListValue* args) {
std::string service_path;
@@ -252,12 +250,12 @@ void CoreChromeOSOptionsHandler::OnPreferenceChanged(
}
void CoreChromeOSOptionsHandler::NotifySettingsChanged(
- const std::string* setting_name) {
- DCHECK(CrosSettings::Get()->IsCrosSettings(*setting_name));
- scoped_ptr<base::Value> value(FetchPref(*setting_name));
+ const std::string& setting_name) {
+ DCHECK(CrosSettings::Get()->IsCrosSettings(setting_name));
+ scoped_ptr<base::Value> value(FetchPref(setting_name));
if (!value.get())
NOTREACHED();
- DispatchPrefChangeNotification(*setting_name, value.Pass());
+ DispatchPrefChangeNotification(setting_name, value.Pass());
}
void CoreChromeOSOptionsHandler::NotifyProxyPrefsChanged() {

Powered by Google App Engine
This is Rietveld 408576698