1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/stub_cros_settings_provider.h"
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"
17 const char* kHandledSettings
[] = {
18 kAccountsPrefAllowGuest
,
19 kAccountsPrefAllowNewUser
,
20 kAccountsPrefShowUserNamesOnSignIn
,
24 kSettingProxyEverywhere
,
25 kSignedDataRoamingEnabled
,
31 StubCrosSettingsProvider::StubCrosSettingsProvider(
32 const NotifyObserversCallback
& notify_cb
)
33 : CrosSettingsProvider(notify_cb
) {
37 StubCrosSettingsProvider::~StubCrosSettingsProvider() {
40 const base::Value
* StubCrosSettingsProvider::Get(
41 const std::string
& path
) const {
42 DCHECK(HandlesSetting(path
));
43 const base::Value
* value
;
44 if (values_
.GetValue(path
, &value
))
49 bool StubCrosSettingsProvider::GetTrusted(const std::string
& path
,
50 const base::Closure
& callback
) {
51 // We don't have a trusted store so all values are available immediately.
55 bool StubCrosSettingsProvider::HandlesSetting(const std::string
& path
) const {
56 const char** end
= kHandledSettings
+ arraysize(kHandledSettings
);
57 return std::find(kHandledSettings
, end
, path
) != end
;
60 void StubCrosSettingsProvider::Reload() {
63 void StubCrosSettingsProvider::DoSet(const std::string
& path
,
64 const base::Value
& value
) {
65 values_
.SetValue(path
, value
.DeepCopy());
66 NotifyObservers(path
);
69 void StubCrosSettingsProvider::SetDefaults() {
70 values_
.SetBoolean(kAccountsPrefAllowGuest
, true);
71 values_
.SetBoolean(kAccountsPrefAllowNewUser
, true);
72 values_
.SetBoolean(kAccountsPrefShowUserNamesOnSignIn
, true);
73 // |kDeviceOwner| will be set to the logged-in user by |UserManager|.
76 } // namespace chromeos