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