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_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
| 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | |
18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
19 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 19 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
20 #include "chromeos/dbus/session_manager_client.h" | 20 #include "chromeos/dbus/session_manager_client.h" |
21 #include "components/ownership/owner_settings_service.h" | 21 #include "components/ownership/owner_settings_service.h" |
22 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 22 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
23 #include "crypto/scoped_nss_types.h" | 23 #include "crypto/scoped_nss_types.h" |
24 #include "policy/proto/device_management_backend.pb.h" | 24 #include "policy/proto/device_management_backend.pb.h" |
25 | 25 |
26 namespace crypto { | 26 namespace crypto { |
27 class RSAPrivateKey; | 27 class RSAPrivateKey; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 return store_status_; | 127 return store_status_; |
128 } | 128 } |
129 | 129 |
130 // Triggers an attempt to pull the public half of the owner key from disk and | 130 // Triggers an attempt to pull the public half of the owner key from disk and |
131 // load the device settings. | 131 // load the device settings. |
132 void Load(); | 132 void Load(); |
133 | 133 |
134 // Stores a policy blob to session_manager. The result of the operation is | 134 // Stores a policy blob to session_manager. The result of the operation is |
135 // reported through |callback|. If successful, the updated device settings are | 135 // reported through |callback|. If successful, the updated device settings are |
136 // present in policy_data() and device_settings() when the callback runs. | 136 // present in policy_data() and device_settings() when the callback runs. |
137 void Store(scoped_ptr<enterprise_management::PolicyFetchResponse> policy, | 137 void Store(std::unique_ptr<enterprise_management::PolicyFetchResponse> policy, |
138 const base::Closure& callback); | 138 const base::Closure& callback); |
139 | 139 |
140 // Returns the ownership status. May return OWNERSHIP_UNKNOWN if the disk | 140 // Returns the ownership status. May return OWNERSHIP_UNKNOWN if the disk |
141 // hasn't been checked yet. | 141 // hasn't been checked yet. |
142 OwnershipStatus GetOwnershipStatus(); | 142 OwnershipStatus GetOwnershipStatus(); |
143 | 143 |
144 // Determines the ownership status and reports the result to |callback|. This | 144 // Determines the ownership status and reports the result to |callback|. This |
145 // is guaranteed to never return OWNERSHIP_UNKNOWN. | 145 // is guaranteed to never return OWNERSHIP_UNKNOWN. |
146 void GetOwnershipStatusAsync(const OwnershipStatusCallback& callback); | 146 void GetOwnershipStatusAsync(const OwnershipStatusCallback& callback); |
147 | 147 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_; | 207 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_; |
208 | 208 |
209 Status store_status_; | 209 Status store_status_; |
210 | 210 |
211 std::vector<OwnershipStatusCallback> pending_ownership_status_callbacks_; | 211 std::vector<OwnershipStatusCallback> pending_ownership_status_callbacks_; |
212 | 212 |
213 std::string username_; | 213 std::string username_; |
214 scoped_refptr<ownership::PublicKey> public_key_; | 214 scoped_refptr<ownership::PublicKey> public_key_; |
215 base::WeakPtr<ownership::OwnerSettingsService> owner_settings_service_; | 215 base::WeakPtr<ownership::OwnerSettingsService> owner_settings_service_; |
216 | 216 |
217 scoped_ptr<enterprise_management::PolicyData> policy_data_; | 217 std::unique_ptr<enterprise_management::PolicyData> policy_data_; |
218 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_; | 218 std::unique_ptr<enterprise_management::ChromeDeviceSettingsProto> |
| 219 device_settings_; |
219 | 220 |
220 // The queue of pending operations. The first operation on the queue is | 221 // The queue of pending operations. The first operation on the queue is |
221 // currently active; it gets removed and destroyed once it completes. | 222 // currently active; it gets removed and destroyed once it completes. |
222 std::deque<linked_ptr<SessionManagerOperation>> pending_operations_; | 223 std::deque<linked_ptr<SessionManagerOperation>> pending_operations_; |
223 | 224 |
224 base::ObserverList<Observer> observers_; | 225 base::ObserverList<Observer> observers_; |
225 | 226 |
226 // For recoverable load errors how many retries are left before we give up. | 227 // For recoverable load errors how many retries are left before we give up. |
227 int load_retries_left_; | 228 int load_retries_left_; |
228 | 229 |
229 base::WeakPtrFactory<DeviceSettingsService> weak_factory_; | 230 base::WeakPtrFactory<DeviceSettingsService> weak_factory_; |
230 | 231 |
231 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsService); | 232 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsService); |
232 }; | 233 }; |
233 | 234 |
234 // Helper class for tests. Initializes the DeviceSettingsService singleton on | 235 // Helper class for tests. Initializes the DeviceSettingsService singleton on |
235 // construction and tears it down again on destruction. | 236 // construction and tears it down again on destruction. |
236 class ScopedTestDeviceSettingsService { | 237 class ScopedTestDeviceSettingsService { |
237 public: | 238 public: |
238 ScopedTestDeviceSettingsService(); | 239 ScopedTestDeviceSettingsService(); |
239 ~ScopedTestDeviceSettingsService(); | 240 ~ScopedTestDeviceSettingsService(); |
240 | 241 |
241 private: | 242 private: |
242 DISALLOW_COPY_AND_ASSIGN(ScopedTestDeviceSettingsService); | 243 DISALLOW_COPY_AND_ASSIGN(ScopedTestDeviceSettingsService); |
243 }; | 244 }; |
244 | 245 |
245 } // namespace chromeos | 246 } // namespace chromeos |
246 | 247 |
247 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ | 248 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ |
OLD | NEW |