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

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

Issue 385983007: Enrollment recovery: Add UMA stats. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cosmetics. Created 6 years, 5 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"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chromeos/login/login_utils.h" 13 #include "chrome/browser/chromeos/login/login_utils.h"
14 #include "chrome/browser/chromeos/login/screens/screen_observer.h" 14 #include "chrome/browser/chromeos/login/screens/screen_observer.h"
15 #include "chrome/browser/chromeos/login/startup_utils.h" 15 #include "chrome/browser/chromeos/login/startup_utils.h"
16 #include "chrome/browser/chromeos/login/wizard_controller.h" 16 #include "chrome/browser/chromeos/login/wizard_controller.h"
17 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h" 17 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
19 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" 19 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h"
20 #include "chromeos/dbus/cryptohome_client.h" 20 #include "chromeos/dbus/cryptohome_client.h"
21 #include "chromeos/dbus/dbus_method_call_status.h" 21 #include "chromeos/dbus/dbus_method_call_status.h"
22 #include "chromeos/dbus/dbus_thread_manager.h" 22 #include "chromeos/dbus/dbus_thread_manager.h"
23 #include "chromeos/dbus/session_manager_client.h" 23 #include "chromeos/dbus/session_manager_client.h"
24 #include "components/policy/core/common/cloud/enterprise_metrics.h"
25 #include "google_apis/gaia/gaia_auth_util.h" 24 #include "google_apis/gaia/gaia_auth_util.h"
26 #include "google_apis/gaia/google_service_auth_error.h" 25 #include "google_apis/gaia/google_service_auth_error.h"
27 26
28 namespace chromeos { 27 namespace chromeos {
29 28
30 namespace {
31
32 void UMA(int sample) {
33 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment,
34 sample,
35 policy::kMetricEnrollmentSize);
36 }
37
38 } // namespace
39
40 EnrollmentScreen::EnrollmentScreen( 29 EnrollmentScreen::EnrollmentScreen(
41 ScreenObserver* observer, 30 ScreenObserver* observer,
42 EnrollmentScreenActor* actor) 31 EnrollmentScreenActor* actor)
43 : WizardScreen(observer), 32 : WizardScreen(observer),
44 actor_(actor), 33 actor_(actor),
45 enrollment_mode_(EnrollmentScreenActor::ENROLLMENT_MODE_MANUAL), 34 enrollment_mode_(EnrollmentScreenActor::ENROLLMENT_MODE_MANUAL),
46 enrollment_failed_once_(false), 35 enrollment_failed_once_(false),
47 lockbox_init_duration_(0), 36 lockbox_init_duration_(0),
48 weak_ptr_factory_(this) { 37 weak_ptr_factory_(this) {
49 // Init the TPM if it has not been done until now (in debug build we might 38 // Init the TPM if it has not been done until now (in debug build we might
(...skipping 12 matching lines...) Expand all
62 user_ = user.empty() ? user : gaia::CanonicalizeEmail(user); 51 user_ = user.empty() ? user : gaia::CanonicalizeEmail(user);
63 actor_->SetParameters(this, enrollment_mode_, management_domain); 52 actor_->SetParameters(this, enrollment_mode_, management_domain);
64 } 53 }
65 54
66 void EnrollmentScreen::PrepareToShow() { 55 void EnrollmentScreen::PrepareToShow() {
67 actor_->PrepareToShow(); 56 actor_->PrepareToShow();
68 } 57 }
69 58
70 void EnrollmentScreen::Show() { 59 void EnrollmentScreen::Show() {
71 if (is_auto_enrollment() && !enrollment_failed_once_) { 60 if (is_auto_enrollment() && !enrollment_failed_once_) {
72 actor_->Show(); 61 actor_->Show();
Joao da Silva 2014/07/14 10:15:50 Nothing is sampled in this case?
Thiemo Nagel 2014/07/14 11:04:30 This code path is just for auto-enrollment which I
73 UMA(policy::kMetricEnrollmentAutoStarted); 62 UMA(policy::kMetricEnrollmentAutoStarted);
74 actor_->ShowEnrollmentSpinnerScreen(); 63 actor_->ShowEnrollmentSpinnerScreen();
75 actor_->FetchOAuthToken(); 64 actor_->FetchOAuthToken();
76 } else { 65 } else {
66 UMA(policy::kMetricEnrollmentTriggered);
77 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen, 67 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen,
78 weak_ptr_factory_.GetWeakPtr())); 68 weak_ptr_factory_.GetWeakPtr()));
79 } 69 }
80 } 70 }
81 71
82 void EnrollmentScreen::Hide() { 72 void EnrollmentScreen::Hide() {
83 actor_->Hide(); 73 actor_->Hide();
84 weak_ptr_factory_.InvalidateWeakPtrs(); 74 weak_ptr_factory_.InvalidateWeakPtrs();
85 } 75 }
86 76
87 std::string EnrollmentScreen::GetName() const { 77 std::string EnrollmentScreen::GetName() const {
88 return WizardController::kEnrollmentScreenName; 78 return WizardController::kEnrollmentScreenName;
89 } 79 }
90 80
91 void EnrollmentScreen::OnLoginDone(const std::string& user) { 81 void EnrollmentScreen::OnLoginDone(const std::string& user) {
92 user_ = gaia::CanonicalizeEmail(user); 82 user_ = gaia::CanonicalizeEmail(user);
93 83
94 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoRetried 84 if (is_auto_enrollment())
95 : policy::kMetricEnrollmentStarted); 85 UMA(policy::kMetricEnrollmentAutoRetried);
86 else if (enrollment_failed_once_)
87 UMA(policy::kMetricEnrollmentRetried);
88 else
89 UMA(policy::kMetricEnrollmentStarted);
96 90
97 actor_->ShowEnrollmentSpinnerScreen(); 91 actor_->ShowEnrollmentSpinnerScreen();
98 actor_->FetchOAuthToken(); 92 actor_->FetchOAuthToken();
99 } 93 }
100 94
101 void EnrollmentScreen::OnAuthError( 95 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) {
102 const GoogleServiceAuthError& error) {
103 enrollment_failed_once_ = true; 96 enrollment_failed_once_ = true;
104 actor_->ShowAuthError(error); 97 actor_->ShowAuthError(error);
105 98
106 switch (error.state()) { 99 switch (error.state()) {
107 case GoogleServiceAuthError::NONE: 100 case GoogleServiceAuthError::NONE:
108 case GoogleServiceAuthError::CAPTCHA_REQUIRED: 101 case GoogleServiceAuthError::CAPTCHA_REQUIRED:
109 case GoogleServiceAuthError::TWO_FACTOR: 102 case GoogleServiceAuthError::TWO_FACTOR:
110 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED: 103 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED:
111 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: 104 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
112 case GoogleServiceAuthError::REQUEST_CANCELED: 105 case GoogleServiceAuthError::REQUEST_CANCELED:
(...skipping 25 matching lines...) Expand all
138 const std::string& token) { 131 const std::string& token) {
139 RegisterForDevicePolicy(token); 132 RegisterForDevicePolicy(token);
140 } 133 }
141 134
142 void EnrollmentScreen::OnRetry() { 135 void EnrollmentScreen::OnRetry() {
143 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen, 136 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen,
144 weak_ptr_factory_.GetWeakPtr())); 137 weak_ptr_factory_.GetWeakPtr()));
145 } 138 }
146 139
147 void EnrollmentScreen::OnCancel() { 140 void EnrollmentScreen::OnCancel() {
148 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_FORCED) { 141 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_FORCED ||
142 enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_RECOVERY) {
pastarmovj 2014/07/14 08:46:06 Is this change part of simply adding the UMAs? It
Thiemo Nagel 2014/07/14 10:30:35 This CL introduces ENROLLMENT_MODE_RECOVERY which
149 actor_->ResetAuth( 143 actor_->ResetAuth(
150 base::Bind(&ScreenObserver::OnExit, 144 base::Bind(&ScreenObserver::OnExit,
151 base::Unretained(get_screen_observer()), 145 base::Unretained(get_screen_observer()),
152 ScreenObserver::ENTERPRISE_ENROLLMENT_BACK)); 146 ScreenObserver::ENTERPRISE_ENROLLMENT_BACK));
153 return; 147 return;
154 } 148 }
155 149
156 if (is_auto_enrollment()) 150 if (is_auto_enrollment())
157 policy::AutoEnrollmentClient::CancelAutoEnrollment(); 151 policy::AutoEnrollmentClient::CancelAutoEnrollment();
158 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoCancelled 152 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoCancelled
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 return; 295 return;
302 case policy::EnrollmentStatus::STATUS_SUCCESS: 296 case policy::EnrollmentStatus::STATUS_SUCCESS:
303 NOTREACHED(); 297 NOTREACHED();
304 return; 298 return;
305 } 299 }
306 300
307 NOTREACHED(); 301 NOTREACHED();
308 UMAFailure(policy::kMetricEnrollmentOtherFailed); 302 UMAFailure(policy::kMetricEnrollmentOtherFailed);
309 } 303 }
310 304
311 void EnrollmentScreen::UMAFailure(int sample) { 305 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) {
306 const char* histogram;
307 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_RECOVERY)
308 histogram = policy::kMetricEnrollmentRecovery;
309 else
310 histogram = policy::kMetricEnrollment;
311 UMA_HISTOGRAM_ENUMERATION(histogram, sample,
312 policy::kMetricEnrollmentSize);
313 }
314
315 void EnrollmentScreen::UMAFailure(policy::MetricEnrollment sample) {
312 if (is_auto_enrollment()) 316 if (is_auto_enrollment())
pastarmovj 2014/07/14 08:46:06 Since auto enrollment is going away anyway can you
Thiemo Nagel 2014/07/14 10:30:35 I fully agree, but I'd rather do that in a separat
313 sample = policy::kMetricEnrollmentAutoFailed; 317 sample = policy::kMetricEnrollmentAutoFailed;
314 UMA(sample); 318 UMA(sample);
315 } 319 }
316 320
317 void EnrollmentScreen::ShowSigninScreen() { 321 void EnrollmentScreen::ShowSigninScreen() {
318 actor_->Show(); 322 actor_->Show();
319 actor_->ShowSigninScreen(); 323 actor_->ShowSigninScreen();
320 } 324 }
321 325
322 } // namespace chromeos 326 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698