| 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 #include "chrome/browser/chromeos/policy/enrollment_handler_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/enrollment_handler_chromeos.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return em::DeviceRegisterRequest::FLAVOR_ENROLLMENT_MANUAL; | 59 return em::DeviceRegisterRequest::FLAVOR_ENROLLMENT_MANUAL; |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace | 62 } // namespace |
| 63 | 63 |
| 64 EnrollmentHandlerChromeOS::EnrollmentHandlerChromeOS( | 64 EnrollmentHandlerChromeOS::EnrollmentHandlerChromeOS( |
| 65 DeviceCloudPolicyStoreChromeOS* store, | 65 DeviceCloudPolicyStoreChromeOS* store, |
| 66 EnterpriseInstallAttributes* install_attributes, | 66 EnterpriseInstallAttributes* install_attributes, |
| 67 ServerBackedStateKeysBroker* state_keys_broker, | 67 ServerBackedStateKeysBroker* state_keys_broker, |
| 68 chromeos::OwnerSettingsServiceChromeOS* owner_settings_service, | 68 chromeos::OwnerSettingsServiceChromeOS* owner_settings_service, |
| 69 scoped_ptr<CloudPolicyClient> client, | 69 std::unique_ptr<CloudPolicyClient> client, |
| 70 scoped_refptr<base::SequencedTaskRunner> background_task_runner, | 70 scoped_refptr<base::SequencedTaskRunner> background_task_runner, |
| 71 const EnrollmentConfig& enrollment_config, | 71 const EnrollmentConfig& enrollment_config, |
| 72 const std::string& auth_token, | 72 const std::string& auth_token, |
| 73 const std::string& client_id, | 73 const std::string& client_id, |
| 74 const std::string& requisition, | 74 const std::string& requisition, |
| 75 const AllowedDeviceModes& allowed_device_modes, | 75 const AllowedDeviceModes& allowed_device_modes, |
| 76 ManagementMode management_mode, | 76 ManagementMode management_mode, |
| 77 const EnrollmentCallback& completion_callback) | 77 const EnrollmentCallback& completion_callback) |
| 78 : store_(store), | 78 : store_(store), |
| 79 install_attributes_(install_attributes), | 79 install_attributes_(install_attributes), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 109 } | 109 } |
| 110 | 110 |
| 111 void EnrollmentHandlerChromeOS::StartEnrollment() { | 111 void EnrollmentHandlerChromeOS::StartEnrollment() { |
| 112 CHECK_EQ(STEP_PENDING, enrollment_step_); | 112 CHECK_EQ(STEP_PENDING, enrollment_step_); |
| 113 enrollment_step_ = STEP_STATE_KEYS; | 113 enrollment_step_ = STEP_STATE_KEYS; |
| 114 state_keys_broker_->RequestStateKeys( | 114 state_keys_broker_->RequestStateKeys( |
| 115 base::Bind(&EnrollmentHandlerChromeOS::HandleStateKeysResult, | 115 base::Bind(&EnrollmentHandlerChromeOS::HandleStateKeysResult, |
| 116 weak_ptr_factory_.GetWeakPtr())); | 116 weak_ptr_factory_.GetWeakPtr())); |
| 117 } | 117 } |
| 118 | 118 |
| 119 scoped_ptr<CloudPolicyClient> EnrollmentHandlerChromeOS::ReleaseClient() { | 119 std::unique_ptr<CloudPolicyClient> EnrollmentHandlerChromeOS::ReleaseClient() { |
| 120 Stop(); | 120 Stop(); |
| 121 return std::move(client_); | 121 return std::move(client_); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void EnrollmentHandlerChromeOS::OnPolicyFetched(CloudPolicyClient* client) { | 124 void EnrollmentHandlerChromeOS::OnPolicyFetched(CloudPolicyClient* client) { |
| 125 DCHECK_EQ(client_.get(), client); | 125 DCHECK_EQ(client_.get(), client); |
| 126 CHECK_EQ(STEP_POLICY_FETCH, enrollment_step_); | 126 CHECK_EQ(STEP_POLICY_FETCH, enrollment_step_); |
| 127 | 127 |
| 128 enrollment_step_ = STEP_VALIDATION; | 128 enrollment_step_ = STEP_VALIDATION; |
| 129 | 129 |
| 130 // Validate the policy. | 130 // Validate the policy. |
| 131 const em::PolicyFetchResponse* policy = client_->GetPolicyFor( | 131 const em::PolicyFetchResponse* policy = client_->GetPolicyFor( |
| 132 dm_protocol::kChromeDevicePolicyType, std::string()); | 132 dm_protocol::kChromeDevicePolicyType, std::string()); |
| 133 if (!policy) { | 133 if (!policy) { |
| 134 ReportResult(EnrollmentStatus::ForFetchError( | 134 ReportResult(EnrollmentStatus::ForFetchError( |
| 135 DM_STATUS_RESPONSE_DECODING_ERROR)); | 135 DM_STATUS_RESPONSE_DECODING_ERROR)); |
| 136 return; | 136 return; |
| 137 } | 137 } |
| 138 | 138 |
| 139 scoped_ptr<DeviceCloudPolicyValidator> validator( | 139 std::unique_ptr<DeviceCloudPolicyValidator> validator( |
| 140 DeviceCloudPolicyValidator::Create( | 140 DeviceCloudPolicyValidator::Create( |
| 141 scoped_ptr<em::PolicyFetchResponse>( | 141 std::unique_ptr<em::PolicyFetchResponse>( |
| 142 new em::PolicyFetchResponse(*policy)), | 142 new em::PolicyFetchResponse(*policy)), |
| 143 background_task_runner_)); | 143 background_task_runner_)); |
| 144 | 144 |
| 145 validator->ValidateTimestamp(base::Time(), base::Time::NowFromSystemTime(), | 145 validator->ValidateTimestamp(base::Time(), base::Time::NowFromSystemTime(), |
| 146 CloudPolicyValidatorBase::TIMESTAMP_REQUIRED); | 146 CloudPolicyValidatorBase::TIMESTAMP_REQUIRED); |
| 147 | 147 |
| 148 // If this is re-enrollment, make sure that the new policy matches the | 148 // If this is re-enrollment, make sure that the new policy matches the |
| 149 // previously-enrolled domain. | 149 // previously-enrolled domain. |
| 150 std::string domain; | 150 std::string domain; |
| 151 if (install_attributes_->IsEnterpriseDevice()) { | 151 if (install_attributes_->IsEnterpriseDevice()) { |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 << ", validation: " << status.validation_status() | 490 << ", validation: " << status.validation_status() |
| 491 << ", store: " << status.store_status() | 491 << ", store: " << status.store_status() |
| 492 << ", lock: " << status.lock_status(); | 492 << ", lock: " << status.lock_status(); |
| 493 } | 493 } |
| 494 | 494 |
| 495 if (!callback.is_null()) | 495 if (!callback.is_null()) |
| 496 callback.Run(status); | 496 callback.Run(status); |
| 497 } | 497 } |
| 498 | 498 |
| 499 } // namespace policy | 499 } // namespace policy |
| OLD | NEW |