| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/boot_times_loader.h" | 16 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 17 #include "chrome/browser/chromeos/cros_settings.h" | 17 #include "chrome/browser/chromeos/cros_settings.h" |
| 18 #include "chrome/browser/chromeos/cros_settings_names.h" | 18 #include "chrome/browser/chromeos/cros_settings_names.h" |
| 19 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 19 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| 20 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 20 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
| 21 #include "chrome/browser/chromeos/login/login_utils.h" | 21 #include "chrome/browser/chromeos/login/login_utils.h" |
| 22 #include "chrome/browser/chromeos/login/screen_locker.h" | 22 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 23 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "content/browser/user_metrics.h" | |
| 30 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 31 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/notification_types.h" | 31 #include "content/public/browser/notification_types.h" |
| 32 #include "content/public/browser/user_metrics.h" |
| 33 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 34 #include "net/base/cookie_monster.h" | 34 #include "net/base/cookie_monster.h" |
| 35 #include "net/base/cookie_store.h" | 35 #include "net/base/cookie_store.h" |
| 36 #include "net/url_request/url_request_context.h" | 36 #include "net/url_request/url_request_context.h" |
| 37 #include "net/url_request/url_request_context_getter.h" | 37 #include "net/url_request/url_request_context_getter.h" |
| 38 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 39 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
| 40 | 40 |
| 41 using content::BrowserThread; | 41 using content::BrowserThread; |
| 42 using content::UserMetricsAction; |
| 42 | 43 |
| 43 namespace chromeos { | 44 namespace chromeos { |
| 44 | 45 |
| 45 // Initialize default LoginPerformer. | 46 // Initialize default LoginPerformer. |
| 46 // static | 47 // static |
| 47 LoginPerformer* LoginPerformer::default_performer_ = NULL; | 48 LoginPerformer* LoginPerformer::default_performer_ = NULL; |
| 48 | 49 |
| 49 LoginPerformer::LoginPerformer(Delegate* delegate) | 50 LoginPerformer::LoginPerformer(Delegate* delegate) |
| 50 : last_login_failure_(LoginFailure::None()), | 51 : last_login_failure_(LoginFailure::None()), |
| 51 delegate_(delegate), | 52 delegate_(delegate), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 65 LoginPerformer::~LoginPerformer() { | 66 LoginPerformer::~LoginPerformer() { |
| 66 DVLOG(1) << "Deleting LoginPerformer"; | 67 DVLOG(1) << "Deleting LoginPerformer"; |
| 67 DCHECK(default_performer_ != NULL) << "Default instance should exist."; | 68 DCHECK(default_performer_ != NULL) << "Default instance should exist."; |
| 68 default_performer_ = NULL; | 69 default_performer_ = NULL; |
| 69 } | 70 } |
| 70 | 71 |
| 71 //////////////////////////////////////////////////////////////////////////////// | 72 //////////////////////////////////////////////////////////////////////////////// |
| 72 // LoginPerformer, LoginStatusConsumer implementation: | 73 // LoginPerformer, LoginStatusConsumer implementation: |
| 73 | 74 |
| 74 void LoginPerformer::OnLoginFailure(const LoginFailure& failure) { | 75 void LoginPerformer::OnLoginFailure(const LoginFailure& failure) { |
| 75 UserMetrics::RecordAction(UserMetricsAction("Login_Failure")); | 76 content::RecordAction(UserMetricsAction("Login_Failure")); |
| 76 UMA_HISTOGRAM_ENUMERATION("Login.FailureReason", failure.reason(), | 77 UMA_HISTOGRAM_ENUMERATION("Login.FailureReason", failure.reason(), |
| 77 LoginFailure::NUM_FAILURE_REASONS); | 78 LoginFailure::NUM_FAILURE_REASONS); |
| 78 | 79 |
| 79 DVLOG(1) << "failure.reason " << failure.reason(); | 80 DVLOG(1) << "failure.reason " << failure.reason(); |
| 80 DVLOG(1) << "failure.error.state " << failure.error().state(); | 81 DVLOG(1) << "failure.error.state " << failure.error().state(); |
| 81 | 82 |
| 82 last_login_failure_ = failure; | 83 last_login_failure_ = failure; |
| 83 if (delegate_) { | 84 if (delegate_) { |
| 84 captcha_.clear(); | 85 captcha_.clear(); |
| 85 captcha_token_.clear(); | 86 captcha_token_.clear(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 NOTREACHED(); | 120 NOTREACHED(); |
| 120 } | 121 } |
| 121 } | 122 } |
| 122 | 123 |
| 123 void LoginPerformer::OnLoginSuccess( | 124 void LoginPerformer::OnLoginSuccess( |
| 124 const std::string& username, | 125 const std::string& username, |
| 125 const std::string& password, | 126 const std::string& password, |
| 126 const GaiaAuthConsumer::ClientLoginResult& credentials, | 127 const GaiaAuthConsumer::ClientLoginResult& credentials, |
| 127 bool pending_requests, | 128 bool pending_requests, |
| 128 bool using_oauth) { | 129 bool using_oauth) { |
| 129 UserMetrics::RecordAction(UserMetricsAction("Login_Success")); | 130 content::RecordAction(UserMetricsAction("Login_Success")); |
| 130 // 0 - Login success offline and online. It's a new user. or it's an | 131 // 0 - Login success offline and online. It's a new user. or it's an |
| 131 // existing user and offline auth took longer than online auth. | 132 // existing user and offline auth took longer than online auth. |
| 132 // 1 - Login success offline only. It's an existing user login. | 133 // 1 - Login success offline only. It's an existing user login. |
| 133 UMA_HISTOGRAM_ENUMERATION("Login.SuccessReason", pending_requests, 2); | 134 UMA_HISTOGRAM_ENUMERATION("Login.SuccessReason", pending_requests, 2); |
| 134 | 135 |
| 135 VLOG(1) << "LoginSuccess, pending_requests " << pending_requests; | 136 VLOG(1) << "LoginSuccess, pending_requests " << pending_requests; |
| 136 if (delegate_) { | 137 if (delegate_) { |
| 137 // After delegate_->OnLoginSuccess(...) is called, delegate_ releases | 138 // After delegate_->OnLoginSuccess(...) is called, delegate_ releases |
| 138 // LoginPerformer ownership. LP now manages it's lifetime on its own. | 139 // LoginPerformer ownership. LP now manages it's lifetime on its own. |
| 139 // 2 things could make it exist longer: | 140 // 2 things could make it exist longer: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 // See ResolveScreenUnlocked(). | 195 // See ResolveScreenUnlocked(). |
| 195 return; | 196 return; |
| 196 } | 197 } |
| 197 initial_online_auth_pending_ = false; | 198 initial_online_auth_pending_ = false; |
| 198 // There's nothing else that's holding LP from deleting itself - | 199 // There's nothing else that's holding LP from deleting itself - |
| 199 // no ScreenLock, no pending requests. | 200 // no ScreenLock, no pending requests. |
| 200 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 201 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 201 } | 202 } |
| 202 | 203 |
| 203 void LoginPerformer::OnOffTheRecordLoginSuccess() { | 204 void LoginPerformer::OnOffTheRecordLoginSuccess() { |
| 204 UserMetrics::RecordAction( | 205 content::RecordAction( |
| 205 UserMetricsAction("Login_GuestLoginSuccess")); | 206 UserMetricsAction("Login_GuestLoginSuccess")); |
| 206 | 207 |
| 207 if (delegate_) | 208 if (delegate_) |
| 208 delegate_->OnOffTheRecordLoginSuccess(); | 209 delegate_->OnOffTheRecordLoginSuccess(); |
| 209 else | 210 else |
| 210 NOTREACHED(); | 211 NOTREACHED(); |
| 211 } | 212 } |
| 212 | 213 |
| 213 void LoginPerformer::OnPasswordChangeDetected( | 214 void LoginPerformer::OnPasswordChangeDetected( |
| 214 const GaiaAuthConsumer::ClientLoginResult& credentials) { | 215 const GaiaAuthConsumer::ClientLoginResult& credentials) { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 profile, | 551 profile, |
| 551 username_, | 552 username_, |
| 552 password_, | 553 password_, |
| 553 captcha_token_, | 554 captcha_token_, |
| 554 captcha_)); | 555 captcha_)); |
| 555 } | 556 } |
| 556 password_.clear(); | 557 password_.clear(); |
| 557 } | 558 } |
| 558 | 559 |
| 559 } // namespace chromeos | 560 } // namespace chromeos |
| OLD | NEW |