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

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

Issue 2935011: Initial accounts options page. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: use ListItem directly for now per arv Created 10 years, 5 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
diff --git a/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc b/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..889a85dfb47c1d6b9b4dc068cb957243140e537a
--- /dev/null
+++ b/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.h"
+
+#include "base/json/json_reader.h"
+#include "base/string_util.h"
+#include "chrome/browser/chromeos/cros_settings.h"
+
+namespace chromeos {
+
+Value* CoreChromeOSOptionsHandler::FetchPref(const std::wstring& pref_name) {
+ if (!CrosSettings::IsCrosSettings(pref_name))
+ return ::CoreOptionsHandler::FetchPref(pref_name);
+
+ Value* pref_value = NULL;
+ CrosSettings::Get()->Get(pref_name, &pref_value);
+ return pref_value ? pref_value->DeepCopy() : Value::CreateNullValue();
+}
+
+void CoreChromeOSOptionsHandler::ObservePref(const std::wstring& pref_name) {
+ if (!CrosSettings::IsCrosSettings(pref_name))
+ return ::CoreOptionsHandler::ObservePref(pref_name);
+
+ // TODO(xiyuan): Change this when CrosSettings supports observers.
+}
+
+void CoreChromeOSOptionsHandler::SetPref(const std::wstring& pref_name,
+ Value::ValueType pref_type,
+ const std::string& value_string) {
+ if (!CrosSettings::IsCrosSettings(pref_name))
+ return ::CoreOptionsHandler::SetPref(pref_name, pref_type, value_string);
+
+ CrosSettings* cros_settings = CrosSettings::Get();
+ switch (pref_type) {
+ case Value::TYPE_BOOLEAN:
+ cros_settings->SetBoolean(pref_name, value_string == "true");
+ break;
+ case Value::TYPE_INTEGER:
+ int int_value;
+ if (StringToInt(value_string, &int_value))
+ cros_settings->SetInteger(pref_name, int_value);
+ break;
+ case Value::TYPE_STRING:
+ cros_settings->SetString(pref_name, value_string);
+ break;
+ default: {
+ Value* pref_value = base::JSONReader().JsonToValue(
+ value_string, // JSON
+ false, // no check_root
+ false); // no trailing comma
+ if (pref_value)
+ cros_settings->Set(pref_name, pref_value);
+ break;
+ }
+ }
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.h ('k') | chrome/browser/chromeos/mock_cros_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698