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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // 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.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/stub_cros_settings_provider.h"
6
7 #include "base/logging.h"
8 #include "base/values.h"
9 #include "chrome/browser/chromeos/cros_settings.h"
10 #include "chrome/browser/chromeos/cros_settings_names.h"
11 #include "chrome/browser/chromeos/login/user_manager.h"
12
13 namespace chromeos {
14
15 namespace {
16
17 const char* kHandledSettings[] = {
18 kAccountsPrefAllowGuest,
19 kAccountsPrefAllowNewUser,
20 kAccountsPrefShowUserNamesOnSignIn,
21 kAccountsPrefUsers,
22 kDeviceOwner,
23 kReleaseChannel,
24 kSettingProxyEverywhere,
25 kSignedDataRoamingEnabled,
26 kStatsReportingPref
27 };
28
29 } // namespace
30
31 StubCrosSettingsProvider::StubCrosSettingsProvider() {
32 SetDefaults();
33 }
34
35 StubCrosSettingsProvider::~StubCrosSettingsProvider() {
36 }
37
38 const base::Value* StubCrosSettingsProvider::Get(
39 const std::string& path) const {
40 DCHECK(HandlesSetting(path));
41 const base::Value* value;
42 if (values_.GetValue(path, &value))
43 return value;
44 return NULL;
45 }
46
47 bool StubCrosSettingsProvider::GetTrusted(const std::string& path,
48 const base::Closure& callback) {
49 // We don't have a trusted store so all values are available immediately.
50 return true;
51 }
52
53 bool StubCrosSettingsProvider::HandlesSetting(const std::string& path) const {
54 const char** end = kHandledSettings + arraysize(kHandledSettings);
55 return std::find(kHandledSettings, end, path) != end;
56 }
57
58 void StubCrosSettingsProvider::Reload() {
59 }
60
61 void StubCrosSettingsProvider::DoSet(const std::string& path,
62 const base::Value& value) {
63 values_.SetValue(path, value.DeepCopy());
64 CrosSettings::Get()->FireObservers(path.c_str());
65 }
66
67 void StubCrosSettingsProvider::SetDefaults() {
68 values_.SetBoolean(kAccountsPrefAllowGuest, true);
69 values_.SetBoolean(kAccountsPrefAllowNewUser, true);
70 values_.SetBoolean(kAccountsPrefShowUserNamesOnSignIn, true);
71 // |kDeviceOwner| will be set to the logged-in user by |UserManager|.
72 }
73
74 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698