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

Side by Side Diff: chrome/browser/chromeos/settings/stub_cros_settings_provider.cc

Issue 1019283004: Switch to direct use of OwnerSettingsServiceChromeOS::Set() in tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 8 months 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
OLDNEW
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/settings/cros_settings.h" 9 #include "chrome/browser/chromeos/settings/cros_settings.h"
10 #include "chrome/browser/chromeos/settings/device_settings_provider.h" 10 #include "chrome/browser/chromeos/settings/device_settings_provider.h"
(...skipping 19 matching lines...) Expand all
30 const std::string& path) const { 30 const std::string& path) const {
31 DCHECK(HandlesSetting(path)); 31 DCHECK(HandlesSetting(path));
32 const base::Value* value; 32 const base::Value* value;
33 if (values_.GetValue(path, &value)) 33 if (values_.GetValue(path, &value))
34 return value; 34 return value;
35 return NULL; 35 return NULL;
36 } 36 }
37 37
38 CrosSettingsProvider::TrustedStatus 38 CrosSettingsProvider::TrustedStatus
39 StubCrosSettingsProvider::PrepareTrustedValues(const base::Closure& cb) { 39 StubCrosSettingsProvider::PrepareTrustedValues(const base::Closure& cb) {
40 // We don't have a trusted store so all values are available immediately. 40 return trusted_status_;
41 return TRUSTED;
42 } 41 }
43 42
44 bool StubCrosSettingsProvider::HandlesSetting(const std::string& path) const { 43 bool StubCrosSettingsProvider::HandlesSetting(const std::string& path) const {
45 return DeviceSettingsProvider::IsDeviceSetting(path); 44 return DeviceSettingsProvider::IsDeviceSetting(path);
46 } 45 }
47 46
47 void StubCrosSettingsProvider::SetTrustedStatus(TrustedStatus status) {
48 trusted_status_ = status;
49 }
50
51 void StubCrosSettingsProvider::SetCurrentUserIsOwner(bool owner) {
52 current_user_is_owner_ = owner;
53 }
54
48 void StubCrosSettingsProvider::DoSet(const std::string& path, 55 void StubCrosSettingsProvider::DoSet(const std::string& path,
49 const base::Value& value) { 56 const base::Value& value) {
50 values_.SetValue(path, value.DeepCopy()); 57 if (current_user_is_owner_)
58 values_.SetValue(path, value.DeepCopy());
59 else
60 LOG(WARNING) << "Changing settings from non-owner, setting=" << path;
51 NotifyObservers(path); 61 NotifyObservers(path);
52 } 62 }
53 63
54 void StubCrosSettingsProvider::SetDefaults() { 64 void StubCrosSettingsProvider::SetDefaults() {
55 values_.SetBoolean(kAccountsPrefAllowGuest, true); 65 values_.SetBoolean(kAccountsPrefAllowGuest, true);
56 values_.SetBoolean(kAccountsPrefAllowNewUser, true); 66 values_.SetBoolean(kAccountsPrefAllowNewUser, true);
57 values_.SetBoolean(kAccountsPrefSupervisedUsersEnabled, true); 67 values_.SetBoolean(kAccountsPrefSupervisedUsersEnabled, true);
58 values_.SetBoolean(kAccountsPrefShowUserNamesOnSignIn, true); 68 values_.SetBoolean(kAccountsPrefShowUserNamesOnSignIn, true);
59 values_.SetValue(kAccountsPrefDeviceLocalAccounts, new base::ListValue); 69 values_.SetValue(kAccountsPrefDeviceLocalAccounts, new base::ListValue);
60 // |kDeviceOwner| will be set to the logged-in user by |UserManager|. 70 // |kDeviceOwner| will be set to the logged-in user by |UserManager|.
61 } 71 }
62 72
63 } // namespace chromeos 73 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698