| 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/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/timer/elapsed_timer.h" | 13 #include "base/timer/elapsed_timer.h" |
| 13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/browser_process_platform_part.h" | 15 #include "chrome/browser/browser_process_platform_part.h" |
| 15 #include "chrome/browser/chromeos/login/enrollment/enrollment_uma.h" | 16 #include "chrome/browser/chromeos/login/enrollment/enrollment_uma.h" |
| 16 #include "chrome/browser/chromeos/login/screen_manager.h" | 17 #include "chrome/browser/chromeos/login/screen_manager.h" |
| 17 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" | 18 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" |
| 18 #include "chrome/browser/chromeos/login/startup_utils.h" | 19 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 19 #include "chrome/browser/chromeos/login/wizard_controller.h" | 20 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 21 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 21 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" | 22 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" |
| 22 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 23 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 24 #include "chromeos/chromeos_switches.h" |
| 23 #include "chromeos/dbus/cryptohome_client.h" | 25 #include "chromeos/dbus/cryptohome_client.h" |
| 24 #include "chromeos/dbus/dbus_method_call_status.h" | 26 #include "chromeos/dbus/dbus_method_call_status.h" |
| 25 #include "chromeos/dbus/dbus_thread_manager.h" | 27 #include "chromeos/dbus/dbus_thread_manager.h" |
| 26 #include "components/pairing/controller_pairing_controller.h" | 28 #include "components/pairing/controller_pairing_controller.h" |
| 27 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 29 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 28 #include "google_apis/gaia/gaia_auth_util.h" | 30 #include "google_apis/gaia/gaia_auth_util.h" |
| 29 | 31 |
| 30 using namespace pairing_chromeos; | 32 using namespace pairing_chromeos; |
| 31 using policy::EnrollmentConfig; | 33 using policy::EnrollmentConfig; |
| 32 | 34 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 actor_->ShowEnrollmentSpinnerScreen(); | 181 actor_->ShowEnrollmentSpinnerScreen(); |
| 180 CreateEnrollmentHelper(); | 182 CreateEnrollmentHelper(); |
| 181 enrollment_helper_->EnrollUsingAttestation(); | 183 enrollment_helper_->EnrollUsingAttestation(); |
| 182 } | 184 } |
| 183 | 185 |
| 184 void EnrollmentScreen::OnLoginDone(const std::string& user, | 186 void EnrollmentScreen::OnLoginDone(const std::string& user, |
| 185 const std::string& auth_code) { | 187 const std::string& auth_code) { |
| 186 LOG_IF(ERROR, auth_code.empty()) << "Auth code is empty."; | 188 LOG_IF(ERROR, auth_code.empty()) << "Auth code is empty."; |
| 187 elapsed_timer_.reset(new base::ElapsedTimer()); | 189 elapsed_timer_.reset(new base::ElapsedTimer()); |
| 188 enrolling_user_domain_ = gaia::ExtractDomainName(user); | 190 enrolling_user_domain_ = gaia::ExtractDomainName(user); |
| 189 | 191 auth_code_ = auth_code; |
| 190 UMA(enrollment_failed_once_ ? policy::kMetricEnrollmentRestarted | 192 // TODO(rsorokin): Move ShowADJoin after STEP_REGISTRATION |
| 191 : policy::kMetricEnrollmentStarted); | 193 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 192 | 194 chromeos::switches::kEnableAD)) { |
| 193 actor_->ShowEnrollmentSpinnerScreen(); | 195 actor_->ShowADJoin(); |
| 194 CreateEnrollmentHelper(); | 196 } else { |
| 195 enrollment_helper_->EnrollUsingAuthCode( | 197 OnADJoined(""); |
| 196 auth_code, shark_controller_ != nullptr /* fetch_additional_token */); | 198 } |
| 197 } | 199 } |
| 198 | 200 |
| 199 void EnrollmentScreen::OnRetry() { | 201 void EnrollmentScreen::OnRetry() { |
| 200 Show(); | 202 Show(); |
| 201 } | 203 } |
| 202 | 204 |
| 203 void EnrollmentScreen::OnCancel() { | 205 void EnrollmentScreen::OnCancel() { |
| 204 if (AdvanceToNextAuth()) { | 206 if (AdvanceToNextAuth()) { |
| 205 Show(); | 207 Show(); |
| 206 return; | 208 return; |
| 207 } | 209 } |
| 208 | 210 |
| 209 UMA(policy::kMetricEnrollmentCancelled); | 211 UMA(policy::kMetricEnrollmentCancelled); |
| 210 if (elapsed_timer_) | 212 if (elapsed_timer_) |
| 211 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeCancel, elapsed_timer_); | 213 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeCancel, elapsed_timer_); |
| 212 | 214 |
| 213 const BaseScreenDelegate::ExitCodes exit_code = | 215 const BaseScreenDelegate::ExitCodes exit_code = |
| 214 config_.is_forced() ? BaseScreenDelegate::ENTERPRISE_ENROLLMENT_BACK | 216 config_.is_forced() ? BaseScreenDelegate::ENTERPRISE_ENROLLMENT_BACK |
| 215 : BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED; | 217 : BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED; |
| 216 ClearAuth( | 218 ClearAuth( |
| 217 base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), exit_code)); | 219 base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), exit_code)); |
| 218 } | 220 } |
| 219 | 221 |
| 220 void EnrollmentScreen::OnConfirmationClosed() { | 222 void EnrollmentScreen::OnConfirmationClosed() { |
| 221 ClearAuth(base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), | 223 ClearAuth(base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), |
| 222 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED)); | 224 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED)); |
| 223 } | 225 } |
| 224 | 226 |
| 227 void EnrollmentScreen::OnADJoined(const std::string& realm) { |
| 228 if (!realm.empty()) { |
| 229 config_.management_realm = realm; |
| 230 } |
| 231 UMA(enrollment_failed_once_ ? policy::kMetricEnrollmentRestarted |
| 232 : policy::kMetricEnrollmentStarted); |
| 233 |
| 234 actor_->ShowEnrollmentSpinnerScreen(); |
| 235 CreateEnrollmentHelper(); |
| 236 enrollment_helper_->EnrollUsingAuthCode( |
| 237 auth_code_, shark_controller_ != NULL /* fetch_additional_token */); |
| 238 } |
| 239 |
| 225 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { | 240 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { |
| 226 RecordEnrollmentErrorMetrics(); | 241 RecordEnrollmentErrorMetrics(); |
| 227 actor_->ShowAuthError(error); | 242 actor_->ShowAuthError(error); |
| 228 } | 243 } |
| 229 | 244 |
| 230 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) { | 245 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) { |
| 231 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. | 246 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. |
| 232 LOG(WARNING) << "Enrollment error occured: status=" << status.status() | 247 LOG(WARNING) << "Enrollment error occured: status=" << status.status() |
| 233 << " http status=" << status.http_status() | 248 << " http status=" << status.http_status() |
| 234 << " DM status=" << status.client_status(); | 249 << " DM status=" << status.client_status(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 } | 348 } |
| 334 | 349 |
| 335 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { | 350 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { |
| 336 enrollment_failed_once_ = true; | 351 enrollment_failed_once_ = true; |
| 337 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? | 352 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? |
| 338 if (elapsed_timer_) | 353 if (elapsed_timer_) |
| 339 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); | 354 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); |
| 340 } | 355 } |
| 341 | 356 |
| 342 } // namespace chromeos | 357 } // namespace chromeos |
| OLD | NEW |