Chromium Code Reviews| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 namespace chromeos { | 57 namespace chromeos { |
| 58 | 58 |
| 59 // static | 59 // static |
| 60 EnrollmentScreen* EnrollmentScreen::Get(ScreenManager* manager) { | 60 EnrollmentScreen* EnrollmentScreen::Get(ScreenManager* manager) { |
| 61 return static_cast<EnrollmentScreen*>( | 61 return static_cast<EnrollmentScreen*>( |
| 62 manager->GetScreen(WizardController::kEnrollmentScreenName)); | 62 manager->GetScreen(WizardController::kEnrollmentScreenName)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 EnrollmentScreen::EnrollmentScreen(BaseScreenDelegate* base_screen_delegate, | 65 EnrollmentScreen::EnrollmentScreen(BaseScreenDelegate* base_screen_delegate, |
| 66 EnrollmentScreenActor* actor) | 66 EnrollmentScreenActor* actor) |
| 67 : BaseScreen(base_screen_delegate), | 67 : BaseScreen(base_screen_delegate), actor_(actor), weak_ptr_factory_(this) { |
|
joth
2016/11/23 22:24:02
as a general guide use initializer list when you c
kumarniranjan
2016/11/24 18:12:46
Done.
| |
| 68 actor_(actor), | 68 policy_ = new net::BackoffEntry::Policy(); |
| 69 weak_ptr_factory_(this) {} | 69 policy_->num_errors_to_ignore = 0; |
| 70 policy_->initial_delay_ms = 4000; | |
| 71 policy_->multiply_factor = 2.0; | |
|
joth
2016/11/23 22:24:02
given we're using this to paper over the TPM init,
kumarniranjan
2016/11/24 18:12:46
Done.
| |
| 72 policy_->jitter_factor = 0.1; | |
| 73 policy_->maximum_backoff_ms = -1; | |
|
joth
2016/11/23 22:24:03
Lets cap the maximum delay to 8 minutes
kumarniranjan
2016/11/24 18:12:46
Done.
| |
| 74 policy_->entry_lifetime_ms = -1; | |
| 75 backoff_ = new net::BackoffEntry(policy_); | |
| 76 } | |
| 70 | 77 |
| 71 EnrollmentScreen::~EnrollmentScreen() { | 78 EnrollmentScreen::~EnrollmentScreen() { |
| 72 DCHECK(!enrollment_helper_ || g_browser_process->IsShuttingDown()); | 79 DCHECK(!enrollment_helper_ || g_browser_process->IsShuttingDown()); |
| 73 } | 80 } |
| 74 | 81 |
| 75 void EnrollmentScreen::SetParameters( | 82 void EnrollmentScreen::SetParameters( |
| 76 const policy::EnrollmentConfig& enrollment_config, | 83 const policy::EnrollmentConfig& enrollment_config, |
| 77 pairing_chromeos::ControllerPairingController* shark_controller) { | 84 pairing_chromeos::ControllerPairingController* shark_controller) { |
| 78 enrollment_config_ = enrollment_config; | 85 enrollment_config_ = enrollment_config; |
| 79 switch (enrollment_config_.auth_mechanism) { | 86 switch (enrollment_config_.auth_mechanism) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 // TODO(rsorokin): Move ShowAdJoin after STEP_REGISTRATION | 198 // TODO(rsorokin): Move ShowAdJoin after STEP_REGISTRATION |
| 192 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 199 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 193 chromeos::switches::kEnableAd)) { | 200 chromeos::switches::kEnableAd)) { |
| 194 actor_->ShowAdJoin(); | 201 actor_->ShowAdJoin(); |
| 195 } else { | 202 } else { |
| 196 OnAdJoined(""); | 203 OnAdJoined(""); |
| 197 } | 204 } |
| 198 } | 205 } |
| 199 | 206 |
| 200 void EnrollmentScreen::OnRetry() { | 207 void EnrollmentScreen::OnRetry() { |
| 201 Show(); | 208 Show(); |
|
joth
2016/11/23 22:24:02
is it safe to call this multiple times? (just wond
kumarniranjan
2016/11/24 18:12:46
The current UI without my changes allows for this
| |
| 202 } | 209 } |
| 203 | 210 |
| 204 void EnrollmentScreen::OnCancel() { | 211 void EnrollmentScreen::OnCancel() { |
| 205 if (AdvanceToNextAuth()) { | 212 if (AdvanceToNextAuth()) { |
| 206 Show(); | 213 Show(); |
| 207 return; | 214 return; |
| 208 } | 215 } |
| 209 | 216 |
| 210 UMA(policy::kMetricEnrollmentCancelled); | 217 UMA(policy::kMetricEnrollmentCancelled); |
| 211 if (elapsed_timer_) | 218 if (elapsed_timer_) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 LOG(WARNING) << "Enrollment error occured: status=" << status.status() | 253 LOG(WARNING) << "Enrollment error occured: status=" << status.status() |
| 247 << " http status=" << status.http_status() | 254 << " http status=" << status.http_status() |
| 248 << " DM status=" << status.client_status(); | 255 << " DM status=" << status.client_status(); |
| 249 RecordEnrollmentErrorMetrics(); | 256 RecordEnrollmentErrorMetrics(); |
| 250 // If the DM server does not have a device pre-provisioned for attestation- | 257 // If the DM server does not have a device pre-provisioned for attestation- |
| 251 // based enrollment and we have a fallback authentication, show it. | 258 // based enrollment and we have a fallback authentication, show it. |
| 252 if (status.status() == policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED && | 259 if (status.status() == policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED && |
| 253 status.client_status() == policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND && | 260 status.client_status() == policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND && |
| 254 current_auth_ == AUTH_ATTESTATION && AdvanceToNextAuth()) | 261 current_auth_ == AUTH_ATTESTATION && AdvanceToNextAuth()) |
| 255 Show(); | 262 Show(); |
| 256 else | 263 else { |
| 257 actor_->ShowEnrollmentStatus(status); | 264 actor_->ShowEnrollmentStatus(status); |
| 265 if (policy::DeviceCloudPolicyManagerChromeOS:: | |
| 266 GetZeroTouchEnrollmentMode() == | |
| 267 policy::ZeroTouchEnrollmentMode::HANDS_OFF) { | |
| 268 backoff_->InformOfRequest(false); | |
| 269 timer_.Start(FROM_HERE, backoff_->GetTimeUntilRelease(), | |
| 270 base::Bind(&EnrollmentScreen::OnRetry, | |
|
joth
2016/11/23 22:24:02
I don't have a strong preference, but it maybe cle
kumarniranjan
2016/11/24 18:12:46
I agree. I ended up calling the method "ProcessRet
| |
| 271 weak_ptr_factory_.GetWeakPtr())); | |
| 272 } | |
| 273 } | |
| 258 } | 274 } |
| 259 | 275 |
| 260 void EnrollmentScreen::OnOtherError( | 276 void EnrollmentScreen::OnOtherError( |
| 261 EnterpriseEnrollmentHelper::OtherError error) { | 277 EnterpriseEnrollmentHelper::OtherError error) { |
|
joth
2016/11/23 22:24:02
Wonder if we should retry here too?
https://cs.ch
kumarniranjan
2016/11/24 18:12:46
Considering we are in hands-off mode, it can't hur
| |
| 262 RecordEnrollmentErrorMetrics(); | 278 RecordEnrollmentErrorMetrics(); |
| 263 actor_->ShowOtherError(error); | 279 actor_->ShowOtherError(error); |
| 264 } | 280 } |
| 265 | 281 |
| 266 void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) { | 282 void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) { |
| 267 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. | 283 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. |
| 268 LOG(WARNING) << "Device is successfully enrolled."; | 284 LOG(WARNING) << "Device is successfully enrolled."; |
| 269 if (!additional_token.empty()) | 285 if (!additional_token.empty()) |
| 270 SendEnrollmentAuthToken(additional_token); | 286 SendEnrollmentAuthToken(additional_token); |
| 271 | 287 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 std::string location = policy ? policy->annotated_location() : std::string(); | 340 std::string location = policy ? policy->annotated_location() : std::string(); |
| 325 actor_->ShowAttributePromptScreen(asset_id, location); | 341 actor_->ShowAttributePromptScreen(asset_id, location); |
| 326 } | 342 } |
| 327 | 343 |
| 328 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { | 344 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { |
| 329 DCHECK(shark_controller_); | 345 DCHECK(shark_controller_); |
| 330 shark_controller_->OnAuthenticationDone(enrolling_user_domain_, token); | 346 shark_controller_->OnAuthenticationDone(enrolling_user_domain_, token); |
| 331 } | 347 } |
| 332 | 348 |
| 333 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() { | 349 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() { |
| 350 backoff_->InformOfRequest(true); | |
| 334 if (elapsed_timer_) | 351 if (elapsed_timer_) |
| 335 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_); | 352 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_); |
| 336 actor_->ShowEnrollmentStatus(policy::EnrollmentStatus::ForStatus( | 353 actor_->ShowEnrollmentStatus(policy::EnrollmentStatus::ForStatus( |
| 337 policy::EnrollmentStatus::STATUS_SUCCESS)); | 354 policy::EnrollmentStatus::STATUS_SUCCESS)); |
| 338 } | 355 } |
| 339 | 356 |
| 340 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { | 357 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { |
| 341 EnrollmentUMA(sample, config_.mode); | 358 EnrollmentUMA(sample, config_.mode); |
| 342 } | 359 } |
| 343 | 360 |
| 344 void EnrollmentScreen::ShowSigninScreen() { | 361 void EnrollmentScreen::ShowSigninScreen() { |
| 345 actor_->Show(); | 362 actor_->Show(); |
| 346 actor_->ShowSigninScreen(); | 363 actor_->ShowSigninScreen(); |
| 347 } | 364 } |
| 348 | 365 |
| 349 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { | 366 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { |
| 350 enrollment_failed_once_ = true; | 367 enrollment_failed_once_ = true; |
| 351 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? | 368 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? |
| 352 if (elapsed_timer_) | 369 if (elapsed_timer_) |
| 353 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); | 370 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); |
| 354 } | 371 } |
| 355 | 372 |
| 356 } // namespace chromeos | 373 } // namespace chromeos |
| OLD | NEW |