OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 5 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chromeos/login/user_manager.h" | 9 #include "chrome/browser/chromeos/login/user_manager.h" |
10 #include "chrome/browser/chromeos/settings/cros_settings.h" | 10 #include "chrome/browser/chromeos/settings/cros_settings.h" |
11 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 11 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
| 12 #include "chrome/browser/chromeos/settings/device_settings_provider.h" |
12 | 13 |
13 namespace chromeos { | 14 namespace chromeos { |
14 | 15 |
15 namespace { | |
16 | |
17 const char* kHandledSettings[] = { | |
18 kAccountsPrefAllowGuest, | |
19 kAccountsPrefAllowNewUser, | |
20 kAccountsPrefShowUserNamesOnSignIn, | |
21 kAccountsPrefUsers, | |
22 kAccountsPrefEphemeralUsersEnabled, | |
23 kAccountsPrefDeviceLocalAccounts, | |
24 kDeviceOwner, | |
25 kPolicyMissingMitigationMode, | |
26 kReleaseChannel, | |
27 kReportDeviceVersionInfo, | |
28 kReportDeviceActivityTimes, | |
29 kReportDeviceBootMode, | |
30 kReportDeviceLocation, | |
31 kSettingProxyEverywhere, | |
32 kSignedDataRoamingEnabled, | |
33 kStatsReportingPref, | |
34 kSystemTimezonePolicy, | |
35 // Kiosk mode settings. | |
36 kIdleLogoutTimeout, | |
37 kIdleLogoutWarningDuration, | |
38 kScreenSaverExtensionId, | |
39 kScreenSaverTimeout | |
40 }; | |
41 | |
42 } // namespace | |
43 | |
44 StubCrosSettingsProvider::StubCrosSettingsProvider( | 16 StubCrosSettingsProvider::StubCrosSettingsProvider( |
45 const NotifyObserversCallback& notify_cb) | 17 const NotifyObserversCallback& notify_cb) |
46 : CrosSettingsProvider(notify_cb) { | 18 : CrosSettingsProvider(notify_cb) { |
47 SetDefaults(); | 19 SetDefaults(); |
48 } | 20 } |
49 | 21 |
50 StubCrosSettingsProvider::StubCrosSettingsProvider() | 22 StubCrosSettingsProvider::StubCrosSettingsProvider() |
51 : CrosSettingsProvider(CrosSettingsProvider::NotifyObserversCallback()) { | 23 : CrosSettingsProvider(CrosSettingsProvider::NotifyObserversCallback()) { |
52 SetDefaults(); | 24 SetDefaults(); |
53 } | 25 } |
(...skipping 10 matching lines...) Expand all Loading... |
64 return NULL; | 36 return NULL; |
65 } | 37 } |
66 | 38 |
67 CrosSettingsProvider::TrustedStatus | 39 CrosSettingsProvider::TrustedStatus |
68 StubCrosSettingsProvider::PrepareTrustedValues(const base::Closure& cb) { | 40 StubCrosSettingsProvider::PrepareTrustedValues(const base::Closure& cb) { |
69 // We don't have a trusted store so all values are available immediately. | 41 // We don't have a trusted store so all values are available immediately. |
70 return TRUSTED; | 42 return TRUSTED; |
71 } | 43 } |
72 | 44 |
73 bool StubCrosSettingsProvider::HandlesSetting(const std::string& path) const { | 45 bool StubCrosSettingsProvider::HandlesSetting(const std::string& path) const { |
74 const char** end = kHandledSettings + arraysize(kHandledSettings); | 46 return DeviceSettingsProvider::IsDeviceSetting(path); |
75 return std::find(kHandledSettings, end, path) != end; | |
76 } | 47 } |
77 | 48 |
78 void StubCrosSettingsProvider::DoSet(const std::string& path, | 49 void StubCrosSettingsProvider::DoSet(const std::string& path, |
79 const base::Value& value) { | 50 const base::Value& value) { |
80 values_.SetValue(path, value.DeepCopy()); | 51 values_.SetValue(path, value.DeepCopy()); |
81 NotifyObservers(path); | 52 NotifyObservers(path); |
82 } | 53 } |
83 | 54 |
84 void StubCrosSettingsProvider::SetDefaults() { | 55 void StubCrosSettingsProvider::SetDefaults() { |
85 values_.SetBoolean(kAccountsPrefAllowGuest, true); | 56 values_.SetBoolean(kAccountsPrefAllowGuest, true); |
86 values_.SetBoolean(kAccountsPrefAllowNewUser, true); | 57 values_.SetBoolean(kAccountsPrefAllowNewUser, true); |
87 values_.SetBoolean(kAccountsPrefShowUserNamesOnSignIn, true); | 58 values_.SetBoolean(kAccountsPrefShowUserNamesOnSignIn, true); |
88 values_.SetValue(kAccountsPrefDeviceLocalAccounts, new ListValue); | 59 values_.SetValue(kAccountsPrefDeviceLocalAccounts, new ListValue); |
89 // |kDeviceOwner| will be set to the logged-in user by |UserManager|. | 60 // |kDeviceOwner| will be set to the logged-in user by |UserManager|. |
90 } | 61 } |
91 | 62 |
92 } // namespace chromeos | 63 } // namespace chromeos |
OLD | NEW |