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

Unified Diff: chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc

Issue 3143009: Reenabled ChromeOS system setting for timezone selection.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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/chromeos/dom_ui/core_chromeos_options_handler.cc
===================================================================
--- chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc (revision 56142)
+++ chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc (working copy)
@@ -7,6 +7,7 @@
#include "base/json/json_reader.h"
#include "base/string_number_conversions.h"
#include "chrome/browser/chromeos/cros_settings.h"
+#include "chrome/common/notification_service.h"
namespace chromeos {
@@ -24,6 +25,7 @@
return ::CoreOptionsHandler::ObservePref(pref_name);
// TODO(xiyuan): Change this when CrosSettings supports observers.
+ CrosSettings::Get()->AddSettingsObserver(pref_name.c_str(), this);
}
void CoreChromeOSOptionsHandler::SetPref(const std::string& pref_name,
@@ -57,4 +59,38 @@
}
}
+void CoreChromeOSOptionsHandler::Observe(NotificationType type,
+ const NotificationSource& source,
dhg 2010/08/16 15:57:21 indent
+ const NotificationDetails& details) {
+ if (type == NotificationType::SYSTEM_SETTING_CHANGED) {
+ NotifySettingsChanged(Details<std::string>(details).ptr());
+ return;
+ }
+ ::CoreOptionsHandler::Observe(type, source, details);
+}
+
+void CoreChromeOSOptionsHandler::NotifySettingsChanged(
+ const std::string* setting_name) {
+ DCHECK(dom_ui_);
+ DCHECK(CrosSettings::Get()->IsCrosSettings(*setting_name));
+ Value* value = NULL;
+ if (!CrosSettings::Get()->Get(*setting_name, &value)) {
+ NOTREACHED();
+ if (value)
+ delete value;
+ return;
+ }
+ for (PreferenceCallbackMap::const_iterator iter =
+ pref_callback_map_.find(*setting_name);
+ iter != pref_callback_map_.end(); ++iter) {
+ const std::wstring& callback_function = iter->second;
+ ListValue result_value;
+ result_value.Append(Value::CreateStringValue(setting_name->c_str()));
+ result_value.Append(value->DeepCopy());
+ dom_ui_->CallJavascriptFunction(callback_function, result_value);
+ }
+ if (value)
+ delete value;
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698