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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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(OobeScreen::SCREEN_OOBE_ENROLLMENT)); | 62 manager->GetScreen(OobeScreen::SCREEN_OOBE_ENROLLMENT)); |
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, OobeScreen::SCREEN_OOBE_ENROLLMENT), | 67 : BaseScreen(base_screen_delegate, OobeScreen::SCREEN_OOBE_ENROLLMENT), |
68 actor_(actor), | 68 actor_(actor), |
69 weak_ptr_factory_(this) {} | 69 weak_ptr_factory_(this) { |
70 retry_policy_.num_errors_to_ignore = 0; | |
71 retry_policy_.initial_delay_ms = INITIAL_DELAY_MS; | |
72 retry_policy_.multiply_factor = MULTIPLY_FACTOR; | |
73 retry_policy_.jitter_factor = JITTER_FACTOR; | |
74 retry_policy_.maximum_backoff_ms = MAX_DELAY_MS; | |
75 retry_policy_.entry_lifetime_ms = -1; | |
76 retry_policy_.always_use_initial_delay = true; | |
77 retry_backoff_.reset(new net::BackoffEntry(&retry_policy_)); | |
78 } | |
70 | 79 |
71 EnrollmentScreen::~EnrollmentScreen() { | 80 EnrollmentScreen::~EnrollmentScreen() { |
72 DCHECK(!enrollment_helper_ || g_browser_process->IsShuttingDown()); | 81 DCHECK(!enrollment_helper_ || g_browser_process->IsShuttingDown()); |
73 } | 82 } |
74 | 83 |
75 void EnrollmentScreen::SetParameters( | 84 void EnrollmentScreen::SetParameters( |
76 const policy::EnrollmentConfig& enrollment_config, | 85 const policy::EnrollmentConfig& enrollment_config, |
77 pairing_chromeos::ControllerPairingController* shark_controller) { | 86 pairing_chromeos::ControllerPairingController* shark_controller) { |
78 enrollment_config_ = enrollment_config; | 87 enrollment_config_ = enrollment_config; |
79 switch (enrollment_config_.auth_mechanism) { | 88 switch (enrollment_config_.auth_mechanism) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 // TODO(rsorokin): Move ShowAdJoin after STEP_REGISTRATION | 192 // TODO(rsorokin): Move ShowAdJoin after STEP_REGISTRATION |
184 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 193 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
185 chromeos::switches::kEnableAd)) { | 194 chromeos::switches::kEnableAd)) { |
186 actor_->ShowAdJoin(); | 195 actor_->ShowAdJoin(); |
187 } else { | 196 } else { |
188 OnAdJoined(""); | 197 OnAdJoined(""); |
189 } | 198 } |
190 } | 199 } |
191 | 200 |
192 void EnrollmentScreen::OnRetry() { | 201 void EnrollmentScreen::OnRetry() { |
202 retry_task_.Cancel(); | |
203 LOG(WARNING) << "Enrollment retry " << ++num_retries_ | |
xiyuan
2017/02/01 23:01:51
Use a separate line for the increment instead of i
| |
204 << " initiated by user button press."; | |
205 ProcessRetry(); | |
206 } | |
207 | |
208 void EnrollmentScreen::AutomaticRetry() { | |
209 retry_backoff_->InformOfRequest(false); | |
210 retry_task_.Reset(base::Bind(&EnrollmentScreen::ProcessRetry, | |
211 weak_ptr_factory_.GetWeakPtr())); | |
212 | |
213 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
214 FROM_HERE, retry_task_.callback(), retry_backoff_->GetTimeUntilRelease()); | |
215 LOG(WARNING) << "Enrollment retry " << ++num_retries_ | |
xiyuan
2017/02/01 23:01:51
smilar here, move ++num_retries_ out of LOG line.
| |
216 << " initiated by timer."; | |
217 } | |
218 | |
219 void EnrollmentScreen::ProcessRetry() { | |
193 Show(); | 220 Show(); |
194 } | 221 } |
195 | 222 |
196 void EnrollmentScreen::OnCancel() { | 223 void EnrollmentScreen::OnCancel() { |
197 if (AdvanceToNextAuth()) { | 224 if (AdvanceToNextAuth()) { |
198 Show(); | 225 Show(); |
199 return; | 226 return; |
200 } | 227 } |
201 | 228 |
202 UMA(policy::kMetricEnrollmentCancelled); | 229 UMA(policy::kMetricEnrollmentCancelled); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) { | 263 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) { |
237 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. | 264 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. |
238 LOG(WARNING) << "Enrollment error occured: status=" << status.status() | 265 LOG(WARNING) << "Enrollment error occured: status=" << status.status() |
239 << " http status=" << status.http_status() | 266 << " http status=" << status.http_status() |
240 << " DM status=" << status.client_status(); | 267 << " DM status=" << status.client_status(); |
241 RecordEnrollmentErrorMetrics(); | 268 RecordEnrollmentErrorMetrics(); |
242 // If the DM server does not have a device pre-provisioned for attestation- | 269 // If the DM server does not have a device pre-provisioned for attestation- |
243 // based enrollment and we have a fallback authentication, show it. | 270 // based enrollment and we have a fallback authentication, show it. |
244 if (status.status() == policy::EnrollmentStatus::REGISTRATION_FAILED && | 271 if (status.status() == policy::EnrollmentStatus::REGISTRATION_FAILED && |
245 status.client_status() == policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND && | 272 status.client_status() == policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND && |
246 current_auth_ == AUTH_ATTESTATION && AdvanceToNextAuth()) | 273 current_auth_ == AUTH_ATTESTATION && AdvanceToNextAuth()) { |
247 Show(); | 274 Show(); |
248 else | 275 } else { |
249 actor_->ShowEnrollmentStatus(status); | 276 actor_->ShowEnrollmentStatus(status); |
277 if (UsingHandsOffEnrollment()) | |
278 AutomaticRetry(); | |
279 } | |
250 } | 280 } |
251 | 281 |
252 void EnrollmentScreen::OnOtherError( | 282 void EnrollmentScreen::OnOtherError( |
253 EnterpriseEnrollmentHelper::OtherError error) { | 283 EnterpriseEnrollmentHelper::OtherError error) { |
254 RecordEnrollmentErrorMetrics(); | 284 RecordEnrollmentErrorMetrics(); |
255 actor_->ShowOtherError(error); | 285 actor_->ShowOtherError(error); |
286 if (UsingHandsOffEnrollment()) | |
287 AutomaticRetry(); | |
256 } | 288 } |
257 | 289 |
258 void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) { | 290 void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) { |
259 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. | 291 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. |
260 LOG(WARNING) << "Device is successfully enrolled."; | 292 LOG(WARNING) << "Device is successfully enrolled."; |
261 if (!additional_token.empty()) | 293 if (!additional_token.empty()) |
262 SendEnrollmentAuthToken(additional_token); | 294 SendEnrollmentAuthToken(additional_token); |
263 | 295 |
264 enrollment_helper_->GetDeviceAttributeUpdatePermission(); | 296 enrollment_helper_->GetDeviceAttributeUpdatePermission(); |
265 } | 297 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 std::string location = policy ? policy->annotated_location() : std::string(); | 348 std::string location = policy ? policy->annotated_location() : std::string(); |
317 actor_->ShowAttributePromptScreen(asset_id, location); | 349 actor_->ShowAttributePromptScreen(asset_id, location); |
318 } | 350 } |
319 | 351 |
320 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { | 352 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { |
321 DCHECK(shark_controller_); | 353 DCHECK(shark_controller_); |
322 shark_controller_->OnAuthenticationDone(enrolling_user_domain_, token); | 354 shark_controller_->OnAuthenticationDone(enrolling_user_domain_, token); |
323 } | 355 } |
324 | 356 |
325 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() { | 357 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() { |
358 retry_backoff_->InformOfRequest(true); | |
326 if (elapsed_timer_) | 359 if (elapsed_timer_) |
327 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_); | 360 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_); |
328 actor_->ShowEnrollmentStatus( | 361 actor_->ShowEnrollmentStatus( |
329 policy::EnrollmentStatus::ForStatus(policy::EnrollmentStatus::SUCCESS)); | 362 policy::EnrollmentStatus::ForStatus(policy::EnrollmentStatus::SUCCESS)); |
330 } | 363 } |
331 | 364 |
332 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { | 365 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { |
333 EnrollmentUMA(sample, config_.mode); | 366 EnrollmentUMA(sample, config_.mode); |
334 } | 367 } |
335 | 368 |
336 void EnrollmentScreen::ShowSigninScreen() { | 369 void EnrollmentScreen::ShowSigninScreen() { |
337 actor_->Show(); | 370 actor_->Show(); |
338 actor_->ShowSigninScreen(); | 371 actor_->ShowSigninScreen(); |
339 } | 372 } |
340 | 373 |
341 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { | 374 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { |
342 enrollment_failed_once_ = true; | 375 enrollment_failed_once_ = true; |
343 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? | 376 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? |
344 if (elapsed_timer_) | 377 if (elapsed_timer_) |
345 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); | 378 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); |
346 } | 379 } |
347 | 380 |
381 bool EnrollmentScreen::UsingHandsOffEnrollment() { | |
382 return policy::DeviceCloudPolicyManagerChromeOS:: | |
383 GetZeroTouchEnrollmentMode() == | |
384 policy::ZeroTouchEnrollmentMode::HANDS_OFF; | |
385 } | |
386 | |
348 } // namespace chromeos | 387 } // namespace chromeos |
OLD | NEW |