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