| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 DeviceCloudPolicyManagerChromeOS* manager, | 65 DeviceCloudPolicyManagerChromeOS* manager, |
| 66 cryptohome::AsyncMethodCaller* async_method_caller, | 66 cryptohome::AsyncMethodCaller* async_method_caller, |
| 67 std::unique_ptr<chromeos::attestation::AttestationFlow> attestation_flow) | 67 std::unique_ptr<chromeos::attestation::AttestationFlow> attestation_flow) |
| 68 : local_state_(local_state), | 68 : local_state_(local_state), |
| 69 enterprise_service_(enterprise_service), | 69 enterprise_service_(enterprise_service), |
| 70 background_task_runner_(background_task_runner), | 70 background_task_runner_(background_task_runner), |
| 71 install_attributes_(install_attributes), | 71 install_attributes_(install_attributes), |
| 72 state_keys_broker_(state_keys_broker), | 72 state_keys_broker_(state_keys_broker), |
| 73 device_store_(device_store), | 73 device_store_(device_store), |
| 74 manager_(manager), | 74 manager_(manager), |
| 75 attestation_flow_(std::move(attestation_flow)), | 75 attestation_flow_(std::move(attestation_flow)) { |
| 76 signing_service_(async_method_caller) {} | 76 default_signing_service_.reset( |
| 77 new TpmEnrollmentKeySigningService(async_method_caller)); |
| 78 signing_service_ = default_signing_service_.get(); |
| 79 } |
| 80 |
| 81 void DeviceCloudPolicyInitializer::SetSigningServiceForTesting( |
| 82 policy::SigningService* signing_service) { |
| 83 signing_service_ = signing_service; |
| 84 } |
| 77 | 85 |
| 78 DeviceCloudPolicyInitializer::~DeviceCloudPolicyInitializer() { | 86 DeviceCloudPolicyInitializer::~DeviceCloudPolicyInitializer() { |
| 79 DCHECK(!is_initialized_); | 87 DCHECK(!is_initialized_); |
| 80 } | 88 } |
| 81 | 89 |
| 82 void DeviceCloudPolicyInitializer::Init() { | 90 void DeviceCloudPolicyInitializer::Init() { |
| 83 DCHECK(!is_initialized_); | 91 DCHECK(!is_initialized_); |
| 84 | 92 |
| 85 is_initialized_ = true; | 93 is_initialized_ = true; |
| 86 device_store_->AddObserver(this); | 94 device_store_->AddObserver(this); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 if (!enrollment_callback.is_null()) | 258 if (!enrollment_callback.is_null()) |
| 251 enrollment_callback.Run(status); | 259 enrollment_callback.Run(status); |
| 252 } | 260 } |
| 253 | 261 |
| 254 std::unique_ptr<CloudPolicyClient> DeviceCloudPolicyInitializer::CreateClient( | 262 std::unique_ptr<CloudPolicyClient> DeviceCloudPolicyInitializer::CreateClient( |
| 255 DeviceManagementService* device_management_service) { | 263 DeviceManagementService* device_management_service) { |
| 256 return base::MakeUnique<CloudPolicyClient>( | 264 return base::MakeUnique<CloudPolicyClient>( |
| 257 DeviceCloudPolicyManagerChromeOS::GetMachineID(), | 265 DeviceCloudPolicyManagerChromeOS::GetMachineID(), |
| 258 DeviceCloudPolicyManagerChromeOS::GetMachineModel(), | 266 DeviceCloudPolicyManagerChromeOS::GetMachineModel(), |
| 259 kPolicyVerificationKeyHash, device_management_service, | 267 kPolicyVerificationKeyHash, device_management_service, |
| 260 g_browser_process->system_request_context(), &signing_service_); | 268 g_browser_process->system_request_context(), signing_service_); |
| 261 } | 269 } |
| 262 | 270 |
| 263 void DeviceCloudPolicyInitializer::TryToCreateClient() { | 271 void DeviceCloudPolicyInitializer::TryToCreateClient() { |
| 264 if (!device_store_->is_initialized() || | 272 if (!device_store_->is_initialized() || |
| 265 !device_store_->has_policy() || | 273 !device_store_->has_policy() || |
| 266 state_keys_broker_->pending() || | 274 state_keys_broker_->pending() || |
| 267 enrollment_handler_) { | 275 enrollment_handler_) { |
| 268 return; | 276 return; |
| 269 } | 277 } |
| 270 StartConnection(CreateClient(enterprise_service_)); | 278 StartConnection(CreateClient(enterprise_service_)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 if (success && (success = att_signed_data.ParseFromString(signed_data))) { | 319 if (success && (success = att_signed_data.ParseFromString(signed_data))) { |
| 312 em_signed_data.set_data(att_signed_data.data()); | 320 em_signed_data.set_data(att_signed_data.data()); |
| 313 em_signed_data.set_signature(att_signed_data.signature()); | 321 em_signed_data.set_signature(att_signed_data.signature()); |
| 314 em_signed_data.set_extra_data_bytes(att_signed_data.data().size() - | 322 em_signed_data.set_extra_data_bytes(att_signed_data.data().size() - |
| 315 data.size()); | 323 data.size()); |
| 316 } | 324 } |
| 317 callback.Run(success, em_signed_data); | 325 callback.Run(success, em_signed_data); |
| 318 } | 326 } |
| 319 | 327 |
| 320 } // namespace policy | 328 } // namespace policy |
| OLD | NEW |