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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/browser_process_platform_part.h" | 13 #include "chrome/browser/browser_process_platform_part.h" |
| 14 #include "chrome/browser/chromeos/login/login_utils.h" | 14 #include "chrome/browser/chromeos/login/login_utils.h" |
| 15 #include "chrome/browser/chromeos/login/screen_manager.h" | 15 #include "chrome/browser/chromeos/login/screen_manager.h" |
| 16 #include "chrome/browser/chromeos/login/screens/screen_observer.h" | 16 #include "chrome/browser/chromeos/login/screens/screen_observer.h" |
| 17 #include "chrome/browser/chromeos/login/startup_utils.h" | 17 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 18 #include "chrome/browser/chromeos/login/wizard_controller.h" | 18 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 19 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h" | 19 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h" |
| 20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 21 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" | 21 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" |
| 22 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 22 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 23 #include "chromeos/dbus/cryptohome_client.h" | 23 #include "chromeos/dbus/cryptohome_client.h" |
| 24 #include "chromeos/dbus/dbus_method_call_status.h" | 24 #include "chromeos/dbus/dbus_method_call_status.h" |
| 25 #include "chromeos/dbus/dbus_thread_manager.h" | 25 #include "chromeos/dbus/dbus_thread_manager.h" |
| 26 #include "chromeos/dbus/session_manager_client.h" | 26 #include "chromeos/dbus/session_manager_client.h" |
| 27 #include "components/pairing/controller_pairing_controller.h" | |
| 27 #include "google_apis/gaia/gaia_auth_util.h" | 28 #include "google_apis/gaia/gaia_auth_util.h" |
| 28 #include "google_apis/gaia/google_service_auth_error.h" | 29 #include "google_apis/gaia/google_service_auth_error.h" |
| 29 #include "policy/proto/device_management_backend.pb.h" | 30 #include "policy/proto/device_management_backend.pb.h" |
| 30 | 31 |
| 32 using namespace pairing_chromeos; | |
| 33 | |
| 31 namespace chromeos { | 34 namespace chromeos { |
| 32 | 35 |
| 33 // static | 36 // static |
| 34 EnrollmentScreen* EnrollmentScreen::Get(ScreenManager* manager) { | 37 EnrollmentScreen* EnrollmentScreen::Get(ScreenManager* manager) { |
| 35 return static_cast<EnrollmentScreen*>( | 38 return static_cast<EnrollmentScreen*>( |
| 36 manager->GetScreen(WizardController::kEnrollmentScreenName)); | 39 manager->GetScreen(WizardController::kEnrollmentScreenName)); |
| 37 } | 40 } |
| 38 | 41 |
| 39 EnrollmentScreen::EnrollmentScreen( | 42 EnrollmentScreen::EnrollmentScreen( |
| 40 ScreenObserver* observer, | 43 ScreenObserver* observer, |
| 41 EnrollmentScreenActor* actor) | 44 EnrollmentScreenActor* actor) |
| 42 : WizardScreen(observer), | 45 : WizardScreen(observer), |
| 46 shark_controller_(NULL), | |
| 47 remora_controller_(NULL), | |
| 43 actor_(actor), | 48 actor_(actor), |
| 44 enrollment_mode_(EnrollmentScreenActor::ENROLLMENT_MODE_MANUAL), | 49 enrollment_mode_(EnrollmentScreenActor::ENROLLMENT_MODE_MANUAL), |
| 45 enrollment_failed_once_(false), | 50 enrollment_failed_once_(false), |
| 46 remora_token_sent_(false), | 51 remora_token_sent_(false), |
| 47 lockbox_init_duration_(0), | 52 lockbox_init_duration_(0), |
| 48 weak_ptr_factory_(this) { | 53 weak_ptr_factory_(this) { |
| 49 // Init the TPM if it has not been done until now (in debug build we might | 54 // Init the TPM if it has not been done until now (in debug build we might |
| 50 // have not done that yet). | 55 // have not done that yet). |
| 51 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership( | 56 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership( |
| 52 EmptyVoidDBusMethodCallback()); | 57 EmptyVoidDBusMethodCallback()); |
| 53 } | 58 } |
| 54 | 59 |
| 55 EnrollmentScreen::~EnrollmentScreen() {} | 60 EnrollmentScreen::~EnrollmentScreen() { |
| 61 if (remora_controller_) { | |
|
dzhioev (left Google)
2014/09/09 02:46:50
nit: remove {}
Zachary Kuznia
2014/09/09 23:53:58
Done.
| |
| 62 remora_controller_->RemoveObserver(this); | |
| 63 } | |
| 64 } | |
| 56 | 65 |
| 57 void EnrollmentScreen::SetParameters( | 66 void EnrollmentScreen::SetParameters( |
| 58 EnrollmentScreenActor::EnrollmentMode enrollment_mode, | 67 EnrollmentScreenActor::EnrollmentMode enrollment_mode, |
| 59 const std::string& management_domain, | 68 const std::string& management_domain, |
| 60 const std::string& user, | 69 const std::string& user, |
| 61 const std::string& auth_token) { | 70 const std::string& auth_token, |
| 71 pairing_chromeos::ControllerPairingController* shark_controller, | |
| 72 pairing_chromeos::HostPairingController* remora_controller) { | |
| 62 enrollment_mode_ = enrollment_mode; | 73 enrollment_mode_ = enrollment_mode; |
| 63 user_ = user.empty() ? user : gaia::CanonicalizeEmail(user); | 74 user_ = user.empty() ? user : gaia::CanonicalizeEmail(user); |
| 64 auth_token_ = auth_token; | 75 auth_token_ = auth_token; |
| 76 shark_controller_ = shark_controller; | |
| 77 DCHECK(!remora_controller_); | |
| 78 remora_controller_ = remora_controller; | |
| 79 if (remora_controller_) { | |
|
dzhioev (left Google)
2014/09/09 02:46:51
nit: remove {}
Zachary Kuznia
2014/09/09 23:53:58
Done.
| |
| 80 remora_controller_->AddObserver(this); | |
| 81 } | |
| 65 actor_->SetParameters(this, enrollment_mode_, management_domain); | 82 actor_->SetParameters(this, enrollment_mode_, management_domain); |
| 66 } | 83 } |
| 67 | 84 |
| 68 void EnrollmentScreen::PrepareToShow() { | 85 void EnrollmentScreen::PrepareToShow() { |
| 69 actor_->PrepareToShow(); | 86 actor_->PrepareToShow(); |
| 70 } | 87 } |
| 71 | 88 |
| 72 void EnrollmentScreen::Show() { | 89 void EnrollmentScreen::Show() { |
| 73 if (is_auto_enrollment() && !enrollment_failed_once_) { | 90 if (is_auto_enrollment() && !enrollment_failed_once_) { |
| 74 actor_->Show(); | 91 actor_->Show(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 88 | 105 |
| 89 void EnrollmentScreen::Hide() { | 106 void EnrollmentScreen::Hide() { |
| 90 actor_->Hide(); | 107 actor_->Hide(); |
| 91 weak_ptr_factory_.InvalidateWeakPtrs(); | 108 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 92 } | 109 } |
| 93 | 110 |
| 94 std::string EnrollmentScreen::GetName() const { | 111 std::string EnrollmentScreen::GetName() const { |
| 95 return WizardController::kEnrollmentScreenName; | 112 return WizardController::kEnrollmentScreenName; |
| 96 } | 113 } |
| 97 | 114 |
| 115 void EnrollmentScreen::PairingStageChanged(Stage new_stage) { | |
| 116 DCHECK(remora_controller_); | |
| 117 switch (new_stage) { | |
|
achuithb
2014/09/09 09:02:02
Can't we just replace this switch with
if (new_sta
Zachary Kuznia
2014/09/09 23:53:58
Done.
| |
| 118 case HostPairingController::STAGE_NONE: | |
| 119 case HostPairingController::STAGE_INITIALIZATION_ERROR: | |
| 120 case HostPairingController::STAGE_WAITING_FOR_CONTROLLER: | |
| 121 case HostPairingController::STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE: | |
| 122 case HostPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION: | |
| 123 case HostPairingController::STAGE_UPDATING: | |
| 124 case HostPairingController::STAGE_WAITING_FOR_CREDENTIALS: | |
| 125 case HostPairingController::STAGE_ENROLLING: | |
| 126 NOTREACHED(); | |
| 127 break; | |
| 128 | |
| 129 case HostPairingController::STAGE_ENROLLMENT_ERROR: | |
| 130 case HostPairingController::STAGE_PAIRING_DONE: | |
| 131 break; | |
| 132 | |
| 133 case HostPairingController::STAGE_FINISHED: { | |
| 134 remora_controller_->RemoveObserver(this); | |
| 135 remora_controller_ = NULL; | |
| 136 get_screen_observer()->OnExit( | |
| 137 WizardController::ENTERPRISE_AUTO_MAGIC_ENROLLMENT_COMPLETED); | |
| 138 break; | |
| 139 } | |
| 140 } | |
| 141 } | |
| 142 | |
| 143 void EnrollmentScreen::ConfigureHost(bool accepted_eula, | |
| 144 const std::string& lang, | |
| 145 const std::string& timezone, | |
| 146 bool send_reports, | |
| 147 const std::string& keyboard_layout) {} | |
|
achuithb
2014/09/09 09:02:02
Shouldn't the } be on a new line?
Zachary Kuznia
2014/09/09 23:53:58
Done.
| |
| 148 | |
| 149 void EnrollmentScreen::EnrollHost(const std::string& auth_token) {} | |
|
achuithb
2014/09/09 09:02:02
same
Zachary Kuznia
2014/09/09 23:53:58
Done.
| |
| 150 | |
| 98 void EnrollmentScreen::OnLoginDone(const std::string& user) { | 151 void EnrollmentScreen::OnLoginDone(const std::string& user) { |
| 99 user_ = gaia::CanonicalizeEmail(user); | 152 user_ = gaia::CanonicalizeEmail(user); |
| 100 | 153 |
| 101 if (is_auto_enrollment()) | 154 if (is_auto_enrollment()) |
| 102 UMA(policy::kMetricEnrollmentAutoRetried); | 155 UMA(policy::kMetricEnrollmentAutoRetried); |
| 103 else if (enrollment_failed_once_) | 156 else if (enrollment_failed_once_) |
| 104 UMA(policy::kMetricEnrollmentRetried); | 157 UMA(policy::kMetricEnrollmentRetried); |
| 105 else | 158 else |
| 106 UMA(policy::kMetricEnrollmentStarted); | 159 UMA(policy::kMetricEnrollmentStarted); |
| 107 | 160 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 CHECK(dcp_initializer); | 285 CHECK(dcp_initializer); |
| 233 dcp_initializer->StartEnrollment( | 286 dcp_initializer->StartEnrollment( |
| 234 enterprise_management::PolicyData::ENTERPRISE_MANAGED, | 287 enterprise_management::PolicyData::ENTERPRISE_MANAGED, |
| 235 connector->device_management_service(), | 288 connector->device_management_service(), |
| 236 token, is_auto_enrollment(), device_modes, | 289 token, is_auto_enrollment(), device_modes, |
| 237 base::Bind(&EnrollmentScreen::ReportEnrollmentStatus, | 290 base::Bind(&EnrollmentScreen::ReportEnrollmentStatus, |
| 238 weak_ptr_factory_.GetWeakPtr())); | 291 weak_ptr_factory_.GetWeakPtr())); |
| 239 } | 292 } |
| 240 | 293 |
| 241 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { | 294 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { |
| 242 // TODO(achuith, zork): Send token via Bluetooth to remote device. | 295 // TODO(achuith, zork): Extract and send domain. |
| 296 if (shark_controller_) | |
| 297 shark_controller_->OnAuthenticationDone("", token); | |
| 243 } | 298 } |
| 244 | 299 |
| 245 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess( | 300 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess( |
| 246 const policy::EnrollmentStatus& status) { | 301 const policy::EnrollmentStatus& status) { |
| 247 actor_->ShowEnrollmentStatus(status); | 302 actor_->ShowEnrollmentStatus(status); |
| 248 StartupUtils::MarkOobeCompleted(); | 303 StartupUtils::MarkOobeCompleted(); |
| 249 } | 304 } |
| 250 | 305 |
| 251 void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) { | 306 void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) { |
| 252 switch (status.status()) { | 307 switch (status.status()) { |
| 253 case policy::EnrollmentStatus::STATUS_SUCCESS: | 308 case policy::EnrollmentStatus::STATUS_SUCCESS: |
| 254 StartupUtils::MarkDeviceRegistered( | 309 StartupUtils::MarkDeviceRegistered( |
| 255 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess, | 310 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess, |
| 256 weak_ptr_factory_.GetWeakPtr(), | 311 weak_ptr_factory_.GetWeakPtr(), |
| 257 status)); | 312 status)); |
| 258 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoOK | 313 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoOK |
| 259 : policy::kMetricEnrollmentOK); | 314 : policy::kMetricEnrollmentOK); |
| 315 if (remora_controller_) { | |
|
dzhioev (left Google)
2014/09/09 02:46:51
ditto
Zachary Kuznia
2014/09/09 23:53:58
Done.
| |
| 316 remora_controller_->SetEnrollmentComplete(true); | |
| 317 } | |
| 260 return; | 318 return; |
| 261 case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED: | 319 case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED: |
| 262 case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED: | 320 case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED: |
| 263 switch (status.client_status()) { | 321 switch (status.client_status()) { |
| 264 case policy::DM_STATUS_SUCCESS: | 322 case policy::DM_STATUS_SUCCESS: |
| 265 case policy::DM_STATUS_REQUEST_INVALID: | 323 case policy::DM_STATUS_REQUEST_INVALID: |
| 266 case policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND: | 324 case policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND: |
| 267 case policy::DM_STATUS_SERVICE_MANAGEMENT_TOKEN_INVALID: | 325 case policy::DM_STATUS_SERVICE_MANAGEMENT_TOKEN_INVALID: |
| 268 case policy::DM_STATUS_SERVICE_ACTIVATION_PENDING: | 326 case policy::DM_STATUS_SERVICE_ACTIVATION_PENDING: |
| 269 case policy::DM_STATUS_SERVICE_DEVICE_ID_CONFLICT: | 327 case policy::DM_STATUS_SERVICE_DEVICE_ID_CONFLICT: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 UMAFailure(policy::kMetricEnrollmentRobotRefreshTokenStoreFailed); | 382 UMAFailure(policy::kMetricEnrollmentRobotRefreshTokenStoreFailed); |
| 325 break; | 383 break; |
| 326 case policy::EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED: | 384 case policy::EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED: |
| 327 // This error should not happen for enterprise enrollment, it only affects | 385 // This error should not happen for enterprise enrollment, it only affects |
| 328 // consumer enrollment. | 386 // consumer enrollment. |
| 329 UMAFailure(policy::kMetricEnrollmentStoreTokenAndIdFailed); | 387 UMAFailure(policy::kMetricEnrollmentStoreTokenAndIdFailed); |
| 330 NOTREACHED(); | 388 NOTREACHED(); |
| 331 break; | 389 break; |
| 332 } | 390 } |
| 333 | 391 |
| 392 if (remora_controller_) { | |
|
dzhioev (left Google)
2014/09/09 02:46:50
ditto
Zachary Kuznia
2014/09/09 23:53:58
Done.
| |
| 393 remora_controller_->SetEnrollmentComplete(false); | |
| 394 } | |
| 334 enrollment_failed_once_ = true; | 395 enrollment_failed_once_ = true; |
| 335 actor_->ShowEnrollmentStatus(status); | 396 actor_->ShowEnrollmentStatus(status); |
| 336 } | 397 } |
| 337 | 398 |
| 338 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { | 399 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { |
| 339 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_RECOVERY) { | 400 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_RECOVERY) { |
| 340 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollmentRecovery, sample, | 401 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollmentRecovery, sample, |
| 341 policy::kMetricEnrollmentSize); | 402 policy::kMetricEnrollmentSize); |
| 342 } else { | 403 } else { |
| 343 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment, sample, | 404 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment, sample, |
| 344 policy::kMetricEnrollmentSize); | 405 policy::kMetricEnrollmentSize); |
| 345 } | 406 } |
| 346 } | 407 } |
| 347 | 408 |
| 348 void EnrollmentScreen::UMAFailure(policy::MetricEnrollment sample) { | 409 void EnrollmentScreen::UMAFailure(policy::MetricEnrollment sample) { |
| 349 if (is_auto_enrollment()) | 410 if (is_auto_enrollment()) |
| 350 sample = policy::kMetricEnrollmentAutoFailed; | 411 sample = policy::kMetricEnrollmentAutoFailed; |
| 351 UMA(sample); | 412 UMA(sample); |
| 352 } | 413 } |
| 353 | 414 |
| 354 void EnrollmentScreen::ShowSigninScreen() { | 415 void EnrollmentScreen::ShowSigninScreen() { |
| 355 actor_->Show(); | 416 actor_->Show(); |
| 356 actor_->ShowSigninScreen(); | 417 actor_->ShowSigninScreen(); |
| 357 } | 418 } |
| 358 | 419 |
| 359 } // namespace chromeos | 420 } // namespace chromeos |
| OLD | NEW |