OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/login_performer.h" | 5 #include "chrome/browser/chromeos/login/login_performer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
11 #include "chrome/browser/chromeos/boot_times_loader.h" | 11 #include "chrome/browser/chromeos/boot_times_loader.h" |
12 #include "chrome/browser/chromeos/login/login_utils.h" | 12 #include "chrome/browser/chromeos/login/login_utils.h" |
13 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | 13 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
14 #include "chrome/browser/metrics/user_metrics.h" | |
14 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
15 #include "chrome/browser/profile_manager.h" | 16 #include "chrome/browser/profile_manager.h" |
16 | 17 |
17 namespace chromeos { | 18 namespace chromeos { |
18 | 19 |
19 namespace { | 20 namespace { |
21 | |
22 // Records the login failure with the error code as user metrics. This | |
23 // function is verbose, but we need to enumerate all actions as described | |
24 // in user_metrics.h. Another option is to add some code in | |
25 // extract_actions.py, which is no better than this. | |
26 void RecordLoginFailure(const chromeos::LoginFailure& failure) { | |
27 switch (failure.reason()) { | |
28 case chromeos::LoginFailure::NONE: | |
29 UserMetrics::RecordAction( | |
Nikita (slow)
2010/12/02 10:45:12
I think what you need here instead is
UMA_HISTOGR
satorux1
2010/12/02 10:52:18
My understanding is that histogram is used for col
Nikita (slow)
2010/12/02 11:38:22
Having Login status error/success codes reported a
| |
30 UserMetricsAction("Login_Failure_NONE")); | |
31 break; | |
32 case chromeos::LoginFailure::COULD_NOT_MOUNT_CRYPTOHOME: | |
33 UserMetrics::RecordAction( | |
34 UserMetricsAction("Login_Failure_COULD_NOT_MOUNT_CRYPTOHOME")); | |
35 break; | |
36 case chromeos::LoginFailure::COULD_NOT_MOUNT_TMPFS: | |
37 UserMetrics::RecordAction( | |
38 UserMetricsAction("Login_Failure_COULD_NOT_MOUNT_TMPFS")); | |
39 break; | |
40 case chromeos::LoginFailure::COULD_NOT_UNMOUNT_CRYPTOHOME: | |
41 UserMetrics::RecordAction( | |
42 UserMetricsAction("Login_Failure_COULD_NOT_UNMOUNT_CRYPTOHOME")); | |
43 break; | |
44 case chromeos::LoginFailure::DATA_REMOVAL_FAILED: | |
45 UserMetrics::RecordAction( | |
46 UserMetricsAction("Login_Failure_DATA_REMOVAL_FAILED")); | |
47 break; | |
48 case chromeos::LoginFailure::LOGIN_TIMED_OUT: | |
49 UserMetrics::RecordAction( | |
50 UserMetricsAction("Login_Failure_LOGIN_TIMED_OUT")); | |
51 break; | |
52 case chromeos::LoginFailure::UNLOCK_FAILED: | |
53 UserMetrics::RecordAction( | |
54 UserMetricsAction("Login_Failure_UNLOCK_FAILED")); | |
55 break; | |
56 case chromeos::LoginFailure::NETWORK_AUTH_FAILED: | |
57 UserMetrics::RecordAction( | |
58 UserMetricsAction("Login_Failure_NETWORK_AUTH_FAILED")); | |
59 break; | |
60 default: | |
61 UserMetrics::RecordAction( | |
62 UserMetricsAction("Login_Failure_UNKNOWN")); | |
63 break; | |
64 } | |
65 } | |
66 | |
20 } // namespace | 67 } // namespace |
21 | 68 |
22 LoginPerformer::LoginPerformer(Delegate* delegate) | 69 LoginPerformer::LoginPerformer(Delegate* delegate) |
23 : last_login_failure_(LoginFailure::None()), | 70 : last_login_failure_(LoginFailure::None()), |
24 delegate_(delegate), | 71 delegate_(delegate), |
25 method_factory_(this) {} | 72 method_factory_(this) {} |
26 | 73 |
27 //////////////////////////////////////////////////////////////////////////////// | 74 //////////////////////////////////////////////////////////////////////////////// |
28 // LoginPerformer, LoginStatusConsumer implementation: | 75 // LoginPerformer, LoginStatusConsumer implementation: |
29 | 76 |
30 void LoginPerformer::OnLoginFailure(const LoginFailure& failure) { | 77 void LoginPerformer::OnLoginFailure(const LoginFailure& failure) { |
31 last_login_failure_ = failure; | 78 RecordLoginFailure(failure); |
32 if (delegate_) { | 79 |
33 captcha_.clear(); | 80 last_login_failure_ = failure; |
34 captcha_token_.clear(); | 81 if (delegate_) { |
35 if (failure.reason() == LoginFailure::NETWORK_AUTH_FAILED && | 82 captcha_.clear(); |
36 failure.error().state() == GoogleServiceAuthError::CAPTCHA_REQUIRED) { | 83 captcha_token_.clear(); |
37 captcha_token_ = failure.error().captcha().token; | 84 if (failure.reason() == LoginFailure::NETWORK_AUTH_FAILED && |
38 } | 85 failure.error().state() == GoogleServiceAuthError::CAPTCHA_REQUIRED) { |
39 delegate_->OnLoginFailure(failure); | 86 captcha_token_ = failure.error().captcha().token; |
40 } else { | 87 } |
41 // TODO(nkostylev): Provide blocking UI using ScreenLocker. | 88 delegate_->OnLoginFailure(failure); |
42 } | 89 } else { |
90 // TODO(nkostylev): Provide blocking UI using ScreenLocker. | |
91 } | |
43 } | 92 } |
44 | 93 |
45 void LoginPerformer::OnLoginSuccess( | 94 void LoginPerformer::OnLoginSuccess( |
46 const std::string& username, | 95 const std::string& username, |
47 const std::string& password, | 96 const std::string& password, |
48 const GaiaAuthConsumer::ClientLoginResult& credentials, | 97 const GaiaAuthConsumer::ClientLoginResult& credentials, |
49 bool pending_requests) { | 98 bool pending_requests) { |
99 if (pending_requests) { | |
100 UserMetrics::RecordAction( | |
101 UserMetricsAction("Login_Success_OfflineOnly")); | |
102 } else { | |
103 UserMetrics::RecordAction( | |
104 UserMetricsAction("Login_Success_OfflineAndOnline")); | |
105 } | |
106 | |
50 if (delegate_) { | 107 if (delegate_) { |
51 delegate_->OnLoginSuccess(username, | 108 delegate_->OnLoginSuccess(username, |
52 password, | 109 password, |
53 credentials, | 110 credentials, |
54 pending_requests); | 111 pending_requests); |
55 if (!pending_requests) | 112 if (!pending_requests) |
56 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 113 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
57 } else { | 114 } else { |
58 DCHECK(!pending_requests); | 115 DCHECK(!pending_requests); |
59 // Online login has succeeded. Delete our instance. | 116 // Online login has succeeded. Delete our instance. |
60 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 117 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
61 } | 118 } |
62 } | 119 } |
63 | 120 |
64 void LoginPerformer::OnOffTheRecordLoginSuccess() { | 121 void LoginPerformer::OnOffTheRecordLoginSuccess() { |
122 UserMetrics::RecordAction( | |
123 UserMetricsAction("Login_OffTheRecordLoginSuccess")); | |
124 | |
65 if (delegate_) | 125 if (delegate_) |
66 delegate_->OnOffTheRecordLoginSuccess(); | 126 delegate_->OnOffTheRecordLoginSuccess(); |
67 else | 127 else |
68 NOTREACHED(); | 128 NOTREACHED(); |
69 } | 129 } |
70 | 130 |
71 void LoginPerformer::OnPasswordChangeDetected( | 131 void LoginPerformer::OnPasswordChangeDetected( |
72 const GaiaAuthConsumer::ClientLoginResult& credentials) { | 132 const GaiaAuthConsumer::ClientLoginResult& credentials) { |
73 cached_credentials_ = credentials; | 133 cached_credentials_ = credentials; |
74 if (delegate_) { | 134 if (delegate_) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 &Authenticator::AuthenticateToLogin, | 223 &Authenticator::AuthenticateToLogin, |
164 profile, | 224 profile, |
165 username_, | 225 username_, |
166 password_, | 226 password_, |
167 captcha_token_, | 227 captcha_token_, |
168 captcha_)); | 228 captcha_)); |
169 password_.clear(); | 229 password_.clear(); |
170 } | 230 } |
171 | 231 |
172 } // namespace chromeos | 232 } // namespace chromeos |
OLD | NEW |