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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 else if (enrollment_failed_once_) | 87 else if (enrollment_failed_once_) |
88 UMA(policy::kMetricEnrollmentRetried); | 88 UMA(policy::kMetricEnrollmentRetried); |
89 else | 89 else |
90 UMA(policy::kMetricEnrollmentStarted); | 90 UMA(policy::kMetricEnrollmentStarted); |
91 | 91 |
92 actor_->ShowEnrollmentSpinnerScreen(); | 92 actor_->ShowEnrollmentSpinnerScreen(); |
93 actor_->FetchOAuthToken(); | 93 actor_->FetchOAuthToken(); |
94 } | 94 } |
95 | 95 |
96 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { | 96 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { |
| 97 enrollment_failed_once_ = true; |
| 98 actor_->ShowAuthError(error); |
| 99 |
97 switch (error.state()) { | 100 switch (error.state()) { |
98 case GoogleServiceAuthError::NONE: | 101 case GoogleServiceAuthError::NONE: |
99 case GoogleServiceAuthError::CAPTCHA_REQUIRED: | 102 case GoogleServiceAuthError::CAPTCHA_REQUIRED: |
100 case GoogleServiceAuthError::TWO_FACTOR: | 103 case GoogleServiceAuthError::TWO_FACTOR: |
101 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED: | 104 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED: |
102 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: | 105 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: |
103 case GoogleServiceAuthError::REQUEST_CANCELED: | 106 case GoogleServiceAuthError::REQUEST_CANCELED: |
104 case GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE: | 107 case GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE: |
105 case GoogleServiceAuthError::SERVICE_ERROR: | 108 case GoogleServiceAuthError::SERVICE_ERROR: |
106 UMAFailure(policy::kMetricEnrollmentLoginFailed); | 109 UMAFailure(policy::kMetricEnrollmentLoginFailed); |
107 LOG(ERROR) << "Auth error " << error.state(); | 110 LOG(ERROR) << "Auth error " << error.state(); |
108 break; | 111 return; |
109 case GoogleServiceAuthError::USER_NOT_SIGNED_UP: | 112 case GoogleServiceAuthError::USER_NOT_SIGNED_UP: |
110 case GoogleServiceAuthError::ACCOUNT_DELETED: | 113 case GoogleServiceAuthError::ACCOUNT_DELETED: |
111 case GoogleServiceAuthError::ACCOUNT_DISABLED: | 114 case GoogleServiceAuthError::ACCOUNT_DISABLED: |
112 UMAFailure(policy::kMetricEnrollmentNotSupported); | 115 UMAFailure(policy::kMetricEnrollmentNotSupported); |
113 LOG(ERROR) << "Account error " << error.state(); | 116 LOG(ERROR) << "Account error " << error.state(); |
114 break; | 117 return; |
115 case GoogleServiceAuthError::CONNECTION_FAILED: | 118 case GoogleServiceAuthError::CONNECTION_FAILED: |
116 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: | 119 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: |
117 UMAFailure(policy::kMetricEnrollmentNetworkFailed); | 120 UMAFailure(policy::kMetricEnrollmentNetworkFailed); |
118 LOG(WARNING) << "Network error " << error.state(); | 121 LOG(WARNING) << "Network error " << error.state(); |
119 break; | 122 return; |
120 case GoogleServiceAuthError::NUM_STATES: | 123 case GoogleServiceAuthError::NUM_STATES: |
121 NOTREACHED(); | |
122 break; | 124 break; |
123 } | 125 } |
124 | 126 |
125 enrollment_failed_once_ = true; | 127 NOTREACHED(); |
126 actor_->ShowAuthError(error); | 128 UMAFailure(policy::kMetricEnrollmentOtherFailed); |
127 } | 129 } |
128 | 130 |
129 void EnrollmentScreen::OnOAuthTokenAvailable(const std::string& token) { | 131 void EnrollmentScreen::OnOAuthTokenAvailable(const std::string& token) { |
130 RegisterForDevicePolicy(token); | 132 RegisterForDevicePolicy(token); |
131 } | 133 } |
132 | 134 |
133 void EnrollmentScreen::OnRetry() { | 135 void EnrollmentScreen::OnRetry() { |
134 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen, | 136 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen, |
135 weak_ptr_factory_.GetWeakPtr())); | 137 weak_ptr_factory_.GetWeakPtr())); |
136 } | 138 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 weak_ptr_factory_.GetWeakPtr())); | 212 weak_ptr_factory_.GetWeakPtr())); |
211 } | 213 } |
212 | 214 |
213 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess( | 215 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess( |
214 const policy::EnrollmentStatus& status) { | 216 const policy::EnrollmentStatus& status) { |
215 actor_->ShowEnrollmentStatus(status); | 217 actor_->ShowEnrollmentStatus(status); |
216 StartupUtils::MarkOobeCompleted(); | 218 StartupUtils::MarkOobeCompleted(); |
217 } | 219 } |
218 | 220 |
219 void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) { | 221 void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) { |
| 222 if (status.status() == policy::EnrollmentStatus::STATUS_SUCCESS) { |
| 223 StartupUtils::MarkDeviceRegistered( |
| 224 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess, |
| 225 weak_ptr_factory_.GetWeakPtr(), |
| 226 status)); |
| 227 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoOK |
| 228 : policy::kMetricEnrollmentOK); |
| 229 return; |
| 230 } else { |
| 231 enrollment_failed_once_ = true; |
| 232 } |
| 233 actor_->ShowEnrollmentStatus(status); |
| 234 |
220 switch (status.status()) { | 235 switch (status.status()) { |
221 case policy::EnrollmentStatus::STATUS_SUCCESS: | |
222 StartupUtils::MarkDeviceRegistered( | |
223 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess, | |
224 weak_ptr_factory_.GetWeakPtr(), | |
225 status)); | |
226 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoOK | |
227 : policy::kMetricEnrollmentOK); | |
228 return; | |
229 case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED: | 236 case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED: |
230 case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED: | 237 case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED: |
231 switch (status.client_status()) { | 238 switch (status.client_status()) { |
232 case policy::DM_STATUS_SUCCESS: | 239 case policy::DM_STATUS_SUCCESS: |
233 case policy::DM_STATUS_REQUEST_INVALID: | 240 case policy::DM_STATUS_REQUEST_INVALID: |
234 case policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND: | 241 case policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND: |
235 case policy::DM_STATUS_SERVICE_MANAGEMENT_TOKEN_INVALID: | 242 case policy::DM_STATUS_SERVICE_MANAGEMENT_TOKEN_INVALID: |
236 case policy::DM_STATUS_SERVICE_ACTIVATION_PENDING: | 243 case policy::DM_STATUS_SERVICE_ACTIVATION_PENDING: |
237 case policy::DM_STATUS_SERVICE_DEVICE_ID_CONFLICT: | 244 case policy::DM_STATUS_SERVICE_DEVICE_ID_CONFLICT: |
238 case policy::DM_STATUS_SERVICE_POLICY_NOT_FOUND: | 245 case policy::DM_STATUS_SERVICE_POLICY_NOT_FOUND: |
239 UMAFailure(policy::kMetricEnrollmentOtherFailed); | 246 UMAFailure(policy::kMetricEnrollmentOtherFailed); |
240 break; | 247 return; |
241 case policy::DM_STATUS_REQUEST_FAILED: | 248 case policy::DM_STATUS_REQUEST_FAILED: |
242 case policy::DM_STATUS_TEMPORARY_UNAVAILABLE: | 249 case policy::DM_STATUS_TEMPORARY_UNAVAILABLE: |
243 case policy::DM_STATUS_HTTP_STATUS_ERROR: | 250 case policy::DM_STATUS_HTTP_STATUS_ERROR: |
244 case policy::DM_STATUS_RESPONSE_DECODING_ERROR: | 251 case policy::DM_STATUS_RESPONSE_DECODING_ERROR: |
245 UMAFailure(policy::kMetricEnrollmentNetworkFailed); | 252 UMAFailure(policy::kMetricEnrollmentNetworkFailed); |
246 break; | 253 return; |
247 case policy::DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED: | 254 case policy::DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED: |
248 UMAFailure(policy::kMetricEnrollmentNotSupported); | 255 UMAFailure(policy::kMetricEnrollmentNotSupported); |
249 break; | 256 return; |
250 case policy::DM_STATUS_SERVICE_INVALID_SERIAL_NUMBER: | 257 case policy::DM_STATUS_SERVICE_INVALID_SERIAL_NUMBER: |
251 UMAFailure(policy::kMetricEnrollmentInvalidSerialNumber); | 258 UMAFailure(policy::kMetricEnrollmentInvalidSerialNumber); |
252 break; | 259 return; |
253 case policy::DM_STATUS_SERVICE_MISSING_LICENSES: | 260 case policy::DM_STATUS_SERVICE_MISSING_LICENSES: |
254 UMAFailure(policy::kMetricMissingLicensesError); | 261 UMAFailure(policy::kMetricMissingLicensesError); |
255 break; | 262 return; |
256 case policy::DM_STATUS_SERVICE_DEPROVISIONED: | 263 case policy::DM_STATUS_SERVICE_DEPROVISIONED: |
257 UMAFailure(policy::kMetricEnrollmentDeprovisioned); | 264 UMAFailure(policy::kMetricEnrollmentDeprovisioned); |
258 break; | 265 return; |
259 case policy::DM_STATUS_SERVICE_DOMAIN_MISMATCH: | 266 case policy::DM_STATUS_SERVICE_DOMAIN_MISMATCH: |
260 UMAFailure(policy::kMetricEnrollmentDomainMismatch); | 267 UMAFailure(policy::kMetricEnrollmentDomainMismatch); |
261 break; | 268 return; |
262 } | 269 } |
263 break; | 270 break; |
264 case policy::EnrollmentStatus::STATUS_REGISTRATION_BAD_MODE: | 271 case policy::EnrollmentStatus::STATUS_REGISTRATION_BAD_MODE: |
265 UMAFailure(policy::kMetricEnrollmentInvalidEnrollmentMode); | 272 UMAFailure(policy::kMetricEnrollmentInvalidEnrollmentMode); |
266 break; | 273 return; |
267 case policy::EnrollmentStatus::STATUS_LOCK_TIMEOUT: | 274 case policy::EnrollmentStatus::STATUS_LOCK_TIMEOUT: |
268 UMAFailure(policy::kMetricLockboxTimeoutError); | 275 UMAFailure(policy::kMetricLockboxTimeoutError); |
269 break; | 276 return; |
270 case policy::EnrollmentStatus::STATUS_LOCK_WRONG_USER: | 277 case policy::EnrollmentStatus::STATUS_LOCK_WRONG_USER: |
271 UMAFailure(policy::kMetricEnrollmentWrongUserError); | 278 UMAFailure(policy::kMetricEnrollmentWrongUserError); |
272 break; | 279 return; |
273 case policy::EnrollmentStatus::STATUS_NO_STATE_KEYS: | 280 case policy::EnrollmentStatus::STATUS_NO_STATE_KEYS: |
274 UMAFailure(policy::kMetricEnrollmentNoStateKeys); | 281 UMAFailure(policy::kMetricEnrollmentNoStateKeys); |
275 break; | 282 return; |
276 case policy::EnrollmentStatus::STATUS_VALIDATION_FAILED: | 283 case policy::EnrollmentStatus::STATUS_VALIDATION_FAILED: |
277 UMAFailure(policy::kMetricEnrollmentPolicyValidationFailed); | 284 UMAFailure(policy::kMetricEnrollmentPolicyValidationFailed); |
278 break; | 285 return; |
279 case policy::EnrollmentStatus::STATUS_STORE_ERROR: | 286 case policy::EnrollmentStatus::STATUS_STORE_ERROR: |
280 UMAFailure(policy::kMetricEnrollmentCloudPolicyStoreError); | 287 UMAFailure(policy::kMetricEnrollmentCloudPolicyStoreError); |
281 break; | 288 return; |
282 case policy::EnrollmentStatus::STATUS_LOCK_ERROR: | 289 case policy::EnrollmentStatus::STATUS_LOCK_ERROR: |
283 UMAFailure(policy::kMetricEnrollmentLockBackendError); | 290 UMAFailure(policy::kMetricEnrollmentLockBackendError); |
284 break; | 291 return; |
285 case policy::EnrollmentStatus::STATUS_ROBOT_AUTH_FETCH_FAILED: | 292 case policy::EnrollmentStatus::STATUS_ROBOT_AUTH_FETCH_FAILED: |
286 UMAFailure(policy::kMetricEnrollmentRobotAuthCodeFetchFailed); | 293 UMAFailure(policy::kMetricEnrollmentRobotAuthCodeFetchFailed); |
287 break; | 294 return; |
288 case policy::EnrollmentStatus::STATUS_ROBOT_REFRESH_FETCH_FAILED: | 295 case policy::EnrollmentStatus::STATUS_ROBOT_REFRESH_FETCH_FAILED: |
289 UMAFailure(policy::kMetricEnrollmentRobotRefreshTokenFetchFailed); | 296 UMAFailure(policy::kMetricEnrollmentRobotRefreshTokenFetchFailed); |
290 break; | 297 return; |
291 case policy::EnrollmentStatus::STATUS_ROBOT_REFRESH_STORE_FAILED: | 298 case policy::EnrollmentStatus::STATUS_ROBOT_REFRESH_STORE_FAILED: |
292 UMAFailure(policy::kMetricEnrollmentRobotRefreshTokenStoreFailed); | 299 UMAFailure(policy::kMetricEnrollmentRobotRefreshTokenStoreFailed); |
293 break; | 300 return; |
294 case policy::EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED: | 301 case policy::EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED: |
295 // This error should not happen for enterprise enrollment, it only affects | 302 // This error should not happen for enterprise enrollment. |
296 // consumer enrollment. | |
297 UMAFailure(policy::kMetricEnrollmentStoreTokenAndIdFailed); | 303 UMAFailure(policy::kMetricEnrollmentStoreTokenAndIdFailed); |
298 NOTREACHED(); | 304 NOTREACHED(); |
299 break; | 305 return; |
| 306 case policy::EnrollmentStatus::STATUS_SUCCESS: |
| 307 NOTREACHED(); |
| 308 return; |
300 } | 309 } |
301 | 310 |
302 enrollment_failed_once_ = true; | 311 NOTREACHED(); |
303 actor_->ShowEnrollmentStatus(status); | 312 UMAFailure(policy::kMetricEnrollmentOtherFailed); |
304 } | 313 } |
305 | 314 |
306 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { | 315 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { |
307 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_RECOVERY) { | 316 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_RECOVERY) { |
308 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollmentRecovery, sample, | 317 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollmentRecovery, sample, |
309 policy::kMetricEnrollmentSize); | 318 policy::kMetricEnrollmentSize); |
310 } else { | 319 } else { |
311 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment, sample, | 320 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment, sample, |
312 policy::kMetricEnrollmentSize); | 321 policy::kMetricEnrollmentSize); |
313 } | 322 } |
314 } | 323 } |
315 | 324 |
316 void EnrollmentScreen::UMAFailure(policy::MetricEnrollment sample) { | 325 void EnrollmentScreen::UMAFailure(policy::MetricEnrollment sample) { |
317 if (is_auto_enrollment()) | 326 if (is_auto_enrollment()) |
318 sample = policy::kMetricEnrollmentAutoFailed; | 327 sample = policy::kMetricEnrollmentAutoFailed; |
319 UMA(sample); | 328 UMA(sample); |
320 } | 329 } |
321 | 330 |
322 void EnrollmentScreen::ShowSigninScreen() { | 331 void EnrollmentScreen::ShowSigninScreen() { |
323 actor_->Show(); | 332 actor_->Show(); |
324 actor_->ShowSigninScreen(); | 333 actor_->ShowSigninScreen(); |
325 } | 334 } |
326 | 335 |
327 } // namespace chromeos | 336 } // namespace chromeos |
OLD | NEW |