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

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: 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..56856ead808986901c614025bc80dc6d9c91783b
--- /dev/null
+++ b/chrome/browser/chromeos/stub_cros_settings_provider.cc
@@ -0,0 +1,74 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
Nikita (slow) 2011/12/12 11:04:57 Please add unittest for this class.
Ivan Korotkov 2011/12/13 13:15:09 Done.
+// 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() {
+ 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());
+ CrosSettings::Get()->FireObservers(path.c_str());
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698