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

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: comments+create ActiveDirectoryJoinDelegate 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 current_auth_ = AUTH_OAUTH; 113 current_auth_ = AUTH_OAUTH;
116 SetConfig(); 114 SetConfig();
117 return true; 115 return true;
118 } 116 }
119 return false; 117 return false;
120 } 118 }
121 119
122 void EnrollmentScreen::CreateEnrollmentHelper() { 120 void EnrollmentScreen::CreateEnrollmentHelper() {
123 if (!enrollment_helper_) { 121 if (!enrollment_helper_) {
124 enrollment_helper_ = EnterpriseEnrollmentHelper::Create( 122 enrollment_helper_ = EnterpriseEnrollmentHelper::Create(
125 this, config_, enrolling_user_domain_); 123 this, this, config_, enrolling_user_domain_);
126 } 124 }
127 } 125 }
128 126
129 void EnrollmentScreen::ClearAuth(const base::Closure& callback) { 127 void EnrollmentScreen::ClearAuth(const base::Closure& callback) {
130 if (!enrollment_helper_) { 128 if (!enrollment_helper_) {
131 callback.Run(); 129 callback.Run();
132 return; 130 return;
133 } 131 }
134 enrollment_helper_->ClearAuth(base::Bind(&EnrollmentScreen::OnAuthCleared, 132 enrollment_helper_->ClearAuth(base::Bind(&EnrollmentScreen::OnAuthCleared,
135 weak_ptr_factory_.GetWeakPtr(), 133 weak_ptr_factory_.GetWeakPtr(),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 actor_->Show(); 170 actor_->Show();
173 CreateEnrollmentHelper(); 171 CreateEnrollmentHelper();
174 enrollment_helper_->EnrollUsingAttestation(); 172 enrollment_helper_->EnrollUsingAttestation();
175 } 173 }
176 174
177 void EnrollmentScreen::OnLoginDone(const std::string& user, 175 void EnrollmentScreen::OnLoginDone(const std::string& user,
178 const std::string& auth_code) { 176 const std::string& auth_code) {
179 LOG_IF(ERROR, auth_code.empty()) << "Auth code is empty."; 177 LOG_IF(ERROR, auth_code.empty()) << "Auth code is empty.";
180 elapsed_timer_.reset(new base::ElapsedTimer()); 178 elapsed_timer_.reset(new base::ElapsedTimer());
181 enrolling_user_domain_ = gaia::ExtractDomainName(user); 179 enrolling_user_domain_ = gaia::ExtractDomainName(user);
182 auth_code_ = auth_code; 180 UMA(enrollment_failed_once_ ? policy::kMetricEnrollmentRestarted
183 // TODO(rsorokin): Move ShowAdJoin after STEP_REGISTRATION 181 : policy::kMetricEnrollmentStarted);
184 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 182
185 chromeos::switches::kEnableAd)) { 183 actor_->ShowEnrollmentSpinnerScreen();
186 actor_->ShowAdJoin(); 184 CreateEnrollmentHelper();
187 } else { 185 enrollment_helper_->EnrollUsingAuthCode(
188 OnAdJoined(""); 186 auth_code, shark_controller_ != nullptr /* fetch_additional_token */);
189 }
190 } 187 }
191 188
192 void EnrollmentScreen::OnRetry() { 189 void EnrollmentScreen::OnRetry() {
193 Show(); 190 Show();
194 } 191 }
195 192
196 void EnrollmentScreen::OnCancel() { 193 void EnrollmentScreen::OnCancel() {
197 if (AdvanceToNextAuth()) { 194 if (AdvanceToNextAuth()) {
198 Show(); 195 Show();
199 return; 196 return;
200 } 197 }
201 198
202 UMA(policy::kMetricEnrollmentCancelled); 199 UMA(policy::kMetricEnrollmentCancelled);
203 if (elapsed_timer_) 200 if (elapsed_timer_)
204 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeCancel, elapsed_timer_); 201 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeCancel, elapsed_timer_);
205 202
206 const BaseScreenDelegate::ExitCodes exit_code = 203 const BaseScreenDelegate::ExitCodes exit_code =
207 config_.is_forced() ? BaseScreenDelegate::ENTERPRISE_ENROLLMENT_BACK 204 config_.is_forced() ? BaseScreenDelegate::ENTERPRISE_ENROLLMENT_BACK
208 : BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED; 205 : BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED;
209 ClearAuth( 206 ClearAuth(
210 base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), exit_code)); 207 base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), exit_code));
211 } 208 }
212 209
213 void EnrollmentScreen::OnConfirmationClosed() { 210 void EnrollmentScreen::OnConfirmationClosed() {
214 ClearAuth(base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), 211 ClearAuth(base::Bind(&EnrollmentScreen::Finish, base::Unretained(this),
215 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED)); 212 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED));
216 } 213 }
217 214
218 void EnrollmentScreen::OnAdJoined(const std::string& realm) { 215 void EnrollmentScreen::OnAdJoined(const std::string& realm) {
219 if (!realm.empty()) { 216 std::move(on_joined_callback_).Run(realm);
220 config_.management_realm = realm;
221 }
222 UMA(enrollment_failed_once_ ? policy::kMetricEnrollmentRestarted
223 : policy::kMetricEnrollmentStarted);
224
225 actor_->ShowEnrollmentSpinnerScreen();
226 CreateEnrollmentHelper();
227 enrollment_helper_->EnrollUsingAuthCode(
228 auth_code_, shark_controller_ != NULL /* fetch_additional_token */);
229 } 217 }
230 218
231 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { 219 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) {
232 RecordEnrollmentErrorMetrics(); 220 RecordEnrollmentErrorMetrics();
233 actor_->ShowAuthError(error); 221 actor_->ShowAuthError(error);
234 } 222 }
235 223
236 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) { 224 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) {
237 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. 225 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed.
238 LOG(WARNING) << "Enrollment error occured: status=" << status.status() 226 LOG(WARNING) << "Enrollment error occured: status=" << status.status()
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 actor_->ShowSigninScreen(); 326 actor_->ShowSigninScreen();
339 } 327 }
340 328
341 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { 329 void EnrollmentScreen::RecordEnrollmentErrorMetrics() {
342 enrollment_failed_once_ = true; 330 enrollment_failed_once_ = true;
343 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? 331 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)?
344 if (elapsed_timer_) 332 if (elapsed_timer_)
345 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); 333 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_);
346 } 334 }
347 335
336 void EnrollmentScreen::JoinDomain(OnDomainJoinedCallback on_joined_callback) {
337 on_joined_callback_ = std::move(on_joined_callback);
338 actor_->ShowAdJoin();
339 }
340
348 } // namespace chromeos 341 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698