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 "components/ownership/owner_settings_service.h" | |
15 #include "net/cert/x509_util_nss.h" | 14 #include "net/cert/x509_util_nss.h" |
16 | 15 |
17 namespace enterprise_management { | 16 namespace enterprise_management { |
18 class ChromeDeviceSettingsProto; | 17 class ChromeDeviceSettingsProto; |
19 class PolicyData; | 18 class PolicyData; |
20 class PolicyFetchResponse; | 19 class PolicyFetchResponse; |
21 } | 20 } |
22 | 21 |
23 namespace ownership { | 22 namespace ownership { |
24 class OwnerKeyUtil; | 23 class OwnerKeyUtil; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 62 |
64 // Whether the load operation is underway. | 63 // Whether the load operation is underway. |
65 bool is_loading() const { return is_loading_; } | 64 bool is_loading() const { return is_loading_; } |
66 | 65 |
67 void set_force_key_load(bool force_key_load) { | 66 void set_force_key_load(bool force_key_load) { |
68 force_key_load_ = force_key_load; | 67 force_key_load_ = force_key_load; |
69 } | 68 } |
70 | 69 |
71 void set_username(const std::string& username) { username_ = username; } | 70 void set_username(const std::string& username) { username_ = username; } |
72 | 71 |
73 void set_owner_settings_service(const base::WeakPtr< | 72 void set_delegate(const base::WeakPtr< |
74 ownership::OwnerSettingsService>& owner_settings_service) { | 73 DeviceSettingsService::PrivateKeyDelegate>& delegate) { |
75 owner_settings_service_ = owner_settings_service; | 74 delegate_ = delegate; |
76 } | 75 } |
77 | 76 |
78 protected: | 77 protected: |
79 // Runs the operation. The result is reported through |callback_|. | 78 // Runs the operation. The result is reported through |callback_|. |
80 virtual void Run() = 0; | 79 virtual void Run() = 0; |
81 | 80 |
82 // Ensures the public key is loaded. | 81 // Ensures the public key is loaded. |
83 void EnsurePublicKey(const base::Closure& callback); | 82 void EnsurePublicKey(const base::Closure& callback); |
84 | 83 |
85 // Starts a load operation. | 84 // Starts a load operation. |
86 void StartLoading(); | 85 void StartLoading(); |
87 | 86 |
88 // Reports the result status of the operation. Once this gets called, the | 87 // Reports the result status of the operation. Once this gets called, the |
89 // operation should not perform further processing or trigger callbacks. | 88 // operation should not perform further processing or trigger callbacks. |
90 void ReportResult(DeviceSettingsService::Status status); | 89 void ReportResult(DeviceSettingsService::Status status); |
91 | 90 |
92 SessionManagerClient* session_manager_client() { | 91 SessionManagerClient* session_manager_client() { |
93 return session_manager_client_; | 92 return session_manager_client_; |
94 } | 93 } |
95 | 94 |
96 base::WeakPtr<ownership::OwnerSettingsService> owner_settings_service_; | 95 base::WeakPtr<DeviceSettingsService::PrivateKeyDelegate> delegate_; |
97 | 96 |
98 private: | 97 private: |
99 // 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. |
100 static scoped_refptr<ownership::PublicKey> LoadPublicKey( | 99 static scoped_refptr<ownership::PublicKey> LoadPublicKey( |
101 scoped_refptr<ownership::OwnerKeyUtil> util, | 100 scoped_refptr<ownership::OwnerKeyUtil> util, |
102 scoped_refptr<ownership::PublicKey> current_key); | 101 scoped_refptr<ownership::PublicKey> current_key); |
103 | 102 |
104 // Stores the owner key loaded by LoadOwnerKey and calls |callback|. | 103 // Stores the owner key loaded by LoadOwnerKey and calls |callback|. |
105 void StorePublicKey(const base::Closure& callback, | 104 void StorePublicKey(const base::Closure& callback, |
106 scoped_refptr<ownership::PublicKey> new_key); | 105 scoped_refptr<ownership::PublicKey> new_key); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 scoped_ptr<enterprise_management::PolicyData> new_policy_; | 196 scoped_ptr<enterprise_management::PolicyData> new_policy_; |
198 | 197 |
199 base::WeakPtrFactory<SignAndStoreSettingsOperation> weak_factory_; | 198 base::WeakPtrFactory<SignAndStoreSettingsOperation> weak_factory_; |
200 | 199 |
201 DISALLOW_COPY_AND_ASSIGN(SignAndStoreSettingsOperation); | 200 DISALLOW_COPY_AND_ASSIGN(SignAndStoreSettingsOperation); |
202 }; | 201 }; |
203 | 202 |
204 } // namespace chromeos | 203 } // namespace chromeos |
205 | 204 |
206 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ | 205 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ |
OLD | NEW |