| 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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h" | 18 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h" |
| 18 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 19 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 19 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 20 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 20 #include "chrome/browser/chromeos/policy/device_status_collector.h" | 21 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
| 21 #include "chrome/browser/chromeos/policy/enrollment_config.h" | 22 #include "chrome/browser/chromeos/policy/enrollment_config.h" |
| 22 #include "chrome/browser/chromeos/policy/enrollment_handler_chromeos.h" | 23 #include "chrome/browser/chromeos/policy/enrollment_handler_chromeos.h" |
| 23 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" | 24 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" |
| 24 #include "chrome/browser/chromeos/policy/server_backed_device_state.h" | 25 #include "chrome/browser/chromeos/policy/server_backed_device_state.h" |
| 25 #include "chrome/browser/chromeos/settings/install_attributes.h" | 26 #include "chrome/browser/chromeos/settings/install_attributes.h" |
| 26 #include "chrome/common/chrome_content_client.h" | 27 #include "chrome/common/chrome_content_client.h" |
| 27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 28 #include "chromeos/attestation/attestation.pb.h" | 29 #include "chromeos/attestation/attestation.pb.h" |
| 29 #include "chromeos/attestation/attestation_flow.h" | 30 #include "chromeos/attestation/attestation_flow.h" |
| 30 #include "chromeos/chromeos_switches.h" | 31 #include "chromeos/chromeos_switches.h" |
| 31 #include "chromeos/cryptohome/async_method_caller.h" | 32 #include "chromeos/cryptohome/async_method_caller.h" |
| 32 #include "chromeos/cryptohome/cryptohome_parameters.h" | 33 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 33 #include "chromeos/system/statistics_provider.h" | 34 #include "chromeos/system/statistics_provider.h" |
| 34 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 35 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 35 #include "components/policy/core/common/cloud/device_management_service.h" | 36 #include "components/policy/core/common/cloud/device_management_service.h" |
| 36 #include "components/prefs/pref_service.h" | 37 #include "components/prefs/pref_service.h" |
| 37 #include "net/url_request/url_request_context_getter.h" | 38 #include "net/url_request/url_request_context_getter.h" |
| 38 | 39 |
| 40 namespace chromeos { |
| 41 class ActiveDirectoryJoinDelegate; |
| 42 } |
| 43 |
| 39 namespace policy { | 44 namespace policy { |
| 40 | 45 |
| 41 DeviceCloudPolicyInitializer::DeviceCloudPolicyInitializer( | 46 DeviceCloudPolicyInitializer::DeviceCloudPolicyInitializer( |
| 42 PrefService* local_state, | 47 PrefService* local_state, |
| 43 DeviceManagementService* enterprise_service, | 48 DeviceManagementService* enterprise_service, |
| 44 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | 49 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
| 45 chromeos::InstallAttributes* install_attributes, | 50 chromeos::InstallAttributes* install_attributes, |
| 46 ServerBackedStateKeysBroker* state_keys_broker, | 51 ServerBackedStateKeysBroker* state_keys_broker, |
| 47 DeviceCloudPolicyStoreChromeOS* device_store, | 52 DeviceCloudPolicyStoreChromeOS* device_store, |
| 48 DeviceCloudPolicyManagerChromeOS* manager, | 53 DeviceCloudPolicyManagerChromeOS* manager, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 DCHECK(is_initialized_); | 91 DCHECK(is_initialized_); |
| 87 | 92 |
| 88 device_store_->RemoveObserver(this); | 93 device_store_->RemoveObserver(this); |
| 89 enrollment_handler_.reset(); | 94 enrollment_handler_.reset(); |
| 90 state_keys_update_subscription_.reset(); | 95 state_keys_update_subscription_.reset(); |
| 91 is_initialized_ = false; | 96 is_initialized_ = false; |
| 92 } | 97 } |
| 93 | 98 |
| 94 void DeviceCloudPolicyInitializer::StartEnrollment( | 99 void DeviceCloudPolicyInitializer::StartEnrollment( |
| 95 DeviceManagementService* device_management_service, | 100 DeviceManagementService* device_management_service, |
| 101 chromeos::ActiveDirectoryJoinDelegate* ad_join_delegate, |
| 96 const EnrollmentConfig& enrollment_config, | 102 const EnrollmentConfig& enrollment_config, |
| 97 const std::string& auth_token, | 103 const std::string& auth_token, |
| 98 const EnrollmentCallback& enrollment_callback) { | 104 const EnrollmentCallback& enrollment_callback) { |
| 99 DCHECK(is_initialized_); | 105 DCHECK(is_initialized_); |
| 100 DCHECK(!enrollment_handler_); | 106 DCHECK(!enrollment_handler_); |
| 101 | 107 |
| 102 manager_->core()->Disconnect(); | 108 manager_->core()->Disconnect(); |
| 103 // TODO(rsorokin): make proper SetDeviceRequisition | 109 // TODO(rsorokin): Remove that once DM server does not require requisition. |
| 104 if (!enrollment_config.management_realm.empty()) | 110 // See crbug.com/668455 |
| 111 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 112 chromeos::switches::kEnableAd)) { |
| 105 manager_->SetDeviceRequisition("chrome_ad"); | 113 manager_->SetDeviceRequisition("chrome_ad"); |
| 114 } |
| 106 | 115 |
| 107 enrollment_handler_.reset(new EnrollmentHandlerChromeOS( | 116 enrollment_handler_.reset(new EnrollmentHandlerChromeOS( |
| 108 device_store_, install_attributes_, state_keys_broker_, | 117 device_store_, install_attributes_, state_keys_broker_, |
| 109 attestation_flow_.get(), CreateClient(device_management_service), | 118 attestation_flow_.get(), CreateClient(device_management_service), |
| 110 background_task_runner_, enrollment_config, auth_token, | 119 background_task_runner_, ad_join_delegate, enrollment_config, auth_token, |
| 111 install_attributes_->GetDeviceId(), manager_->GetDeviceRequisition(), | 120 install_attributes_->GetDeviceId(), manager_->GetDeviceRequisition(), |
| 112 base::Bind(&DeviceCloudPolicyInitializer::EnrollmentCompleted, | 121 base::Bind(&DeviceCloudPolicyInitializer::EnrollmentCompleted, |
| 113 base::Unretained(this), enrollment_callback))); | 122 base::Unretained(this), enrollment_callback))); |
| 114 enrollment_handler_->StartEnrollment(); | 123 enrollment_handler_->StartEnrollment(); |
| 115 } | 124 } |
| 116 | 125 |
| 117 EnrollmentConfig DeviceCloudPolicyInitializer::GetPrescribedEnrollmentConfig() | 126 EnrollmentConfig DeviceCloudPolicyInitializer::GetPrescribedEnrollmentConfig() |
| 118 const { | 127 const { |
| 119 EnrollmentConfig config; | 128 EnrollmentConfig config; |
| 120 | 129 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 if (success && (success = att_signed_data.ParseFromString(signed_data))) { | 338 if (success && (success = att_signed_data.ParseFromString(signed_data))) { |
| 330 em_signed_data.set_data(att_signed_data.data()); | 339 em_signed_data.set_data(att_signed_data.data()); |
| 331 em_signed_data.set_signature(att_signed_data.signature()); | 340 em_signed_data.set_signature(att_signed_data.signature()); |
| 332 em_signed_data.set_extra_data_bytes(att_signed_data.data().size() - | 341 em_signed_data.set_extra_data_bytes(att_signed_data.data().size() - |
| 333 data.size()); | 342 data.size()); |
| 334 } | 343 } |
| 335 callback.Run(success, em_signed_data); | 344 callback.Run(success, em_signed_data); |
| 336 } | 345 } |
| 337 | 346 |
| 338 } // namespace policy | 347 } // namespace policy |
| OLD | NEW |