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

Unified Diff: chrome/browser/chromeos/stub_cros_settings_provider.cc

Issue 8899002: [cros] Add --stub-cros-settings option for testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 9 years 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/stub_cros_settings_provider.cc
diff --git a/chrome/browser/chromeos/stub_cros_settings_provider.cc b/chrome/browser/chromeos/stub_cros_settings_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b4690e765cc221fb75ea688a39a969400ecfc3ee
--- /dev/null
+++ b/chrome/browser/chromeos/stub_cros_settings_provider.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 2011 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/stub_cros_settings_provider.h"
+
+#include "base/logging.h"
+#include "base/values.h"
+#include "chrome/browser/chromeos/cros_settings.h"
+#include "chrome/browser/chromeos/cros_settings_names.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
+
+namespace chromeos {
+
+namespace {
+
+const char* kHandledSettings[] = {
+ kAccountsPrefAllowGuest,
+ kAccountsPrefAllowNewUser,
+ kAccountsPrefShowUserNamesOnSignIn,
+ kAccountsPrefUsers,
+ kDeviceOwner,
+ kReleaseChannel,
+ kSettingProxyEverywhere,
+ kSignedDataRoamingEnabled,
+ kStatsReportingPref
+};
+
+} // namespace
+
+StubCrosSettingsProvider::StubCrosSettingsProvider(
+ const NotifyObserversCallback& notify_cb)
+ : CrosSettingsProvider(notify_cb) {
+ SetDefaults();
+}
+
+StubCrosSettingsProvider::~StubCrosSettingsProvider() {
+}
+
+const base::Value* StubCrosSettingsProvider::Get(
+ const std::string& path) const {
+ DCHECK(HandlesSetting(path));
+ const base::Value* value;
+ if (values_.GetValue(path, &value))
+ return value;
+ return NULL;
+}
+
+bool StubCrosSettingsProvider::GetTrusted(const std::string& path,
+ const base::Closure& callback) {
+ // We don't have a trusted store so all values are available immediately.
+ return true;
+}
+
+bool StubCrosSettingsProvider::HandlesSetting(const std::string& path) const {
+ const char** end = kHandledSettings + arraysize(kHandledSettings);
+ return std::find(kHandledSettings, end, path) != end;
+}
+
+void StubCrosSettingsProvider::Reload() {
+}
+
+void StubCrosSettingsProvider::DoSet(const std::string& path,
+ const base::Value& value) {
+ values_.SetValue(path, value.DeepCopy());
+ NotifyObservers(path);
+}
+
+void StubCrosSettingsProvider::SetDefaults() {
+ values_.SetBoolean(kAccountsPrefAllowGuest, true);
+ values_.SetBoolean(kAccountsPrefAllowNewUser, true);
+ values_.SetBoolean(kAccountsPrefShowUserNamesOnSignIn, true);
+ // |kDeviceOwner| will be set to the logged-in user by |UserManager|.
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/stub_cros_settings_provider.h ('k') | chrome/browser/chromeos/stub_cros_settings_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698