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

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

Issue 2677563005: Chromad: Use DM server reply to determine enrollment type (Closed)
Patch Set: More comments Created 3 years, 10 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/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
13 #include "base/timer/elapsed_timer.h" 12 #include "base/timer/elapsed_timer.h"
14 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/browser_process_platform_part.h" 14 #include "chrome/browser/browser_process_platform_part.h"
16 #include "chrome/browser/chromeos/login/enrollment/enrollment_uma.h" 15 #include "chrome/browser/chromeos/login/enrollment/enrollment_uma.h"
17 #include "chrome/browser/chromeos/login/screen_manager.h" 16 #include "chrome/browser/chromeos/login/screen_manager.h"
18 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" 17 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h"
19 #include "chrome/browser/chromeos/login/startup_utils.h" 18 #include "chrome/browser/chromeos/login/startup_utils.h"
20 #include "chrome/browser/chromeos/login/wizard_controller.h" 19 #include "chrome/browser/chromeos/login/wizard_controller.h"
21 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
22 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" 21 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
23 #include "chrome/browser/chromeos/profiles/profile_helper.h" 22 #include "chrome/browser/chromeos/profiles/profile_helper.h"
24 #include "chromeos/chromeos_switches.h"
25 #include "chromeos/dbus/cryptohome_client.h" 23 #include "chromeos/dbus/cryptohome_client.h"
26 #include "chromeos/dbus/dbus_method_call_status.h" 24 #include "chromeos/dbus/dbus_method_call_status.h"
27 #include "chromeos/dbus/dbus_thread_manager.h" 25 #include "chromeos/dbus/dbus_thread_manager.h"
28 #include "components/pairing/controller_pairing_controller.h" 26 #include "components/pairing/controller_pairing_controller.h"
29 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 27 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
30 #include "google_apis/gaia/gaia_auth_util.h" 28 #include "google_apis/gaia/gaia_auth_util.h"
31 29
32 using namespace pairing_chromeos; 30 using namespace pairing_chromeos;
33 using policy::EnrollmentConfig; 31 using policy::EnrollmentConfig;
34 32
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 current_auth_ = AUTH_OAUTH; 135 current_auth_ = AUTH_OAUTH;
138 SetConfig(); 136 SetConfig();
139 return true; 137 return true;
140 } 138 }
141 return false; 139 return false;
142 } 140 }
143 141
144 void EnrollmentScreen::CreateEnrollmentHelper() { 142 void EnrollmentScreen::CreateEnrollmentHelper() {
145 if (!enrollment_helper_) { 143 if (!enrollment_helper_) {
146 enrollment_helper_ = EnterpriseEnrollmentHelper::Create( 144 enrollment_helper_ = EnterpriseEnrollmentHelper::Create(
147 this, config_, enrolling_user_domain_); 145 this, this, config_, enrolling_user_domain_);
148 } 146 }
149 } 147 }
150 148
151 void EnrollmentScreen::ClearAuth(const base::Closure& callback) { 149 void EnrollmentScreen::ClearAuth(const base::Closure& callback) {
152 if (!enrollment_helper_) { 150 if (!enrollment_helper_) {
153 callback.Run(); 151 callback.Run();
154 return; 152 return;
155 } 153 }
156 enrollment_helper_->ClearAuth(base::Bind(&EnrollmentScreen::OnAuthCleared, 154 enrollment_helper_->ClearAuth(base::Bind(&EnrollmentScreen::OnAuthCleared,
157 weak_ptr_factory_.GetWeakPtr(), 155 weak_ptr_factory_.GetWeakPtr(),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 actor_->Show(); 192 actor_->Show();
195 CreateEnrollmentHelper(); 193 CreateEnrollmentHelper();
196 enrollment_helper_->EnrollUsingAttestation(); 194 enrollment_helper_->EnrollUsingAttestation();
197 } 195 }
198 196
199 void EnrollmentScreen::OnLoginDone(const std::string& user, 197 void EnrollmentScreen::OnLoginDone(const std::string& user,
200 const std::string& auth_code) { 198 const std::string& auth_code) {
201 LOG_IF(ERROR, auth_code.empty()) << "Auth code is empty."; 199 LOG_IF(ERROR, auth_code.empty()) << "Auth code is empty.";
202 elapsed_timer_.reset(new base::ElapsedTimer()); 200 elapsed_timer_.reset(new base::ElapsedTimer());
203 enrolling_user_domain_ = gaia::ExtractDomainName(user); 201 enrolling_user_domain_ = gaia::ExtractDomainName(user);
204 auth_code_ = auth_code; 202 UMA(enrollment_failed_once_ ? policy::kMetricEnrollmentRestarted
205 // TODO(rsorokin): Move ShowAdJoin after STEP_REGISTRATION 203 : policy::kMetricEnrollmentStarted);
206 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 204
207 chromeos::switches::kEnableAd)) { 205 actor_->ShowEnrollmentSpinnerScreen();
208 actor_->ShowAdJoin(); 206 CreateEnrollmentHelper();
209 } else { 207 enrollment_helper_->EnrollUsingAuthCode(
210 OnAdJoined(""); 208 auth_code, shark_controller_ != nullptr /* fetch_additional_token */);
211 }
212 } 209 }
213 210
214 void EnrollmentScreen::OnRetry() { 211 void EnrollmentScreen::OnRetry() {
215 retry_task_.Cancel(); 212 retry_task_.Cancel();
216 ProcessRetry(); 213 ProcessRetry();
217 } 214 }
218 215
219 void EnrollmentScreen::AutomaticRetry() { 216 void EnrollmentScreen::AutomaticRetry() {
220 retry_backoff_->InformOfRequest(false); 217 retry_backoff_->InformOfRequest(false);
221 retry_task_.Reset(base::Bind(&EnrollmentScreen::ProcessRetry, 218 retry_task_.Reset(base::Bind(&EnrollmentScreen::ProcessRetry,
(...skipping 25 matching lines...) Expand all
247 ClearAuth( 244 ClearAuth(
248 base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), exit_code)); 245 base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), exit_code));
249 } 246 }
250 247
251 void EnrollmentScreen::OnConfirmationClosed() { 248 void EnrollmentScreen::OnConfirmationClosed() {
252 ClearAuth(base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), 249 ClearAuth(base::Bind(&EnrollmentScreen::Finish, base::Unretained(this),
253 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED)); 250 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED));
254 } 251 }
255 252
256 void EnrollmentScreen::OnAdJoined(const std::string& realm) { 253 void EnrollmentScreen::OnAdJoined(const std::string& realm) {
257 if (!realm.empty()) { 254 std::move(on_joined_callback_).Run(realm);
258 config_.management_realm = realm;
259 }
260 UMA(enrollment_failed_once_ ? policy::kMetricEnrollmentRestarted
261 : policy::kMetricEnrollmentStarted);
262
263 actor_->ShowEnrollmentSpinnerScreen();
264 CreateEnrollmentHelper();
265 enrollment_helper_->EnrollUsingAuthCode(
266 auth_code_, shark_controller_ != NULL /* fetch_additional_token */);
267 } 255 }
268 256
269 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { 257 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) {
270 RecordEnrollmentErrorMetrics(); 258 RecordEnrollmentErrorMetrics();
271 actor_->ShowAuthError(error); 259 actor_->ShowAuthError(error);
272 } 260 }
273 261
274 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) { 262 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) {
275 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. 263 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed.
276 LOG(WARNING) << "Enrollment error occured: status=" << status.status() 264 LOG(WARNING) << "Enrollment error occured: status=" << status.status()
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 actor_->ShowSigninScreen(); 374 actor_->ShowSigninScreen();
387 } 375 }
388 376
389 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { 377 void EnrollmentScreen::RecordEnrollmentErrorMetrics() {
390 enrollment_failed_once_ = true; 378 enrollment_failed_once_ = true;
391 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? 379 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)?
392 if (elapsed_timer_) 380 if (elapsed_timer_)
393 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); 381 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_);
394 } 382 }
395 383
384 void EnrollmentScreen::JoinDomain(OnDomainJoinedCallback on_joined_callback) {
385 on_joined_callback_ = std::move(on_joined_callback);
386 actor_->ShowAdJoin();
387 }
388
396 } // namespace chromeos 389 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698