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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 else if (enrollment_failed_once_) | 103 else if (enrollment_failed_once_) |
104 UMA(policy::kMetricEnrollmentRetried); | 104 UMA(policy::kMetricEnrollmentRetried); |
105 else | 105 else |
106 UMA(policy::kMetricEnrollmentStarted); | 106 UMA(policy::kMetricEnrollmentStarted); |
107 | 107 |
108 actor_->ShowEnrollmentSpinnerScreen(); | 108 actor_->ShowEnrollmentSpinnerScreen(); |
109 actor_->FetchOAuthToken(); | 109 actor_->FetchOAuthToken(); |
110 } | 110 } |
111 | 111 |
112 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { | 112 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { |
113 enrollment_failed_once_ = true; | |
114 actor_->ShowAuthError(error); | |
115 | |
116 switch (error.state()) { | 113 switch (error.state()) { |
117 case GoogleServiceAuthError::NONE: | 114 case GoogleServiceAuthError::NONE: |
118 case GoogleServiceAuthError::CAPTCHA_REQUIRED: | 115 case GoogleServiceAuthError::CAPTCHA_REQUIRED: |
119 case GoogleServiceAuthError::TWO_FACTOR: | 116 case GoogleServiceAuthError::TWO_FACTOR: |
120 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED: | 117 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED: |
121 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: | 118 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: |
122 case GoogleServiceAuthError::REQUEST_CANCELED: | 119 case GoogleServiceAuthError::REQUEST_CANCELED: |
123 case GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE: | 120 case GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE: |
124 case GoogleServiceAuthError::SERVICE_ERROR: | 121 case GoogleServiceAuthError::SERVICE_ERROR: |
125 UMAFailure(policy::kMetricEnrollmentLoginFailed); | 122 UMAFailure(policy::kMetricEnrollmentLoginFailed); |
126 LOG(ERROR) << "Auth error " << error.state(); | 123 LOG(ERROR) << "Auth error " << error.state(); |
127 return; | 124 break; |
128 case GoogleServiceAuthError::USER_NOT_SIGNED_UP: | 125 case GoogleServiceAuthError::USER_NOT_SIGNED_UP: |
129 case GoogleServiceAuthError::ACCOUNT_DELETED: | 126 case GoogleServiceAuthError::ACCOUNT_DELETED: |
130 case GoogleServiceAuthError::ACCOUNT_DISABLED: | 127 case GoogleServiceAuthError::ACCOUNT_DISABLED: |
131 UMAFailure(policy::kMetricEnrollmentNotSupported); | 128 UMAFailure(policy::kMetricEnrollmentNotSupported); |
132 LOG(ERROR) << "Account error " << error.state(); | 129 LOG(ERROR) << "Account error " << error.state(); |
133 return; | 130 break; |
134 case GoogleServiceAuthError::CONNECTION_FAILED: | 131 case GoogleServiceAuthError::CONNECTION_FAILED: |
135 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: | 132 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: |
136 UMAFailure(policy::kMetricEnrollmentNetworkFailed); | 133 UMAFailure(policy::kMetricEnrollmentNetworkFailed); |
137 LOG(WARNING) << "Network error " << error.state(); | 134 LOG(WARNING) << "Network error " << error.state(); |
138 return; | 135 break; |
139 case GoogleServiceAuthError::NUM_STATES: | 136 case GoogleServiceAuthError::NUM_STATES: |
| 137 NOTREACHED(); |
140 break; | 138 break; |
141 } | 139 } |
142 | 140 |
143 NOTREACHED(); | 141 enrollment_failed_once_ = true; |
144 UMAFailure(policy::kMetricEnrollmentOtherFailed); | 142 actor_->ShowAuthError(error); |
145 } | 143 } |
146 | 144 |
147 void EnrollmentScreen::OnOAuthTokenAvailable(const std::string& token) { | 145 void EnrollmentScreen::OnOAuthTokenAvailable(const std::string& token) { |
148 VLOG(1) << "OnOAuthTokenAvailable " << token; | 146 VLOG(1) << "OnOAuthTokenAvailable " << token; |
149 const bool is_shark = | 147 const bool is_shark = |
150 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> | 148 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> |
151 GetDeviceCloudPolicyManager()->IsSharkRequisition(); | 149 GetDeviceCloudPolicyManager()->IsSharkRequisition(); |
152 | 150 |
153 if (is_shark && !remora_token_sent_) { | 151 if (is_shark && !remora_token_sent_) { |
154 // Fetch a second token for shark devices. | 152 // Fetch a second token for shark devices. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // TODO(achuith, zork): Send token via Bluetooth to remote device. | 242 // TODO(achuith, zork): Send token via Bluetooth to remote device. |
245 } | 243 } |
246 | 244 |
247 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess( | 245 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess( |
248 const policy::EnrollmentStatus& status) { | 246 const policy::EnrollmentStatus& status) { |
249 actor_->ShowEnrollmentStatus(status); | 247 actor_->ShowEnrollmentStatus(status); |
250 StartupUtils::MarkOobeCompleted(); | 248 StartupUtils::MarkOobeCompleted(); |
251 } | 249 } |
252 | 250 |
253 void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) { | 251 void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) { |
254 if (status.status() == policy::EnrollmentStatus::STATUS_SUCCESS) { | |
255 StartupUtils::MarkDeviceRegistered( | |
256 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess, | |
257 weak_ptr_factory_.GetWeakPtr(), | |
258 status)); | |
259 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoOK | |
260 : policy::kMetricEnrollmentOK); | |
261 return; | |
262 } else { | |
263 enrollment_failed_once_ = true; | |
264 } | |
265 actor_->ShowEnrollmentStatus(status); | |
266 | |
267 switch (status.status()) { | 252 switch (status.status()) { |
| 253 case policy::EnrollmentStatus::STATUS_SUCCESS: |
| 254 StartupUtils::MarkDeviceRegistered( |
| 255 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess, |
| 256 weak_ptr_factory_.GetWeakPtr(), |
| 257 status)); |
| 258 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoOK |
| 259 : policy::kMetricEnrollmentOK); |
| 260 return; |
268 case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED: | 261 case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED: |
269 case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED: | 262 case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED: |
270 switch (status.client_status()) { | 263 switch (status.client_status()) { |
271 case policy::DM_STATUS_SUCCESS: | 264 case policy::DM_STATUS_SUCCESS: |
272 case policy::DM_STATUS_REQUEST_INVALID: | 265 case policy::DM_STATUS_REQUEST_INVALID: |
273 case policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND: | 266 case policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND: |
274 case policy::DM_STATUS_SERVICE_MANAGEMENT_TOKEN_INVALID: | 267 case policy::DM_STATUS_SERVICE_MANAGEMENT_TOKEN_INVALID: |
275 case policy::DM_STATUS_SERVICE_ACTIVATION_PENDING: | 268 case policy::DM_STATUS_SERVICE_ACTIVATION_PENDING: |
276 case policy::DM_STATUS_SERVICE_DEVICE_ID_CONFLICT: | 269 case policy::DM_STATUS_SERVICE_DEVICE_ID_CONFLICT: |
277 case policy::DM_STATUS_SERVICE_POLICY_NOT_FOUND: | 270 case policy::DM_STATUS_SERVICE_POLICY_NOT_FOUND: |
278 UMAFailure(policy::kMetricEnrollmentOtherFailed); | 271 UMAFailure(policy::kMetricEnrollmentOtherFailed); |
279 return; | 272 break; |
280 case policy::DM_STATUS_REQUEST_FAILED: | 273 case policy::DM_STATUS_REQUEST_FAILED: |
281 case policy::DM_STATUS_TEMPORARY_UNAVAILABLE: | 274 case policy::DM_STATUS_TEMPORARY_UNAVAILABLE: |
282 case policy::DM_STATUS_HTTP_STATUS_ERROR: | 275 case policy::DM_STATUS_HTTP_STATUS_ERROR: |
283 case policy::DM_STATUS_RESPONSE_DECODING_ERROR: | 276 case policy::DM_STATUS_RESPONSE_DECODING_ERROR: |
284 UMAFailure(policy::kMetricEnrollmentNetworkFailed); | 277 UMAFailure(policy::kMetricEnrollmentNetworkFailed); |
285 return; | 278 break; |
286 case policy::DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED: | 279 case policy::DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED: |
287 UMAFailure(policy::kMetricEnrollmentNotSupported); | 280 UMAFailure(policy::kMetricEnrollmentNotSupported); |
288 return; | 281 break; |
289 case policy::DM_STATUS_SERVICE_INVALID_SERIAL_NUMBER: | 282 case policy::DM_STATUS_SERVICE_INVALID_SERIAL_NUMBER: |
290 UMAFailure(policy::kMetricEnrollmentInvalidSerialNumber); | 283 UMAFailure(policy::kMetricEnrollmentInvalidSerialNumber); |
291 return; | 284 break; |
292 case policy::DM_STATUS_SERVICE_MISSING_LICENSES: | 285 case policy::DM_STATUS_SERVICE_MISSING_LICENSES: |
293 UMAFailure(policy::kMetricMissingLicensesError); | 286 UMAFailure(policy::kMetricMissingLicensesError); |
294 return; | 287 break; |
295 case policy::DM_STATUS_SERVICE_DEPROVISIONED: | 288 case policy::DM_STATUS_SERVICE_DEPROVISIONED: |
296 UMAFailure(policy::kMetricEnrollmentDeprovisioned); | 289 UMAFailure(policy::kMetricEnrollmentDeprovisioned); |
297 return; | 290 break; |
298 case policy::DM_STATUS_SERVICE_DOMAIN_MISMATCH: | 291 case policy::DM_STATUS_SERVICE_DOMAIN_MISMATCH: |
299 UMAFailure(policy::kMetricEnrollmentDomainMismatch); | 292 UMAFailure(policy::kMetricEnrollmentDomainMismatch); |
300 return; | 293 break; |
301 } | 294 } |
302 break; | 295 break; |
303 case policy::EnrollmentStatus::STATUS_REGISTRATION_BAD_MODE: | 296 case policy::EnrollmentStatus::STATUS_REGISTRATION_BAD_MODE: |
304 UMAFailure(policy::kMetricEnrollmentInvalidEnrollmentMode); | 297 UMAFailure(policy::kMetricEnrollmentInvalidEnrollmentMode); |
305 return; | 298 break; |
306 case policy::EnrollmentStatus::STATUS_LOCK_TIMEOUT: | 299 case policy::EnrollmentStatus::STATUS_LOCK_TIMEOUT: |
307 UMAFailure(policy::kMetricLockboxTimeoutError); | 300 UMAFailure(policy::kMetricLockboxTimeoutError); |
308 return; | 301 break; |
309 case policy::EnrollmentStatus::STATUS_LOCK_WRONG_USER: | 302 case policy::EnrollmentStatus::STATUS_LOCK_WRONG_USER: |
310 UMAFailure(policy::kMetricEnrollmentWrongUserError); | 303 UMAFailure(policy::kMetricEnrollmentWrongUserError); |
311 return; | 304 break; |
312 case policy::EnrollmentStatus::STATUS_NO_STATE_KEYS: | 305 case policy::EnrollmentStatus::STATUS_NO_STATE_KEYS: |
313 UMAFailure(policy::kMetricEnrollmentNoStateKeys); | 306 UMAFailure(policy::kMetricEnrollmentNoStateKeys); |
314 return; | 307 break; |
315 case policy::EnrollmentStatus::STATUS_VALIDATION_FAILED: | 308 case policy::EnrollmentStatus::STATUS_VALIDATION_FAILED: |
316 UMAFailure(policy::kMetricEnrollmentPolicyValidationFailed); | 309 UMAFailure(policy::kMetricEnrollmentPolicyValidationFailed); |
317 return; | 310 break; |
318 case policy::EnrollmentStatus::STATUS_STORE_ERROR: | 311 case policy::EnrollmentStatus::STATUS_STORE_ERROR: |
319 UMAFailure(policy::kMetricEnrollmentCloudPolicyStoreError); | 312 UMAFailure(policy::kMetricEnrollmentCloudPolicyStoreError); |
320 return; | 313 break; |
321 case policy::EnrollmentStatus::STATUS_LOCK_ERROR: | 314 case policy::EnrollmentStatus::STATUS_LOCK_ERROR: |
322 UMAFailure(policy::kMetricEnrollmentLockBackendError); | 315 UMAFailure(policy::kMetricEnrollmentLockBackendError); |
323 return; | 316 break; |
324 case policy::EnrollmentStatus::STATUS_ROBOT_AUTH_FETCH_FAILED: | 317 case policy::EnrollmentStatus::STATUS_ROBOT_AUTH_FETCH_FAILED: |
325 UMAFailure(policy::kMetricEnrollmentRobotAuthCodeFetchFailed); | 318 UMAFailure(policy::kMetricEnrollmentRobotAuthCodeFetchFailed); |
326 return; | 319 break; |
327 case policy::EnrollmentStatus::STATUS_ROBOT_REFRESH_FETCH_FAILED: | 320 case policy::EnrollmentStatus::STATUS_ROBOT_REFRESH_FETCH_FAILED: |
328 UMAFailure(policy::kMetricEnrollmentRobotRefreshTokenFetchFailed); | 321 UMAFailure(policy::kMetricEnrollmentRobotRefreshTokenFetchFailed); |
329 return; | 322 break; |
330 case policy::EnrollmentStatus::STATUS_ROBOT_REFRESH_STORE_FAILED: | 323 case policy::EnrollmentStatus::STATUS_ROBOT_REFRESH_STORE_FAILED: |
331 UMAFailure(policy::kMetricEnrollmentRobotRefreshTokenStoreFailed); | 324 UMAFailure(policy::kMetricEnrollmentRobotRefreshTokenStoreFailed); |
332 return; | 325 break; |
333 case policy::EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED: | 326 case policy::EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED: |
334 // This error should not happen for enterprise enrollment. | 327 // This error should not happen for enterprise enrollment, it only affects |
| 328 // consumer enrollment. |
335 UMAFailure(policy::kMetricEnrollmentStoreTokenAndIdFailed); | 329 UMAFailure(policy::kMetricEnrollmentStoreTokenAndIdFailed); |
336 NOTREACHED(); | 330 NOTREACHED(); |
337 return; | 331 break; |
338 case policy::EnrollmentStatus::STATUS_SUCCESS: | |
339 NOTREACHED(); | |
340 return; | |
341 } | 332 } |
342 | 333 |
343 NOTREACHED(); | 334 enrollment_failed_once_ = true; |
344 UMAFailure(policy::kMetricEnrollmentOtherFailed); | 335 actor_->ShowEnrollmentStatus(status); |
345 } | 336 } |
346 | 337 |
347 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { | 338 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { |
348 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_RECOVERY) { | 339 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_RECOVERY) { |
349 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollmentRecovery, sample, | 340 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollmentRecovery, sample, |
350 policy::kMetricEnrollmentSize); | 341 policy::kMetricEnrollmentSize); |
351 } else { | 342 } else { |
352 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment, sample, | 343 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment, sample, |
353 policy::kMetricEnrollmentSize); | 344 policy::kMetricEnrollmentSize); |
354 } | 345 } |
355 } | 346 } |
356 | 347 |
357 void EnrollmentScreen::UMAFailure(policy::MetricEnrollment sample) { | 348 void EnrollmentScreen::UMAFailure(policy::MetricEnrollment sample) { |
358 if (is_auto_enrollment()) | 349 if (is_auto_enrollment()) |
359 sample = policy::kMetricEnrollmentAutoFailed; | 350 sample = policy::kMetricEnrollmentAutoFailed; |
360 UMA(sample); | 351 UMA(sample); |
361 } | 352 } |
362 | 353 |
363 void EnrollmentScreen::ShowSigninScreen() { | 354 void EnrollmentScreen::ShowSigninScreen() { |
364 actor_->Show(); | 355 actor_->Show(); |
365 actor_->ShowSigninScreen(); | 356 actor_->ShowSigninScreen(); |
366 } | 357 } |
367 | 358 |
368 } // namespace chromeos | 359 } // namespace chromeos |
OLD | NEW |