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_SESSION_MANAGER_OPERATION_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ |
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/chromeos/policy/device_cloud_policy_validator.h" | 12 #include "chrome/browser/chromeos/policy/device_cloud_policy_validator.h" |
13 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 13 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
14 #include "net/cert/x509_util_nss.h" | 14 #include "net/cert/x509_util_nss.h" |
15 | 15 |
16 namespace enterprise_management { | 16 namespace enterprise_management { |
17 class ChromeDeviceSettingsProto; | 17 class ChromeDeviceSettingsProto; |
18 class PolicyData; | 18 class PolicyData; |
19 class PolicyFetchResponse; | 19 class PolicyFetchResponse; |
20 } | 20 } |
21 | 21 |
| 22 namespace ownership { |
| 23 class OwnerKeyUtil; |
| 24 class PublicKey; |
| 25 } |
| 26 |
22 namespace chromeos { | 27 namespace chromeos { |
23 | 28 |
24 class OwnerKeyUtil; | |
25 class SessionManagerClient; | 29 class SessionManagerClient; |
26 | 30 |
27 // Handles a single transaction with session manager. This is a virtual base | 31 // Handles a single transaction with session manager. This is a virtual base |
28 // class that contains common infrastructure for key and policy loading. There | 32 // class that contains common infrastructure for key and policy loading. There |
29 // are subclasses for loading, storing and signing policy blobs. | 33 // are subclasses for loading, storing and signing policy blobs. |
30 class SessionManagerOperation { | 34 class SessionManagerOperation { |
31 public: | 35 public: |
32 typedef base::Callback<void(SessionManagerOperation*, | 36 typedef base::Callback<void(SessionManagerOperation*, |
33 DeviceSettingsService::Status)> Callback; | 37 DeviceSettingsService::Status)> Callback; |
34 | 38 |
35 // Creates a new load operation. | 39 // Creates a new load operation. |
36 explicit SessionManagerOperation(const Callback& callback); | 40 explicit SessionManagerOperation(const Callback& callback); |
37 virtual ~SessionManagerOperation(); | 41 virtual ~SessionManagerOperation(); |
38 | 42 |
39 // Starts the operation. | 43 // Starts the operation. |
40 void Start(SessionManagerClient* session_manager_client, | 44 void Start(SessionManagerClient* session_manager_client, |
41 scoped_refptr<OwnerKeyUtil> owner_key_util, | 45 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util, |
42 scoped_refptr<PublicKey> public_key); | 46 scoped_refptr<ownership::PublicKey> public_key); |
43 | 47 |
44 // Restarts a load operation (if that part is already in progress). | 48 // Restarts a load operation (if that part is already in progress). |
45 void RestartLoad(bool key_changed); | 49 void RestartLoad(bool key_changed); |
46 | 50 |
47 // Accessors for recovering the loaded policy data after completion. | 51 // Accessors for recovering the loaded policy data after completion. |
48 scoped_ptr<enterprise_management::PolicyData>& policy_data() { | 52 scoped_ptr<enterprise_management::PolicyData>& policy_data() { |
49 return policy_data_; | 53 return policy_data_; |
50 } | 54 } |
51 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto>& | 55 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto>& |
52 device_settings() { | 56 device_settings() { |
53 return device_settings_; | 57 return device_settings_; |
54 } | 58 } |
55 | 59 |
56 // Public part of the owner key as configured/loaded from disk. | 60 // Public part of the owner key as configured/loaded from disk. |
57 scoped_refptr<PublicKey> public_key() { return public_key_; } | 61 scoped_refptr<ownership::PublicKey> public_key() { return public_key_; } |
58 | 62 |
59 // Whether the load operation is underway. | 63 // Whether the load operation is underway. |
60 bool is_loading() const { return is_loading_; } | 64 bool is_loading() const { return is_loading_; } |
61 | 65 |
62 void set_force_key_load(bool force_key_load) { | 66 void set_force_key_load(bool force_key_load) { |
63 force_key_load_ = force_key_load; | 67 force_key_load_ = force_key_load; |
64 } | 68 } |
65 | 69 |
66 void set_username(const std::string& username) { username_ = username; } | 70 void set_username(const std::string& username) { username_ = username; } |
67 | 71 |
(...skipping 17 matching lines...) Expand all Loading... |
85 void ReportResult(DeviceSettingsService::Status status); | 89 void ReportResult(DeviceSettingsService::Status status); |
86 | 90 |
87 SessionManagerClient* session_manager_client() { | 91 SessionManagerClient* session_manager_client() { |
88 return session_manager_client_; | 92 return session_manager_client_; |
89 } | 93 } |
90 | 94 |
91 base::WeakPtr<DeviceSettingsService::PrivateKeyDelegate> delegate_; | 95 base::WeakPtr<DeviceSettingsService::PrivateKeyDelegate> delegate_; |
92 | 96 |
93 private: | 97 private: |
94 // Loads the owner key from disk. Must be run on a thread that can do I/O. | 98 // Loads the owner key from disk. Must be run on a thread that can do I/O. |
95 static scoped_refptr<PublicKey> LoadPublicKey( | 99 static scoped_refptr<ownership::PublicKey> LoadPublicKey( |
96 scoped_refptr<OwnerKeyUtil> util, | 100 scoped_refptr<ownership::OwnerKeyUtil> util, |
97 scoped_refptr<PublicKey> current_key); | 101 scoped_refptr<ownership::PublicKey> current_key); |
98 | 102 |
99 // Stores the owner key loaded by LoadOwnerKey and calls |callback|. | 103 // Stores the owner key loaded by LoadOwnerKey and calls |callback|. |
100 void StorePublicKey(const base::Closure& callback, | 104 void StorePublicKey(const base::Closure& callback, |
101 scoped_refptr<PublicKey> new_key); | 105 scoped_refptr<ownership::PublicKey> new_key); |
102 | 106 |
103 // Triggers a device settings load. | 107 // Triggers a device settings load. |
104 void RetrieveDeviceSettings(); | 108 void RetrieveDeviceSettings(); |
105 | 109 |
106 // Validates device settings after retrieval from session_manager. | 110 // Validates device settings after retrieval from session_manager. |
107 void ValidateDeviceSettings(const std::string& policy_blob); | 111 void ValidateDeviceSettings(const std::string& policy_blob); |
108 | 112 |
109 // Extracts status and device settings from the validator and reports them. | 113 // Extracts status and device settings from the validator and reports them. |
110 void ReportValidatorStatus(policy::DeviceCloudPolicyValidator* validator); | 114 void ReportValidatorStatus(policy::DeviceCloudPolicyValidator* validator); |
111 | 115 |
112 SessionManagerClient* session_manager_client_; | 116 SessionManagerClient* session_manager_client_; |
113 scoped_refptr<OwnerKeyUtil> owner_key_util_; | 117 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_; |
114 | 118 |
115 base::WeakPtrFactory<SessionManagerOperation> weak_factory_; | 119 base::WeakPtrFactory<SessionManagerOperation> weak_factory_; |
116 | 120 |
117 Callback callback_; | 121 Callback callback_; |
118 | 122 |
119 scoped_refptr<PublicKey> public_key_; | 123 scoped_refptr<ownership::PublicKey> public_key_; |
120 bool force_key_load_; | 124 bool force_key_load_; |
121 std::string username_; | 125 std::string username_; |
122 | 126 |
123 bool is_loading_; | 127 bool is_loading_; |
124 scoped_ptr<enterprise_management::PolicyData> policy_data_; | 128 scoped_ptr<enterprise_management::PolicyData> policy_data_; |
125 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_; | 129 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_; |
126 | 130 |
127 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperation); | 131 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperation); |
128 }; | 132 }; |
129 | 133 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 scoped_ptr<enterprise_management::PolicyData> new_policy_; | 196 scoped_ptr<enterprise_management::PolicyData> new_policy_; |
193 | 197 |
194 base::WeakPtrFactory<SignAndStoreSettingsOperation> weak_factory_; | 198 base::WeakPtrFactory<SignAndStoreSettingsOperation> weak_factory_; |
195 | 199 |
196 DISALLOW_COPY_AND_ASSIGN(SignAndStoreSettingsOperation); | 200 DISALLOW_COPY_AND_ASSIGN(SignAndStoreSettingsOperation); |
197 }; | 201 }; |
198 | 202 |
199 } // namespace chromeos | 203 } // namespace chromeos |
200 | 204 |
201 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ | 205 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ |
OLD | NEW |