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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
19 #include "chromeos/dbus/session_manager_client.h" | 19 #include "chromeos/dbus/session_manager_client.h" |
20 #include "chromeos/tpm_token_loader.h" | 20 #include "chromeos/tpm_token_loader.h" |
21 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 21 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
| 22 #include "content/public/browser/notification_observer.h" |
| 23 #include "content/public/browser/notification_registrar.h" |
22 #include "policy/proto/device_management_backend.pb.h" | 24 #include "policy/proto/device_management_backend.pb.h" |
23 | 25 |
24 namespace crypto { | 26 namespace crypto { |
25 class RSAPrivateKey; | 27 class RSAPrivateKey; |
26 } | 28 } |
27 | 29 |
28 namespace enterprise_management { | 30 namespace enterprise_management { |
29 class ChromeDeviceSettingsProto; | 31 class ChromeDeviceSettingsProto; |
30 } | 32 } |
31 | 33 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // settings are brokered by the session_manager daemon. | 74 // settings are brokered by the session_manager daemon. |
73 // | 75 // |
74 // The purpose of DeviceSettingsService is to keep track of the current key and | 76 // The purpose of DeviceSettingsService is to keep track of the current key and |
75 // settings blob. For reading and writing device settings, use CrosSettings | 77 // settings blob. For reading and writing device settings, use CrosSettings |
76 // instead, which provides a high-level interface that allows for manipulation | 78 // instead, which provides a high-level interface that allows for manipulation |
77 // of individual settings. | 79 // of individual settings. |
78 // | 80 // |
79 // DeviceSettingsService generates notifications for key and policy update | 81 // DeviceSettingsService generates notifications for key and policy update |
80 // events so interested parties can reload state as appropriate. | 82 // events so interested parties can reload state as appropriate. |
81 class DeviceSettingsService : public SessionManagerClient::Observer, | 83 class DeviceSettingsService : public SessionManagerClient::Observer, |
82 public TPMTokenLoader::Observer { | 84 public TPMTokenLoader::Observer, |
| 85 public content::NotificationObserver { |
83 public: | 86 public: |
84 // Indicates ownership status of the device. | 87 // Indicates ownership status of the device. |
85 enum OwnershipStatus { | 88 enum OwnershipStatus { |
86 // Listed in upgrade order. | 89 // Listed in upgrade order. |
87 OWNERSHIP_UNKNOWN = 0, | 90 OWNERSHIP_UNKNOWN = 0, |
88 OWNERSHIP_NONE, | 91 OWNERSHIP_NONE, |
89 OWNERSHIP_TAKEN | 92 OWNERSHIP_TAKEN |
90 }; | 93 }; |
91 | 94 |
92 typedef base::Callback<void(OwnershipStatus)> OwnershipStatusCallback; | 95 typedef base::Callback<void(OwnershipStatus)> OwnershipStatusCallback; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 // Removes an observer. | 210 // Removes an observer. |
208 void RemoveObserver(Observer* observer); | 211 void RemoveObserver(Observer* observer); |
209 | 212 |
210 // SessionManagerClient::Observer: | 213 // SessionManagerClient::Observer: |
211 virtual void OwnerKeySet(bool success) OVERRIDE; | 214 virtual void OwnerKeySet(bool success) OVERRIDE; |
212 virtual void PropertyChangeComplete(bool success) OVERRIDE; | 215 virtual void PropertyChangeComplete(bool success) OVERRIDE; |
213 | 216 |
214 // TPMTokenLoader::Observer: | 217 // TPMTokenLoader::Observer: |
215 virtual void OnTPMTokenReady() OVERRIDE; | 218 virtual void OnTPMTokenReady() OVERRIDE; |
216 | 219 |
| 220 // content::NotificationObserver implementation. |
| 221 virtual void Observe(int type, |
| 222 const content::NotificationSource& source, |
| 223 const content::NotificationDetails& details) OVERRIDE; |
| 224 |
217 private: | 225 private: |
218 // Enqueues a new operation. Takes ownership of |operation| and starts it | 226 // Enqueues a new operation. Takes ownership of |operation| and starts it |
219 // right away if there is no active operation currently. | 227 // right away if there is no active operation currently. |
220 void Enqueue(SessionManagerOperation* operation); | 228 void Enqueue(SessionManagerOperation* operation); |
221 | 229 |
222 // Enqueues a load operation. | 230 // Enqueues a load operation. |
223 void EnqueueLoad(bool force_key_load); | 231 void EnqueueLoad(bool force_key_load); |
224 | 232 |
225 // Makes sure there's a reload operation so changes to the settings (and key, | 233 // Makes sure there's a reload operation so changes to the settings (and key, |
226 // in case force_key_load is set) are getting picked up. | 234 // in case force_key_load is set) are getting picked up. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 281 |
274 // The queue of pending operations. The first operation on the queue is | 282 // The queue of pending operations. The first operation on the queue is |
275 // currently active; it gets removed and destroyed once it completes. | 283 // currently active; it gets removed and destroyed once it completes. |
276 std::deque<SessionManagerOperation*> pending_operations_; | 284 std::deque<SessionManagerOperation*> pending_operations_; |
277 | 285 |
278 ObserverList<Observer, true> observers_; | 286 ObserverList<Observer, true> observers_; |
279 | 287 |
280 // For recoverable load errors how many retries are left before we give up. | 288 // For recoverable load errors how many retries are left before we give up. |
281 int load_retries_left_; | 289 int load_retries_left_; |
282 | 290 |
| 291 content::NotificationRegistrar registrar_; |
| 292 |
283 base::WeakPtrFactory<DeviceSettingsService> weak_factory_; | 293 base::WeakPtrFactory<DeviceSettingsService> weak_factory_; |
284 | 294 |
285 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsService); | 295 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsService); |
286 }; | 296 }; |
287 | 297 |
288 // Helper class for tests. Initializes the DeviceSettingsService singleton on | 298 // Helper class for tests. Initializes the DeviceSettingsService singleton on |
289 // construction and tears it down again on destruction. | 299 // construction and tears it down again on destruction. |
290 class ScopedTestDeviceSettingsService { | 300 class ScopedTestDeviceSettingsService { |
291 public: | 301 public: |
292 ScopedTestDeviceSettingsService(); | 302 ScopedTestDeviceSettingsService(); |
293 ~ScopedTestDeviceSettingsService(); | 303 ~ScopedTestDeviceSettingsService(); |
294 | 304 |
295 private: | 305 private: |
296 DISALLOW_COPY_AND_ASSIGN(ScopedTestDeviceSettingsService); | 306 DISALLOW_COPY_AND_ASSIGN(ScopedTestDeviceSettingsService); |
297 }; | 307 }; |
298 | 308 |
299 } // namespace chromeos | 309 } // namespace chromeos |
300 | 310 |
301 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ | 311 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ |
OLD | NEW |