Chromium Code Reviews| 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/metrics/histogram.h" | |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/browser_thread.h" | 11 #include "chrome/browser/browser_thread.h" |
| 11 #include "chrome/browser/chromeos/boot_times_loader.h" | 12 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 12 #include "chrome/browser/chromeos/login/login_utils.h" | 13 #include "chrome/browser/chromeos/login/login_utils.h" |
| 13 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | 14 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| 15 #include "chrome/browser/metrics/user_metrics.h" | |
| 14 #include "chrome/browser/profile.h" | 16 #include "chrome/browser/profile.h" |
| 15 #include "chrome/browser/profile_manager.h" | 17 #include "chrome/browser/profile_manager.h" |
| 16 | 18 |
| 17 namespace chromeos { | 19 namespace chromeos { |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 } // namespace | 22 } // namespace |
| 21 | 23 |
| 22 LoginPerformer::LoginPerformer(Delegate* delegate) | 24 LoginPerformer::LoginPerformer(Delegate* delegate) |
| 23 : last_login_failure_(LoginFailure::None()), | 25 : last_login_failure_(LoginFailure::None()), |
| 24 delegate_(delegate), | 26 delegate_(delegate), |
| 25 method_factory_(this) {} | 27 method_factory_(this) {} |
| 26 | 28 |
| 27 //////////////////////////////////////////////////////////////////////////////// | 29 //////////////////////////////////////////////////////////////////////////////// |
| 28 // LoginPerformer, LoginStatusConsumer implementation: | 30 // LoginPerformer, LoginStatusConsumer implementation: |
| 29 | 31 |
| 30 void LoginPerformer::OnLoginFailure(const LoginFailure& failure) { | 32 void LoginPerformer::OnLoginFailure(const LoginFailure& failure) { |
| 31 last_login_failure_ = failure; | 33 UserMetrics::RecordAction(UserMetricsAction("Login_Failure")); |
| 32 if (delegate_) { | 34 UMA_HISTOGRAM_ENUMERATION("Login.FailureReason", failure.reason(), |
| 33 captcha_.clear(); | 35 LoginFailure::NUM_FAILURE_REASONS); |
| 34 captcha_token_.clear(); | 36 |
| 35 if (failure.reason() == LoginFailure::NETWORK_AUTH_FAILED && | 37 last_login_failure_ = failure; |
| 36 failure.error().state() == GoogleServiceAuthError::CAPTCHA_REQUIRED) { | 38 if (delegate_) { |
| 37 captcha_token_ = failure.error().captcha().token; | 39 captcha_.clear(); |
| 38 } | 40 captcha_token_.clear(); |
| 39 delegate_->OnLoginFailure(failure); | 41 if (failure.reason() == LoginFailure::NETWORK_AUTH_FAILED && |
| 40 } else { | 42 failure.error().state() == GoogleServiceAuthError::CAPTCHA_REQUIRED) { |
| 41 // TODO(nkostylev): Provide blocking UI using ScreenLocker. | 43 captcha_token_ = failure.error().captcha().token; |
| 42 } | 44 } |
| 45 delegate_->OnLoginFailure(failure); | |
| 46 } else { | |
| 47 // TODO(nkostylev): Provide blocking UI using ScreenLocker. | |
| 48 } | |
| 43 } | 49 } |
| 44 | 50 |
| 45 void LoginPerformer::OnLoginSuccess( | 51 void LoginPerformer::OnLoginSuccess( |
| 46 const std::string& username, | 52 const std::string& username, |
| 47 const std::string& password, | 53 const std::string& password, |
| 48 const GaiaAuthConsumer::ClientLoginResult& credentials, | 54 const GaiaAuthConsumer::ClientLoginResult& credentials, |
| 49 bool pending_requests) { | 55 bool pending_requests) { |
| 56 UserMetrics::RecordAction(UserMetricsAction("Login_Success")); | |
| 57 // 0 = login success offline and online. | |
|
Nikita (slow)
2010/12/02 12:27:50
Makes sense.
0 - it does mean that it's a new use
satorux1
2010/12/02 12:49:09
Updated comments accordingly.
| |
| 58 // 1 = login success offline only. | |
| 59 UMA_HISTOGRAM_ENUMERATION("Login.SuccessReason", pending_requests, 2); | |
| 60 | |
| 50 if (delegate_) { | 61 if (delegate_) { |
| 51 delegate_->OnLoginSuccess(username, | 62 delegate_->OnLoginSuccess(username, |
| 52 password, | 63 password, |
| 53 credentials, | 64 credentials, |
| 54 pending_requests); | 65 pending_requests); |
| 55 if (!pending_requests) | 66 if (!pending_requests) |
| 56 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 67 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 57 } else { | 68 } else { |
| 58 DCHECK(!pending_requests); | 69 DCHECK(!pending_requests); |
| 59 // Online login has succeeded. Delete our instance. | 70 // Online login has succeeded. Delete our instance. |
| 60 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 71 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 61 } | 72 } |
| 62 } | 73 } |
| 63 | 74 |
| 64 void LoginPerformer::OnOffTheRecordLoginSuccess() { | 75 void LoginPerformer::OnOffTheRecordLoginSuccess() { |
| 76 UserMetrics::RecordAction( | |
| 77 UserMetricsAction("Login_OffTheRecordLoginSuccess")); | |
|
Nikita (slow)
2010/12/02 12:26:35
nit: Login_GuestLoginSuccess
satorux1
2010/12/02 12:49:09
Done.
satorux1
2010/12/02 12:49:09
Done.
| |
| 78 | |
| 65 if (delegate_) | 79 if (delegate_) |
| 66 delegate_->OnOffTheRecordLoginSuccess(); | 80 delegate_->OnOffTheRecordLoginSuccess(); |
| 67 else | 81 else |
| 68 NOTREACHED(); | 82 NOTREACHED(); |
| 69 } | 83 } |
| 70 | 84 |
| 71 void LoginPerformer::OnPasswordChangeDetected( | 85 void LoginPerformer::OnPasswordChangeDetected( |
| 72 const GaiaAuthConsumer::ClientLoginResult& credentials) { | 86 const GaiaAuthConsumer::ClientLoginResult& credentials) { |
| 73 cached_credentials_ = credentials; | 87 cached_credentials_ = credentials; |
| 74 if (delegate_) { | 88 if (delegate_) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 &Authenticator::AuthenticateToLogin, | 177 &Authenticator::AuthenticateToLogin, |
| 164 profile, | 178 profile, |
| 165 username_, | 179 username_, |
| 166 password_, | 180 password_, |
| 167 captcha_token_, | 181 captcha_token_, |
| 168 captcha_)); | 182 captcha_)); |
| 169 password_.clear(); | 183 password_.clear(); |
| 170 } | 184 } |
| 171 | 185 |
| 172 } // namespace chromeos | 186 } // namespace chromeos |
| OLD | NEW |