OLD | NEW |
(Empty) | |
| 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. |
| 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 const NotifyObserversCallback& notify_cb) |
| 33 : CrosSettingsProvider(notify_cb) { |
| 34 SetDefaults(); |
| 35 } |
| 36 |
| 37 StubCrosSettingsProvider::~StubCrosSettingsProvider() { |
| 38 } |
| 39 |
| 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)) |
| 45 return value; |
| 46 return NULL; |
| 47 } |
| 48 |
| 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. |
| 52 return true; |
| 53 } |
| 54 |
| 55 bool StubCrosSettingsProvider::HandlesSetting(const std::string& path) const { |
| 56 const char** end = kHandledSettings + arraysize(kHandledSettings); |
| 57 return std::find(kHandledSettings, end, path) != end; |
| 58 } |
| 59 |
| 60 void StubCrosSettingsProvider::Reload() { |
| 61 } |
| 62 |
| 63 void StubCrosSettingsProvider::DoSet(const std::string& path, |
| 64 const base::Value& value) { |
| 65 values_.SetValue(path, value.DeepCopy()); |
| 66 NotifyObservers(path); |
| 67 } |
| 68 |
| 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|. |
| 74 } |
| 75 |
| 76 } // namespace chromeos |
OLD | NEW |