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

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

Issue 2433363004: Chromad: added AD Join ui, authpolicy_client (Closed)
Patch Set: nit Created 4 years, 1 month 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"
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 actor_->Show(); 180 actor_->Show();
179 CreateEnrollmentHelper(); 181 CreateEnrollmentHelper();
180 enrollment_helper_->EnrollUsingAttestation(); 182 enrollment_helper_->EnrollUsingAttestation();
181 } 183 }
182 184
183 void EnrollmentScreen::OnLoginDone(const std::string& user, 185 void EnrollmentScreen::OnLoginDone(const std::string& user,
184 const std::string& auth_code) { 186 const std::string& auth_code) {
185 LOG_IF(ERROR, auth_code.empty()) << "Auth code is empty."; 187 LOG_IF(ERROR, auth_code.empty()) << "Auth code is empty.";
186 elapsed_timer_.reset(new base::ElapsedTimer()); 188 elapsed_timer_.reset(new base::ElapsedTimer());
187 enrolling_user_domain_ = gaia::ExtractDomainName(user); 189 enrolling_user_domain_ = gaia::ExtractDomainName(user);
188 190 auth_code_ = auth_code;
189 UMA(enrollment_failed_once_ ? policy::kMetricEnrollmentRestarted 191 // TODO(rsorokin): Move ShowAdJoin after STEP_REGISTRATION
190 : policy::kMetricEnrollmentStarted); 192 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
191 193 chromeos::switches::kEnableAd)) {
192 actor_->ShowEnrollmentSpinnerScreen(); 194 actor_->ShowAdJoin();
193 CreateEnrollmentHelper(); 195 } else {
194 enrollment_helper_->EnrollUsingAuthCode( 196 OnAdJoined("");
195 auth_code, shark_controller_ != nullptr /* fetch_additional_token */); 197 }
196 } 198 }
197 199
198 void EnrollmentScreen::OnRetry() { 200 void EnrollmentScreen::OnRetry() {
199 Show(); 201 Show();
200 } 202 }
201 203
202 void EnrollmentScreen::OnCancel() { 204 void EnrollmentScreen::OnCancel() {
203 if (AdvanceToNextAuth()) { 205 if (AdvanceToNextAuth()) {
204 Show(); 206 Show();
205 return; 207 return;
206 } 208 }
207 209
208 UMA(policy::kMetricEnrollmentCancelled); 210 UMA(policy::kMetricEnrollmentCancelled);
209 if (elapsed_timer_) 211 if (elapsed_timer_)
210 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeCancel, elapsed_timer_); 212 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeCancel, elapsed_timer_);
211 213
212 const BaseScreenDelegate::ExitCodes exit_code = 214 const BaseScreenDelegate::ExitCodes exit_code =
213 config_.is_forced() ? BaseScreenDelegate::ENTERPRISE_ENROLLMENT_BACK 215 config_.is_forced() ? BaseScreenDelegate::ENTERPRISE_ENROLLMENT_BACK
214 : BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED; 216 : BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED;
215 ClearAuth( 217 ClearAuth(
216 base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), exit_code)); 218 base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), exit_code));
217 } 219 }
218 220
219 void EnrollmentScreen::OnConfirmationClosed() { 221 void EnrollmentScreen::OnConfirmationClosed() {
220 ClearAuth(base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), 222 ClearAuth(base::Bind(&EnrollmentScreen::Finish, base::Unretained(this),
221 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED)); 223 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED));
222 } 224 }
223 225
226 void EnrollmentScreen::OnAdJoined(const std::string& realm) {
227 if (!realm.empty()) {
228 config_.management_realm = realm;
229 }
230 UMA(enrollment_failed_once_ ? policy::kMetricEnrollmentRestarted
231 : policy::kMetricEnrollmentStarted);
232
233 actor_->ShowEnrollmentSpinnerScreen();
234 CreateEnrollmentHelper();
235 enrollment_helper_->EnrollUsingAuthCode(
236 auth_code_, shark_controller_ != NULL /* fetch_additional_token */);
237 }
238
224 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { 239 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) {
225 RecordEnrollmentErrorMetrics(); 240 RecordEnrollmentErrorMetrics();
226 actor_->ShowAuthError(error); 241 actor_->ShowAuthError(error);
227 } 242 }
228 243
229 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) { 244 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) {
230 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. 245 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed.
231 LOG(WARNING) << "Enrollment error occured: status=" << status.status() 246 LOG(WARNING) << "Enrollment error occured: status=" << status.status()
232 << " http status=" << status.http_status() 247 << " http status=" << status.http_status()
233 << " DM status=" << status.client_status(); 248 << " DM status=" << status.client_status();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 347 }
333 348
334 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { 349 void EnrollmentScreen::RecordEnrollmentErrorMetrics() {
335 enrollment_failed_once_ = true; 350 enrollment_failed_once_ = true;
336 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? 351 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)?
337 if (elapsed_timer_) 352 if (elapsed_timer_)
338 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); 353 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_);
339 } 354 }
340 355
341 } // namespace chromeos 356 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698