Chromium Code Reviews| Index: chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc |
| diff --git a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc |
| index ad963ff0a8149ae14e18e0f5b6a2f8d913d46fcf..ceee93444b401caffcf6eb89ea0b4f72bef61086 100644 |
| --- a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc |
| +++ b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc |
| @@ -10,12 +10,15 @@ |
| #include "base/message_loop/message_loop.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" |
| +#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
| #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" |
| +#include "chrome/browser/chromeos/profiles/profile_helper.h" |
| #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
| #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h" |
| #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| +#include "chrome/browser/profiles/profile.h" |
| #include "chromeos/chromeos_switches.h" |
| #include "google_apis/gaia/gaia_urls.h" |
| #include "net/http/http_status_code.h" |
| @@ -43,6 +46,7 @@ EnrollmentHandlerChromeOS::EnrollmentHandlerChromeOS( |
| EnterpriseInstallAttributes* install_attributes, |
| ServerBackedStateKeysBroker* state_keys_broker, |
| chromeos::DeviceSettingsService* device_settings_service, |
| + chromeos::OwnerSettingsServiceChromeOS* owner_settings_service, |
| scoped_ptr<CloudPolicyClient> client, |
| scoped_refptr<base::SequencedTaskRunner> background_task_runner, |
| const std::string& auth_token, |
| @@ -56,6 +60,7 @@ EnrollmentHandlerChromeOS::EnrollmentHandlerChromeOS( |
| install_attributes_(install_attributes), |
| state_keys_broker_(state_keys_broker), |
| device_settings_service_(device_settings_service), |
| + owner_settings_service_(owner_settings_service), |
| client_(client.Pass()), |
| background_task_runner_(background_task_runner), |
| auth_token_(auth_token), |
| @@ -206,10 +211,11 @@ void EnrollmentHandlerChromeOS::OnStoreLoaded(CloudPolicyStore* store) { |
| void EnrollmentHandlerChromeOS::OnStoreError(CloudPolicyStore* store) { |
| DCHECK_EQ(store_, store); |
| if (enrollment_step_ == STEP_STORE_TOKEN_AND_ID) { |
| - // Calling DeviceSettingsService::SetManagementSettings() on a non- |
| - // enterprise-managed device will trigger OnStoreError(), as |
| - // DeviceCloudPolicyStore listens to all changes on DeviceSettingsService, |
| - // and it calls OnStoreError() when the device is not enterprise-managed. |
| + // Calling OwnerSettingsServiceChromeOS::SetManagementSettings() |
| + // on a non- enterprise-managed device will fail as |
| + // DeviceCloudPolicyStore listens to all changes on device |
| + // settings, and it calls OnStoreError() when the device is not |
| + // enterprise-managed. |
| return; |
| } |
| ReportResult(EnrollmentStatus::ForStoreError(store_->status(), |
| @@ -346,8 +352,12 @@ void EnrollmentHandlerChromeOS::StartLockDevice() { |
| // Consumer device enrollment doesn't use install attributes. Instead, |
| // we put the information in the owners settings. |
| enrollment_step_ = STEP_STORE_TOKEN_AND_ID; |
|
davidyu
2014/12/03 16:06:04
CHECK(owner_settings_service_);
ygorshenin1
2014/12/04 10:27:23
Done.
|
| - device_settings_service_->SetManagementSettings( |
| - em::PolicyData::CONSUMER_MANAGED, request_token_, device_id_, |
| + chromeos::OwnerSettingsServiceChromeOS::ManagementSettings settings; |
| + settings.management_mode = management_mode_; |
| + settings.request_token = request_token_; |
| + settings.device_id = device_id_; |
| + owner_settings_service_->SetManagementSettings( |
| + settings, |
| base::Bind(&EnrollmentHandlerChromeOS::HandleSetManagementSettingsDone, |
| weak_ptr_factory_.GetWeakPtr())); |
| } else { |
| @@ -358,10 +368,9 @@ void EnrollmentHandlerChromeOS::StartLockDevice() { |
| } |
| } |
| -void EnrollmentHandlerChromeOS::HandleSetManagementSettingsDone() { |
| +void EnrollmentHandlerChromeOS::HandleSetManagementSettingsDone(bool success) { |
| CHECK_EQ(STEP_STORE_TOKEN_AND_ID, enrollment_step_); |
| - if (device_settings_service_->status() != |
| - chromeos::DeviceSettingsService::STORE_SUCCESS) { |
| + if (!success) { |
| ReportResult(EnrollmentStatus::ForStatus( |
| EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED)); |
| return; |