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/consumer_enrollment_handler.h" | 5 #include "chrome/browser/chromeos/policy/consumer_enrollment_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/browser_process_platform_part.h" | 13 #include "chrome/browser/browser_process_platform_part.h" |
14 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" | |
14 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 15 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
15 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" | 16 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" |
16 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" | 17 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" |
18 #include "chrome/browser/profiles/profile.h" | |
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
18 #include "chrome/browser/signin/signin_manager_factory.h" | 20 #include "chrome/browser/signin/signin_manager_factory.h" |
19 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 21 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
20 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 22 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
21 #include "components/signin/core/browser/signin_manager_base.h" | 23 #include "components/signin/core/browser/signin_manager_base.h" |
22 #include "google_apis/gaia/gaia_constants.h" | 24 #include "google_apis/gaia/gaia_constants.h" |
23 #include "google_apis/gaia/google_service_auth_error.h" | 25 #include "google_apis/gaia/google_service_auth_error.h" |
24 | 26 |
25 namespace policy { | 27 namespace policy { |
26 | 28 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 BrowserPolicyConnectorChromeOS* connector = | 104 BrowserPolicyConnectorChromeOS* connector = |
103 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 105 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
104 DeviceCloudPolicyInitializer* initializer = | 106 DeviceCloudPolicyInitializer* initializer = |
105 connector->GetDeviceCloudPolicyInitializer(); | 107 connector->GetDeviceCloudPolicyInitializer(); |
106 CHECK(initializer); | 108 CHECK(initializer); |
107 | 109 |
108 policy::DeviceCloudPolicyInitializer::AllowedDeviceModes device_modes; | 110 policy::DeviceCloudPolicyInitializer::AllowedDeviceModes device_modes; |
109 device_modes[policy::DEVICE_MODE_ENTERPRISE] = true; | 111 device_modes[policy::DEVICE_MODE_ENTERPRISE] = true; |
110 | 112 |
111 initializer->StartEnrollment( | 113 initializer->StartEnrollment( |
112 MANAGEMENT_MODE_CONSUMER_MANAGED, | 114 MANAGEMENT_MODE_CONSUMER_MANAGED, device_management_service_, |
davidyu
2014/12/03 16:06:04
Put each parameter at its own line.
| |
113 device_management_service_, | 115 chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext( |
116 profile_), | |
114 access_token, | 117 access_token, |
115 false, // is_auto_enrollment | 118 false, // is_auto_enrollment |
116 device_modes, | 119 device_modes, |
117 base::Bind(&ConsumerEnrollmentHandler::OnEnrollmentCompleted, | 120 base::Bind(&ConsumerEnrollmentHandler::OnEnrollmentCompleted, |
118 weak_ptr_factory_.GetWeakPtr())); | 121 weak_ptr_factory_.GetWeakPtr())); |
119 } | 122 } |
120 | 123 |
121 void ConsumerEnrollmentHandler::OnEnrollmentCompleted(EnrollmentStatus status) { | 124 void ConsumerEnrollmentHandler::OnEnrollmentCompleted(EnrollmentStatus status) { |
122 if (status.status() != EnrollmentStatus::STATUS_SUCCESS) { | 125 if (status.status() != EnrollmentStatus::STATUS_SUCCESS) { |
123 LOG(ERROR) << "Failed to enroll the device." | 126 LOG(ERROR) << "Failed to enroll the device." |
124 << " status=" << status.status() | 127 << " status=" << status.status() |
125 << " client_status=" << status.client_status() | 128 << " client_status=" << status.client_status() |
126 << " http_status=" << status.http_status() | 129 << " http_status=" << status.http_status() |
127 << " store_status=" << status.store_status() | 130 << " store_status=" << status.store_status() |
128 << " validation_status=" << status.validation_status(); | 131 << " validation_status=" << status.validation_status(); |
129 EndEnrollment(ConsumerManagementService::ENROLLMENT_STAGE_DM_SERVER_FAILED); | 132 EndEnrollment(ConsumerManagementService::ENROLLMENT_STAGE_DM_SERVER_FAILED); |
130 return; | 133 return; |
131 } | 134 } |
132 | 135 |
133 EndEnrollment(ConsumerManagementService::ENROLLMENT_STAGE_SUCCESS); | 136 EndEnrollment(ConsumerManagementService::ENROLLMENT_STAGE_SUCCESS); |
134 } | 137 } |
135 | 138 |
136 void ConsumerEnrollmentHandler::EndEnrollment( | 139 void ConsumerEnrollmentHandler::EndEnrollment( |
137 ConsumerManagementService::EnrollmentStage stage) { | 140 ConsumerManagementService::EnrollmentStage stage) { |
138 consumer_management_service_->SetEnrollmentStage(stage); | 141 consumer_management_service_->SetEnrollmentStage(stage); |
139 } | 142 } |
140 | 143 |
141 } // namespace policy | 144 } // namespace policy |
OLD | NEW |