Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(727)

Side by Side Diff: chrome/browser/chromeos/login/enrollment/enrollment_screen.cc

Issue 652743003: Fix update and enrollment flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: indent Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 EnrollmentScreen::~EnrollmentScreen() { 72 EnrollmentScreen::~EnrollmentScreen() {
73 if (remora_controller_) 73 if (remora_controller_)
74 remora_controller_->RemoveObserver(this); 74 remora_controller_->RemoveObserver(this);
75 } 75 }
76 76
77 void EnrollmentScreen::SetParameters( 77 void EnrollmentScreen::SetParameters(
78 EnrollmentScreenActor::EnrollmentMode enrollment_mode, 78 EnrollmentScreenActor::EnrollmentMode enrollment_mode,
79 const std::string& management_domain, 79 const std::string& management_domain,
80 const std::string& user, 80 const std::string& user,
81 const std::string& auth_token,
82 pairing_chromeos::ControllerPairingController* shark_controller, 81 pairing_chromeos::ControllerPairingController* shark_controller,
83 pairing_chromeos::HostPairingController* remora_controller) { 82 pairing_chromeos::HostPairingController* remora_controller) {
84 enrollment_mode_ = enrollment_mode; 83 enrollment_mode_ = enrollment_mode;
85 user_ = user.empty() ? user : gaia::CanonicalizeEmail(user); 84 user_ = user.empty() ? user : gaia::CanonicalizeEmail(user);
86 auth_token_ = auth_token;
87 shark_controller_ = shark_controller; 85 shark_controller_ = shark_controller;
88 if (remora_controller_) 86 if (remora_controller_)
89 remora_controller_->RemoveObserver(this); 87 remora_controller_->RemoveObserver(this);
90 remora_controller_ = remora_controller; 88 remora_controller_ = remora_controller;
91 if (remora_controller_) 89 if (remora_controller_)
92 remora_controller_->AddObserver(this); 90 remora_controller_->AddObserver(this);
93 actor_->SetParameters(this, enrollment_mode_, management_domain); 91 actor_->SetParameters(this, enrollment_mode_, management_domain);
94 } 92 }
95 93
96 void EnrollmentScreen::PrepareToShow() { 94 void EnrollmentScreen::PrepareToShow() {
97 actor_->PrepareToShow(); 95 actor_->PrepareToShow();
98 } 96 }
99 97
100 void EnrollmentScreen::Show() { 98 void EnrollmentScreen::Show() {
101 if (is_auto_enrollment() && !enrollment_failed_once_) { 99 if (is_auto_enrollment() && !enrollment_failed_once_) {
102 actor_->Show(); 100 actor_->Show();
103 UMA(policy::kMetricEnrollmentAutoStarted); 101 UMA(policy::kMetricEnrollmentAutoStarted);
104 actor_->ShowEnrollmentSpinnerScreen(); 102 actor_->ShowEnrollmentSpinnerScreen();
105 actor_->FetchOAuthToken(); 103 actor_->FetchOAuthToken();
106 } else if (auth_token_.empty()) { 104 } else {
107 UMA(policy::kMetricEnrollmentTriggered); 105 UMA(policy::kMetricEnrollmentTriggered);
108 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen, 106 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen,
109 weak_ptr_factory_.GetWeakPtr())); 107 weak_ptr_factory_.GetWeakPtr()));
110 } else {
111 actor_->Show();
112 actor_->ShowEnrollmentSpinnerScreen();
113 OnOAuthTokenAvailable(auth_token_);
114 } 108 }
115 } 109 }
116 110
117 void EnrollmentScreen::Hide() { 111 void EnrollmentScreen::Hide() {
118 actor_->Hide(); 112 actor_->Hide();
119 weak_ptr_factory_.InvalidateWeakPtrs(); 113 weak_ptr_factory_.InvalidateWeakPtrs();
120 } 114 }
121 115
122 std::string EnrollmentScreen::GetName() const { 116 std::string EnrollmentScreen::GetName() const {
123 return WizardController::kEnrollmentScreenName; 117 return WizardController::kEnrollmentScreenName;
124 } 118 }
125 119
126 void EnrollmentScreen::PairingStageChanged(Stage new_stage) { 120 void EnrollmentScreen::PairingStageChanged(Stage new_stage) {
127 DCHECK(remora_controller_); 121 DCHECK(remora_controller_);
128 if (new_stage == HostPairingController::STAGE_FINISHED) { 122 if (new_stage == HostPairingController::STAGE_FINISHED) {
129 remora_controller_->RemoveObserver(this); 123 remora_controller_->RemoveObserver(this);
130 remora_controller_ = NULL; 124 remora_controller_ = NULL;
131 // TODO(zork): Check that this is the best exit status. crbug.com/412798 125 OnConfirmationClosed();
132 get_screen_observer()->OnExit(
133 WizardController::ENTERPRISE_AUTO_MAGIC_ENROLLMENT_COMPLETED);
134 } 126 }
135 } 127 }
136 128
137 void EnrollmentScreen::ConfigureHost(bool accepted_eula, 129 void EnrollmentScreen::ConfigureHost(bool accepted_eula,
138 const std::string& lang, 130 const std::string& lang,
139 const std::string& timezone, 131 const std::string& timezone,
140 bool send_reports, 132 bool send_reports,
141 const std::string& keyboard_layout) { 133 const std::string& keyboard_layout) {
142 } 134 }
143 135
144 void EnrollmentScreen::EnrollHost(const std::string& auth_token) { 136 void EnrollmentScreen::EnrollHost(const std::string& auth_token) {
145 // TODO(achuith, zork): Move this to ConfigureHost (crbug.com/419512). 137 // TODO(achuith, zork): Move this to ConfigureHost (crbug.com/419512).
146 StartupUtils::MarkEulaAccepted(); 138 StartupUtils::MarkEulaAccepted();
147 139
148 actor_->Show(); 140 actor_->Show();
149 actor_->ShowEnrollmentSpinnerScreen(); 141 actor_->ShowEnrollmentSpinnerScreen();
150 OnOAuthTokenAvailable(auth_token); 142 OnOAuthTokenAvailable(auth_token);
143 if (remora_controller_) {
144 remora_controller_->OnEnrollmentStatusChanged(
145 HostPairingController::ENROLLMENT_STATUS_ENROLLING);
146 }
151 } 147 }
152 148
153 void EnrollmentScreen::OnLoginDone(const std::string& user) { 149 void EnrollmentScreen::OnLoginDone(const std::string& user) {
154 elapsed_timer_.reset(new base::ElapsedTimer()); 150 elapsed_timer_.reset(new base::ElapsedTimer());
155 user_ = gaia::CanonicalizeEmail(user); 151 user_ = gaia::CanonicalizeEmail(user);
156 152
157 if (is_auto_enrollment()) 153 if (is_auto_enrollment())
158 UMA(policy::kMetricEnrollmentAutoRestarted); 154 UMA(policy::kMetricEnrollmentAutoRestarted);
159 else if (enrollment_failed_once_) 155 else if (enrollment_failed_once_)
160 UMA(policy::kMetricEnrollmentRestarted); 156 UMA(policy::kMetricEnrollmentRestarted);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 315
320 void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) { 316 void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) {
321 switch (status.status()) { 317 switch (status.status()) {
322 case policy::EnrollmentStatus::STATUS_SUCCESS: 318 case policy::EnrollmentStatus::STATUS_SUCCESS:
323 StartupUtils::MarkDeviceRegistered( 319 StartupUtils::MarkDeviceRegistered(
324 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess, 320 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess,
325 weak_ptr_factory_.GetWeakPtr(), 321 weak_ptr_factory_.GetWeakPtr(),
326 status)); 322 status));
327 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoOK 323 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoOK
328 : policy::kMetricEnrollmentOK); 324 : policy::kMetricEnrollmentOK);
329 if (remora_controller_) 325 if (remora_controller_) {
330 remora_controller_->SetEnrollmentComplete(true); 326 remora_controller_->OnEnrollmentStatusChanged(
327 HostPairingController::ENROLLMENT_STATUS_SUCCESS);
328 }
331 return; 329 return;
332 case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED: 330 case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED:
333 case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED: 331 case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED:
334 switch (status.client_status()) { 332 switch (status.client_status()) {
335 case policy::DM_STATUS_SUCCESS: 333 case policy::DM_STATUS_SUCCESS:
336 NOTREACHED(); 334 NOTREACHED();
337 break; 335 break;
338 case policy::DM_STATUS_REQUEST_INVALID: 336 case policy::DM_STATUS_REQUEST_INVALID:
339 UMAFailure(policy::kMetricEnrollmentRegisterPolicyPayloadInvalid); 337 UMAFailure(policy::kMetricEnrollmentRegisterPolicyPayloadInvalid);
340 break; 338 break;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 UMAFailure(policy::kMetricEnrollmentRobotRefreshTokenStoreFailed); 411 UMAFailure(policy::kMetricEnrollmentRobotRefreshTokenStoreFailed);
414 break; 412 break;
415 case policy::EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED: 413 case policy::EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED:
416 // This error should not happen for enterprise enrollment, it only affects 414 // This error should not happen for enterprise enrollment, it only affects
417 // consumer enrollment. 415 // consumer enrollment.
418 UMAFailure(policy::kMetricEnrollmentStoreTokenAndIdFailed); 416 UMAFailure(policy::kMetricEnrollmentStoreTokenAndIdFailed);
419 NOTREACHED(); 417 NOTREACHED();
420 break; 418 break;
421 } 419 }
422 420
423 if (remora_controller_) 421 if (remora_controller_) {
424 remora_controller_->SetEnrollmentComplete(false); 422 remora_controller_->OnEnrollmentStatusChanged(
423 HostPairingController::ENROLLMENT_STATUS_FAILURE);
424 }
425 enrollment_failed_once_ = true; 425 enrollment_failed_once_ = true;
426 if (elapsed_timer_) 426 if (elapsed_timer_)
427 UMA_ENROLLMENT_TIME("Enterprise.EnrollmentTime.Failure", elapsed_timer_); 427 UMA_ENROLLMENT_TIME("Enterprise.EnrollmentTime.Failure", elapsed_timer_);
428 actor_->ShowEnrollmentStatus(status); 428 actor_->ShowEnrollmentStatus(status);
429 } 429 }
430 430
431 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { 431 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) {
432 switch (enrollment_mode_) { 432 switch (enrollment_mode_) {
433 case EnrollmentScreenActor::ENROLLMENT_MODE_MANUAL: 433 case EnrollmentScreenActor::ENROLLMENT_MODE_MANUAL:
434 case EnrollmentScreenActor::ENROLLMENT_MODE_AUTO: 434 case EnrollmentScreenActor::ENROLLMENT_MODE_AUTO:
(...skipping 16 matching lines...) Expand all
451 sample = policy::kMetricEnrollmentAutoFailed; 451 sample = policy::kMetricEnrollmentAutoFailed;
452 UMA(sample); 452 UMA(sample);
453 } 453 }
454 454
455 void EnrollmentScreen::ShowSigninScreen() { 455 void EnrollmentScreen::ShowSigninScreen() {
456 actor_->Show(); 456 actor_->Show();
457 actor_->ShowSigninScreen(); 457 actor_->ShowSigninScreen();
458 } 458 }
459 459
460 } // namespace chromeos 460 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698