| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 device_settings() { | 57 device_settings() { |
| 58 return device_settings_; | 58 return device_settings_; |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Public part of the owner key as configured/loaded from disk. | 61 // Public part of the owner key as configured/loaded from disk. |
| 62 scoped_refptr<ownership::PublicKey> public_key() { return public_key_; } | 62 scoped_refptr<ownership::PublicKey> public_key() { return public_key_; } |
| 63 | 63 |
| 64 // Whether the load operation is underway. | 64 // Whether the load operation is underway. |
| 65 bool is_loading() const { return is_loading_; } | 65 bool is_loading() const { return is_loading_; } |
| 66 | 66 |
| 67 void set_force_key_load(bool force_key_load) { | |
| 68 force_key_load_ = force_key_load; | |
| 69 } | |
| 70 | |
| 71 protected: | 67 protected: |
| 72 // Runs the operation. The result is reported through |callback_|. | 68 // Runs the operation. The result is reported through |callback_|. |
| 73 virtual void Run() = 0; | 69 virtual void Run() = 0; |
| 74 | 70 |
| 75 // Ensures the public key is loaded. | 71 // Ensures the public key is loaded. |
| 76 void EnsurePublicKey(const base::Closure& callback); | 72 void EnsurePublicKey(const base::Closure& callback); |
| 77 | 73 |
| 78 // Starts a load operation. | 74 // Starts a load operation. |
| 79 void StartLoading(); | 75 void StartLoading(); |
| 80 | 76 |
| 81 // Reports the result status of the operation. Once this gets called, the | 77 // Reports the result status of the operation. Once this gets called, the |
| 82 // operation should not perform further processing or trigger callbacks. | 78 // operation should not perform further processing or trigger callbacks. |
| 83 void ReportResult(DeviceSettingsService::Status status); | 79 void ReportResult(DeviceSettingsService::Status status); |
| 84 | 80 |
| 85 SessionManagerClient* session_manager_client() { | 81 SessionManagerClient* session_manager_client() { |
| 86 return session_manager_client_; | 82 return session_manager_client_; |
| 87 } | 83 } |
| 88 | 84 |
| 85 // Whether to verify the loaded policy's signature against |public_key_| and |
| 86 // perform other cloud-specific validations. (Active Directory policy has no |
| 87 // signature that could be verified.) |
| 88 bool cloud_validations_ = true; |
| 89 |
| 90 bool force_key_load_ = false; |
| 91 |
| 89 private: | 92 private: |
| 90 // Loads the owner key from disk. Must be run on a thread that can do I/O. | 93 // Loads the owner key from disk. Must be run on a thread that can do I/O. |
| 91 static scoped_refptr<ownership::PublicKey> LoadPublicKey( | 94 static scoped_refptr<ownership::PublicKey> LoadPublicKey( |
| 92 scoped_refptr<ownership::OwnerKeyUtil> util, | 95 scoped_refptr<ownership::OwnerKeyUtil> util, |
| 93 scoped_refptr<ownership::PublicKey> current_key); | 96 scoped_refptr<ownership::PublicKey> current_key); |
| 94 | 97 |
| 95 // Stores the owner key loaded by LoadOwnerKey and calls |callback|. | 98 // Stores the owner key loaded by LoadOwnerKey and calls |callback|. |
| 96 void StorePublicKey(const base::Closure& callback, | 99 void StorePublicKey(const base::Closure& callback, |
| 97 scoped_refptr<ownership::PublicKey> new_key); | 100 scoped_refptr<ownership::PublicKey> new_key); |
| 98 | 101 |
| 99 // Triggers a device settings load. | 102 // Triggers a device settings load. |
| 100 void RetrieveDeviceSettings(); | 103 void RetrieveDeviceSettings(); |
| 101 | 104 |
| 102 // Validates device settings after retrieval from session_manager. | 105 // Validates device settings after retrieval from session_manager. |
| 103 void ValidateDeviceSettings(const std::string& policy_blob); | 106 void ValidateDeviceSettings(const std::string& policy_blob); |
| 104 | 107 |
| 105 // Extracts status and device settings from the validator and reports them. | 108 // Extracts status and device settings from the validator and reports them. |
| 106 void ReportValidatorStatus(policy::DeviceCloudPolicyValidator* validator); | 109 void ReportValidatorStatus(policy::DeviceCloudPolicyValidator* validator); |
| 107 | 110 |
| 108 SessionManagerClient* session_manager_client_; | 111 SessionManagerClient* session_manager_client_ = nullptr; |
| 109 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_; | 112 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_; |
| 110 | 113 |
| 111 Callback callback_; | 114 Callback callback_; |
| 112 | 115 |
| 113 scoped_refptr<ownership::PublicKey> public_key_; | 116 scoped_refptr<ownership::PublicKey> public_key_; |
| 114 bool force_key_load_; | |
| 115 | 117 |
| 116 bool is_loading_; | 118 bool is_loading_ = false; |
| 117 std::unique_ptr<enterprise_management::PolicyData> policy_data_; | 119 std::unique_ptr<enterprise_management::PolicyData> policy_data_; |
| 118 std::unique_ptr<enterprise_management::ChromeDeviceSettingsProto> | 120 std::unique_ptr<enterprise_management::ChromeDeviceSettingsProto> |
| 119 device_settings_; | 121 device_settings_; |
| 120 | 122 |
| 121 base::WeakPtrFactory<SessionManagerOperation> weak_factory_; | 123 base::WeakPtrFactory<SessionManagerOperation> weak_factory_; |
| 122 | 124 |
| 123 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperation); | 125 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperation); |
| 124 }; | 126 }; |
| 125 | 127 |
| 126 // This operation loads the public owner key from disk if appropriate, fetches | 128 // This operation loads the public owner key from disk if appropriate, fetches |
| 127 // the policy blob from session manager, and validates the loaded policy blob. | 129 // the policy blob from session manager, and validates the loaded policy blob. |
| 128 class LoadSettingsOperation : public SessionManagerOperation { | 130 class LoadSettingsOperation : public SessionManagerOperation { |
| 129 public: | 131 public: |
| 130 // Creates a new load operation. | 132 // Creates a new load operation. If |cloud_validations| is true, signature |
| 131 explicit LoadSettingsOperation(const Callback& callback); | 133 // validation and other cloud-specific checks are performed. |
| 134 LoadSettingsOperation(bool force_key_load, |
| 135 bool cloud_validations, |
| 136 const Callback& callback); |
| 132 ~LoadSettingsOperation() override; | 137 ~LoadSettingsOperation() override; |
| 133 | 138 |
| 134 protected: | 139 protected: |
| 135 // SessionManagerOperation: | 140 // SessionManagerOperation: |
| 136 void Run() override; | 141 void Run() override; |
| 137 | 142 |
| 138 private: | 143 private: |
| 139 DISALLOW_COPY_AND_ASSIGN(LoadSettingsOperation); | 144 DISALLOW_COPY_AND_ASSIGN(LoadSettingsOperation); |
| 140 }; | 145 }; |
| 141 | 146 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 160 std::unique_ptr<enterprise_management::PolicyFetchResponse> policy_; | 165 std::unique_ptr<enterprise_management::PolicyFetchResponse> policy_; |
| 161 | 166 |
| 162 base::WeakPtrFactory<StoreSettingsOperation> weak_factory_; | 167 base::WeakPtrFactory<StoreSettingsOperation> weak_factory_; |
| 163 | 168 |
| 164 DISALLOW_COPY_AND_ASSIGN(StoreSettingsOperation); | 169 DISALLOW_COPY_AND_ASSIGN(StoreSettingsOperation); |
| 165 }; | 170 }; |
| 166 | 171 |
| 167 } // namespace chromeos | 172 } // namespace chromeos |
| 168 | 173 |
| 169 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ | 174 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SESSION_MANAGER_OPERATION_H_ |
| OLD | NEW |