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 #ifndef CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace base { | 23 namespace base { |
24 class Value; | 24 class Value; |
25 } | 25 } |
26 | 26 |
27 namespace chromeos { | 27 namespace chromeos { |
28 | 28 |
29 // CrosSettingsProvider implementation that works with SignedSettings. | 29 // CrosSettingsProvider implementation that works with SignedSettings. |
30 class DeviceSettingsProvider : public CrosSettingsProvider, | 30 class DeviceSettingsProvider : public CrosSettingsProvider, |
31 public content::NotificationObserver { | 31 public content::NotificationObserver { |
32 public: | 32 public: |
33 explicit DeviceSettingsProvider(const NotifyObserversCallback& notify_cb); | 33 explicit DeviceSettingsProvider(const NotifyObserversCallback& notify_cb, |
| 34 SignedSettingsHelper* signed_settings_helper); |
34 virtual ~DeviceSettingsProvider(); | 35 virtual ~DeviceSettingsProvider(); |
35 | 36 |
36 // CrosSettingsProvider implementation. | 37 // CrosSettingsProvider implementation. |
37 virtual const base::Value* Get(const std::string& path) const OVERRIDE; | 38 virtual const base::Value* Get(const std::string& path) const OVERRIDE; |
38 virtual bool PrepareTrustedValues(const base::Closure& callback) OVERRIDE; | 39 virtual bool PrepareTrustedValues(const base::Closure& callback) OVERRIDE; |
39 virtual bool HandlesSetting(const std::string& path) const OVERRIDE; | 40 virtual bool HandlesSetting(const std::string& path) const OVERRIDE; |
40 virtual void Reload() OVERRIDE; | 41 virtual void Reload() OVERRIDE; |
41 | 42 |
| 43 protected: |
| 44 // For test use only. |
| 45 void set_ownership_status(OwnershipService::Status status) { |
| 46 ownership_status_ = status; |
| 47 } |
| 48 |
42 private: | 49 private: |
43 // CrosSettingsProvider implementation: | 50 // CrosSettingsProvider implementation: |
44 virtual void DoSet(const std::string& path, | 51 virtual void DoSet(const std::string& path, |
45 const base::Value& value) OVERRIDE; | 52 const base::Value& value) OVERRIDE; |
46 | 53 |
47 // content::NotificationObserver implementation: | 54 // content::NotificationObserver implementation: |
48 virtual void Observe(int type, | 55 virtual void Observe(int type, |
49 const content::NotificationSource& source, | 56 const content::NotificationSource& source, |
50 const content::NotificationDetails& details) OVERRIDE; | 57 const content::NotificationDetails& details) OVERRIDE; |
51 | 58 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 void OnStorePolicyCompleted(SignedSettings::ReturnCode code); | 125 void OnStorePolicyCompleted(SignedSettings::ReturnCode code); |
119 | 126 |
120 // Callback of RetrievePolicyOp for ordinary policy [re]loads. | 127 // Callback of RetrievePolicyOp for ordinary policy [re]loads. |
121 void OnRetrievePolicyCompleted( | 128 void OnRetrievePolicyCompleted( |
122 SignedSettings::ReturnCode code, | 129 SignedSettings::ReturnCode code, |
123 const enterprise_management::PolicyFetchResponse& policy); | 130 const enterprise_management::PolicyFetchResponse& policy); |
124 | 131 |
125 // Pending callbacks that need to be invoked after settings verification. | 132 // Pending callbacks that need to be invoked after settings verification. |
126 std::vector<base::Closure> callbacks_; | 133 std::vector<base::Closure> callbacks_; |
127 | 134 |
| 135 SignedSettingsHelper* signed_settings_helper_; |
128 OwnershipService::Status ownership_status_; | 136 OwnershipService::Status ownership_status_; |
129 mutable scoped_ptr<SignedSettingsMigrationHelper> migration_helper_; | 137 mutable scoped_ptr<SignedSettingsMigrationHelper> migration_helper_; |
130 | 138 |
131 content::NotificationRegistrar registrar_; | 139 content::NotificationRegistrar registrar_; |
132 | 140 |
133 // In order to guard against occasional failure to fetch a property | 141 // In order to guard against occasional failure to fetch a property |
134 // we allow for some number of retries. | 142 // we allow for some number of retries. |
135 int retries_left_; | 143 int retries_left_; |
136 | 144 |
137 enterprise_management::PolicyData policy_; | 145 enterprise_management::PolicyData policy_; |
138 bool trusted_; | 146 bool trusted_; |
139 | 147 |
140 PrefValueMap values_cache_; | 148 PrefValueMap values_cache_; |
141 | 149 |
142 // This is a queue for set requests, because those need to be sequential. | 150 // This is a queue for set requests, because those need to be sequential. |
143 typedef std::pair<std::string, base::Value*> PendingQueueElement; | 151 typedef std::pair<std::string, base::Value*> PendingQueueElement; |
144 std::vector<PendingQueueElement> pending_changes_; | 152 std::vector<PendingQueueElement> pending_changes_; |
145 | 153 |
| 154 friend class DeviceSettingsProviderTest; |
| 155 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, |
| 156 InitializationTestUnowned); |
146 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider); | 157 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider); |
147 }; | 158 }; |
148 | 159 |
149 } // namespace chromeos | 160 } // namespace chromeos |
150 | 161 |
151 #endif // CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ | 162 #endif // CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ |
OLD | NEW |