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/login/enrollment/enrollment_screen.h" | 5 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 void EnrollmentScreen::OnOtherError( | 221 void EnrollmentScreen::OnOtherError( |
222 EnterpriseEnrollmentHelper::OtherError error) { | 222 EnterpriseEnrollmentHelper::OtherError error) { |
223 OnAnyEnrollmentError(); | 223 OnAnyEnrollmentError(); |
224 actor_->ShowOtherError(error); | 224 actor_->ShowOtherError(error); |
225 } | 225 } |
226 | 226 |
227 void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) { | 227 void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) { |
228 if (!additional_token.empty()) | 228 if (!additional_token.empty()) |
229 SendEnrollmentAuthToken(additional_token); | 229 SendEnrollmentAuthToken(additional_token); |
230 StartupUtils::MarkDeviceRegistered( | 230 |
231 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess, | 231 enrollment_helper_->GetDeviceAttributeUpdatePermission(); |
232 weak_ptr_factory_.GetWeakPtr())); | 232 } |
| 233 |
| 234 void EnrollmentScreen::OnDeviceAttributeProvided(const std::string& asset_id, |
| 235 const std::string& location) { |
| 236 enrollment_helper_->UpdateDeviceAttributes(asset_id, location); |
| 237 } |
| 238 |
| 239 void EnrollmentScreen::OnDeviceAttributeUpdatePermission(bool granted) { |
| 240 // If user is permitted to update device attributes |
| 241 // Show attribute prompt screen |
| 242 if (granted) { |
| 243 StartupUtils::MarkDeviceRegistered( |
| 244 base::Bind(&EnrollmentScreen::ShowAttributePromptScreen, |
| 245 weak_ptr_factory_.GetWeakPtr())); |
| 246 } else { |
| 247 StartupUtils::MarkDeviceRegistered( |
| 248 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess, |
| 249 weak_ptr_factory_.GetWeakPtr())); |
| 250 } |
| 251 |
233 if (remora_controller_) { | 252 if (remora_controller_) { |
234 remora_controller_->OnEnrollmentStatusChanged( | 253 remora_controller_->OnEnrollmentStatusChanged( |
235 HostPairingController::ENROLLMENT_STATUS_SUCCESS); | 254 HostPairingController::ENROLLMENT_STATUS_SUCCESS); |
236 } | 255 } |
237 } | 256 } |
238 | 257 |
| 258 void EnrollmentScreen::OnDeviceAttributeUploadCompleted(bool success) { |
| 259 if (success) { |
| 260 actor_->ShowEnrollmentStatus(policy::EnrollmentStatus::ForStatus( |
| 261 policy::EnrollmentStatus::STATUS_SUCCESS)); |
| 262 } else { |
| 263 actor_->ShowEnrollmentStatus(policy::EnrollmentStatus::ForStatus( |
| 264 policy::EnrollmentStatus::STATUS_ATTRIBUTE_UPDATE_FAILED)); |
| 265 } |
| 266 } |
| 267 |
| 268 void EnrollmentScreen::ShowAttributePromptScreen() { |
| 269 policy::BrowserPolicyConnectorChromeOS* connector = |
| 270 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 271 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
| 272 connector->GetDeviceCloudPolicyManager(); |
| 273 |
| 274 policy::CloudPolicyStore* store = policy_manager->core()->store(); |
| 275 |
| 276 const enterprise_management::PolicyData* policy = store->policy(); |
| 277 |
| 278 std::string asset_id = policy ? policy->annotated_asset_id() : std::string(); |
| 279 std::string location = policy ? policy->annotated_location() : std::string(); |
| 280 actor_->ShowAttributePromptScreen(asset_id, location); |
| 281 } |
| 282 |
239 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { | 283 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { |
240 // TODO(achuith, zork): Extract and send domain. | 284 // TODO(achuith, zork): Extract and send domain. |
241 DCHECK(shark_controller_); | 285 DCHECK(shark_controller_); |
242 shark_controller_->OnAuthenticationDone("", token); | 286 shark_controller_->OnAuthenticationDone("", token); |
243 } | 287 } |
244 | 288 |
245 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() { | 289 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() { |
246 StartupUtils::MarkOobeCompleted(); | 290 StartupUtils::MarkOobeCompleted(); |
247 if (elapsed_timer_) | 291 if (elapsed_timer_) |
248 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_); | 292 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_); |
(...skipping 14 matching lines...) Expand all Loading... |
263 enrollment_failed_once_ = true; | 307 enrollment_failed_once_ = true; |
264 if (elapsed_timer_) | 308 if (elapsed_timer_) |
265 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); | 309 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); |
266 if (remora_controller_) { | 310 if (remora_controller_) { |
267 remora_controller_->OnEnrollmentStatusChanged( | 311 remora_controller_->OnEnrollmentStatusChanged( |
268 HostPairingController::ENROLLMENT_STATUS_FAILURE); | 312 HostPairingController::ENROLLMENT_STATUS_FAILURE); |
269 } | 313 } |
270 } | 314 } |
271 | 315 |
272 } // namespace chromeos | 316 } // namespace chromeos |
OLD | NEW |