Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |