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

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: 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 137 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_ != NULL /* fetch_additional_token */);
achuithb 2017/02/07 20:27:16 nullptr
Roman Sorokin (ftl) 2017/02/10 14:57:10 Done.
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) {
219 if (!realm.empty()) {
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 }
230
231 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { 215 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) {
232 RecordEnrollmentErrorMetrics(); 216 RecordEnrollmentErrorMetrics();
233 actor_->ShowAuthError(error); 217 actor_->ShowAuthError(error);
234 } 218 }
235 219
236 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) { 220 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) {
237 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. 221 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed.
238 LOG(WARNING) << "Enrollment error occured: status=" << status.status() 222 LOG(WARNING) << "Enrollment error occured: status=" << status.status()
239 << " http status=" << status.http_status() 223 << " http status=" << status.http_status()
240 << " DM status=" << status.client_status(); 224 << " DM status=" << status.client_status();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 323 }
340 324
341 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { 325 void EnrollmentScreen::RecordEnrollmentErrorMetrics() {
342 enrollment_failed_once_ = true; 326 enrollment_failed_once_ = true;
343 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? 327 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)?
344 if (elapsed_timer_) 328 if (elapsed_timer_)
345 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); 329 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_);
346 } 330 }
347 331
348 } // namespace chromeos 332 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698