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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 "Enterprise.EnrollmentTime.Failure"; | 50 "Enterprise.EnrollmentTime.Failure"; |
51 const char * const kMetricEnrollmentTimeSuccess = | 51 const char * const kMetricEnrollmentTimeSuccess = |
52 "Enterprise.EnrollmentTime.Success"; | 52 "Enterprise.EnrollmentTime.Success"; |
53 | 53 |
54 // Retry policy constants. | 54 // Retry policy constants. |
55 constexpr int kInitialDelayMS = 4 * 1000; // 4 seconds | 55 constexpr int kInitialDelayMS = 4 * 1000; // 4 seconds |
56 constexpr double kMultiplyFactor = 1.5; | 56 constexpr double kMultiplyFactor = 1.5; |
57 constexpr double kJitterFactor = 0.1; // +/- 10% jitter | 57 constexpr double kJitterFactor = 0.1; // +/- 10% jitter |
58 constexpr int64_t kMaxDelayMS = 8 * 60 * 1000; // 8 minutes | 58 constexpr int64_t kMaxDelayMS = 8 * 60 * 1000; // 8 minutes |
59 | 59 |
60 // Helper function. Returns true if we are using Hands Off Enrollment. | |
61 bool UsingHandsOffEnrollment() { | |
62 return policy::DeviceCloudPolicyManagerChromeOS:: | |
63 GetZeroTouchEnrollmentMode() == | |
64 policy::ZeroTouchEnrollmentMode::HANDS_OFF; | |
65 } | |
66 | |
67 } // namespace | 60 } // namespace |
68 | 61 |
69 namespace chromeos { | 62 namespace chromeos { |
70 | 63 |
71 // static | 64 // static |
72 EnrollmentScreen* EnrollmentScreen::Get(ScreenManager* manager) { | 65 EnrollmentScreen* EnrollmentScreen::Get(ScreenManager* manager) { |
73 return static_cast<EnrollmentScreen*>( | 66 return static_cast<EnrollmentScreen*>( |
74 manager->GetScreen(OobeScreen::SCREEN_OOBE_ENROLLMENT)); | 67 manager->GetScreen(OobeScreen::SCREEN_OOBE_ENROLLMENT)); |
75 } | 68 } |
76 | 69 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 << " DM status=" << status.client_status(); | 270 << " DM status=" << status.client_status(); |
278 RecordEnrollmentErrorMetrics(); | 271 RecordEnrollmentErrorMetrics(); |
279 // If the DM server does not have a device pre-provisioned for attestation- | 272 // If the DM server does not have a device pre-provisioned for attestation- |
280 // based enrollment and we have a fallback authentication, show it. | 273 // based enrollment and we have a fallback authentication, show it. |
281 if (status.status() == policy::EnrollmentStatus::REGISTRATION_FAILED && | 274 if (status.status() == policy::EnrollmentStatus::REGISTRATION_FAILED && |
282 status.client_status() == policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND && | 275 status.client_status() == policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND && |
283 current_auth_ == AUTH_ATTESTATION && AdvanceToNextAuth()) { | 276 current_auth_ == AUTH_ATTESTATION && AdvanceToNextAuth()) { |
284 Show(); | 277 Show(); |
285 } else { | 278 } else { |
286 view_->ShowEnrollmentStatus(status); | 279 view_->ShowEnrollmentStatus(status); |
287 if (UsingHandsOffEnrollment()) | 280 if (WizardController::UsingHandsOffEnrollment()) |
288 AutomaticRetry(); | 281 AutomaticRetry(); |
289 } | 282 } |
290 } | 283 } |
291 | 284 |
292 void EnrollmentScreen::OnOtherError( | 285 void EnrollmentScreen::OnOtherError( |
293 EnterpriseEnrollmentHelper::OtherError error) { | 286 EnterpriseEnrollmentHelper::OtherError error) { |
294 RecordEnrollmentErrorMetrics(); | 287 RecordEnrollmentErrorMetrics(); |
295 view_->ShowOtherError(error); | 288 view_->ShowOtherError(error); |
296 if (UsingHandsOffEnrollment()) | 289 if (WizardController::UsingHandsOffEnrollment()) |
297 AutomaticRetry(); | 290 AutomaticRetry(); |
298 } | 291 } |
299 | 292 |
300 void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) { | 293 void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) { |
301 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. | 294 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. |
302 LOG(WARNING) << "Device is successfully enrolled."; | 295 LOG(WARNING) << "Device is successfully enrolled."; |
303 if (!additional_token.empty()) | 296 if (!additional_token.empty()) |
304 SendEnrollmentAuthToken(additional_token); | 297 SendEnrollmentAuthToken(additional_token); |
305 | 298 |
306 enrollment_helper_->GetDeviceAttributeUpdatePermission(); | 299 enrollment_helper_->GetDeviceAttributeUpdatePermission(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 354 |
362 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { | 355 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { |
363 DCHECK(shark_controller_); | 356 DCHECK(shark_controller_); |
364 shark_controller_->OnAuthenticationDone(enrolling_user_domain_, token); | 357 shark_controller_->OnAuthenticationDone(enrolling_user_domain_, token); |
365 } | 358 } |
366 | 359 |
367 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() { | 360 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() { |
368 retry_backoff_->InformOfRequest(true); | 361 retry_backoff_->InformOfRequest(true); |
369 if (elapsed_timer_) | 362 if (elapsed_timer_) |
370 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_); | 363 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_); |
371 if (UsingHandsOffEnrollment()) { | 364 if (WizardController::UsingHandsOffEnrollment()) { |
372 OnConfirmationClosed(); | 365 OnConfirmationClosed(); |
373 } else { | 366 } else { |
374 view_->ShowEnrollmentStatus( | 367 view_->ShowEnrollmentStatus( |
375 policy::EnrollmentStatus::ForStatus(policy::EnrollmentStatus::SUCCESS)); | 368 policy::EnrollmentStatus::ForStatus(policy::EnrollmentStatus::SUCCESS)); |
376 } | 369 } |
377 } | 370 } |
378 | 371 |
379 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { | 372 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { |
380 EnrollmentUMA(sample, config_.mode); | 373 EnrollmentUMA(sample, config_.mode); |
381 } | 374 } |
382 | 375 |
383 void EnrollmentScreen::ShowSigninScreen() { | 376 void EnrollmentScreen::ShowSigninScreen() { |
384 view_->Show(); | 377 view_->Show(); |
385 view_->ShowSigninScreen(); | 378 view_->ShowSigninScreen(); |
386 } | 379 } |
387 | 380 |
388 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { | 381 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { |
389 enrollment_failed_once_ = true; | 382 enrollment_failed_once_ = true; |
390 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? | 383 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? |
391 if (elapsed_timer_) | 384 if (elapsed_timer_) |
392 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); | 385 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); |
393 } | 386 } |
394 | 387 |
395 void EnrollmentScreen::JoinDomain(OnDomainJoinedCallback on_joined_callback) { | 388 void EnrollmentScreen::JoinDomain(OnDomainJoinedCallback on_joined_callback) { |
396 on_joined_callback_ = std::move(on_joined_callback); | 389 on_joined_callback_ = std::move(on_joined_callback); |
397 view_->ShowAdJoin(); | 390 view_->ShowAdJoin(); |
398 } | 391 } |
399 | 392 |
400 } // namespace chromeos | 393 } // namespace chromeos |
OLD | NEW |