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

Side by Side Diff: chrome/browser/chromeos/login/lock/screen_locker.cc

Issue 2208583006: UMA for pin unlock success/failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fixed patch set 3 errors. Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/lock/screen_locker.h" 5 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/ash_switches.h" 10 #include "ash/common/ash_switches.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } // namespace 129 } // namespace
130 130
131 // static 131 // static
132 ScreenLocker* ScreenLocker::screen_locker_ = NULL; 132 ScreenLocker* ScreenLocker::screen_locker_ = NULL;
133 133
134 ////////////////////////////////////////////////////////////////////////////// 134 //////////////////////////////////////////////////////////////////////////////
135 // ScreenLocker, public: 135 // ScreenLocker, public:
136 136
137 ScreenLocker::ScreenLocker(const user_manager::UserList& users) 137 ScreenLocker::ScreenLocker(const user_manager::UserList& users)
138 : users_(users), 138 : users_(users),
139 locked_(false),
140 start_time_(base::Time::Now()), 139 start_time_(base::Time::Now()),
jdufault 2016/08/16 17:55:02 Move initialization to header
sammiequon 2016/08/16 19:22:11 Done.
141 auth_status_consumer_(NULL), 140 auth_status_consumer_(nullptr),
jdufault 2016/08/16 17:55:02 Move initialization to header
sammiequon 2016/08/16 19:22:11 Done.
142 incorrect_passwords_count_(0),
143 weak_factory_(this) { 141 weak_factory_(this) {
144 DCHECK(!screen_locker_); 142 DCHECK(!screen_locker_);
145 screen_locker_ = this; 143 screen_locker_ = this;
146 144
147 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 145 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
148 media::SoundsManager* manager = media::SoundsManager::Get(); 146 media::SoundsManager* manager = media::SoundsManager::Get();
149 manager->Initialize(SOUND_LOCK, 147 manager->Initialize(SOUND_LOCK,
150 bundle.GetRawDataResource(IDR_SOUND_LOCK_WAV)); 148 bundle.GetRawDataResource(IDR_SOUND_LOCK_WAV));
151 manager->Initialize(SOUND_UNLOCK, 149 manager->Initialize(SOUND_UNLOCK,
152 bundle.GetRawDataResource(IDR_SOUND_UNLOCK_WAV)); 150 bundle.GetRawDataResource(IDR_SOUND_UNLOCK_WAV));
(...skipping 29 matching lines...) Expand all
182 void ScreenLocker::OnAuthFailure(const AuthFailure& error) { 180 void ScreenLocker::OnAuthFailure(const AuthFailure& error) {
183 content::RecordAction(UserMetricsAction("ScreenLocker_OnLoginFailure")); 181 content::RecordAction(UserMetricsAction("ScreenLocker_OnLoginFailure"));
184 if (authentication_start_time_.is_null()) { 182 if (authentication_start_time_.is_null()) {
185 LOG(ERROR) << "Start time is not set at authentication failure"; 183 LOG(ERROR) << "Start time is not set at authentication failure";
186 } else { 184 } else {
187 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; 185 base::TimeDelta delta = base::Time::Now() - authentication_start_time_;
188 VLOG(1) << "Authentication failure: " << delta.InSecondsF() << " second(s)"; 186 VLOG(1) << "Authentication failure: " << delta.InSecondsF() << " second(s)";
189 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationFailureTime", delta); 187 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationFailureTime", delta);
190 } 188 }
191 189
190 UMA_HISTOGRAM_ENUMERATION("ScreenLocker.AuthenticationFailure",
191 is_pin_attempt_
192 ? UnlockFailure::AUTH_FAILURE_PIN
193 : UnlockFailure::AUTH_FAILURE_PASSWORD,
194 UnlockFailure::AUTH_FAILURE_COUNT);
195
192 EnableInput(); 196 EnableInput();
193 // Don't enable signout button here as we're showing 197 // Don't enable signout button here as we're showing
194 // MessageBubble. 198 // MessageBubble.
195 199
196 delegate_->ShowErrorMessage(incorrect_passwords_count_++ ? 200 delegate_->ShowErrorMessage(incorrect_passwords_count_++ ?
197 IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME : 201 IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME :
198 IDS_LOGIN_ERROR_AUTHENTICATING, 202 IDS_LOGIN_ERROR_AUTHENTICATING,
199 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); 203 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
200 204
201 if (auth_status_consumer_) 205 if (auth_status_consumer_)
202 auth_status_consumer_->OnAuthFailure(error); 206 auth_status_consumer_->OnAuthFailure(error);
203 } 207 }
204 208
205 void ScreenLocker::OnAuthSuccess(const UserContext& user_context) { 209 void ScreenLocker::OnAuthSuccess(const UserContext& user_context) {
206 incorrect_passwords_count_ = 0; 210 incorrect_passwords_count_ = 0;
207 if (authentication_start_time_.is_null()) { 211 if (authentication_start_time_.is_null()) {
208 if (user_context.GetAccountId().is_valid()) 212 if (user_context.GetAccountId().is_valid())
209 LOG(ERROR) << "Start time is not set at authentication success"; 213 LOG(ERROR) << "Start time is not set at authentication success";
210 } else { 214 } else {
211 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; 215 base::TimeDelta delta = base::Time::Now() - authentication_start_time_;
212 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)"; 216 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)";
213 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta); 217 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta);
214 } 218 }
215 219
220 UMA_HISTOGRAM_ENUMERATION("ScreenLocker.AuthenticationSuccess",
221 is_pin_attempt_
222 ? UnlockSuccess::AUTH_SUCCESS_PIN
223 : UnlockSuccess::AUTH_SUCCESS_PASSWORD,
224 UnlockSuccess::AUTH_SUCCESS_COUNT);
225
216 const user_manager::User* user = 226 const user_manager::User* user =
217 user_manager::UserManager::Get()->FindUser(user_context.GetAccountId()); 227 user_manager::UserManager::Get()->FindUser(user_context.GetAccountId());
218 if (user) { 228 if (user) {
219 if (!user->is_active()) { 229 if (!user->is_active()) {
220 saved_ime_state_ = NULL; 230 saved_ime_state_ = NULL;
221 user_manager::UserManager::Get()->SwitchActiveUser( 231 user_manager::UserManager::Get()->SwitchActiveUser(
222 user_context.GetAccountId()); 232 user_context.GetAccountId());
223 } 233 }
224 234
225 // Reset the number of PIN attempts available to the user. We always do this 235 // Reset the number of PIN attempts available to the user. We always do this
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 chromeos::ScreenLocker::Hide(); 286 chromeos::ScreenLocker::Hide();
277 } 287 }
278 288
279 void ScreenLocker::Authenticate(const UserContext& user_context) { 289 void ScreenLocker::Authenticate(const UserContext& user_context) {
280 LOG_ASSERT(IsUserLoggedIn(user_context.GetAccountId())) 290 LOG_ASSERT(IsUserLoggedIn(user_context.GetAccountId()))
281 << "Invalid user trying to unlock."; 291 << "Invalid user trying to unlock.";
282 292
283 authentication_start_time_ = base::Time::Now(); 293 authentication_start_time_ = base::Time::Now();
284 delegate_->SetInputEnabled(false); 294 delegate_->SetInputEnabled(false);
285 delegate_->OnAuthenticate(); 295 delegate_->OnAuthenticate();
296 is_pin_attempt_ = user_context.IsUsingPin();
286 297
287 const user_manager::User* user = FindUnlockUser(user_context.GetAccountId()); 298 const user_manager::User* user = FindUnlockUser(user_context.GetAccountId());
288 if (user) { 299 if (user) {
289 // Check to see if the user submitted a PIN and it is valid. 300 // Check to see if the user submitted a PIN and it is valid.
290 const std::string pin = user_context.GetKey()->GetSecret(); 301 const std::string pin = user_context.GetKey()->GetSecret();
291 302
292 // We only want to try authenticating the pin if it is a number, 303 // We only want to try authenticating the pin if it is a number,
293 // otherwise we will timeout PIN if the user enters their account password 304 // otherwise we will timeout PIN if the user enters their account password
294 // incorrectly more than a few times. 305 // incorrectly more than a few times.
295 int dummy_value; 306 int dummy_value;
296 if (base::StringToInt(pin, &dummy_value)) { 307 if (is_pin_attempt_ && base::StringToInt(pin, &dummy_value)) {
297 chromeos::PinStorage* pin_storage = 308 chromeos::PinStorage* pin_storage =
298 chromeos::PinStorageFactory::GetForUser(user); 309 chromeos::PinStorageFactory::GetForUser(user);
299 if (pin_storage && pin_storage->TryAuthenticatePin(pin)) { 310 if (pin_storage && pin_storage->TryAuthenticatePin(pin)) {
300 OnAuthSuccess(user_context); 311 OnAuthSuccess(user_context);
301 return; 312 return;
302 } 313 }
303 } 314 }
304 315
305 // Special case: supervised users. Use special authenticator. 316 // Special case: supervised users. Use special authenticator.
306 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) { 317 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 550
540 bool ScreenLocker::IsUserLoggedIn(const AccountId& account_id) const { 551 bool ScreenLocker::IsUserLoggedIn(const AccountId& account_id) const {
541 for (user_manager::User* user : users_) { 552 for (user_manager::User* user : users_) {
542 if (user->GetAccountId() == account_id) 553 if (user->GetAccountId() == account_id)
543 return true; 554 return true;
544 } 555 }
545 return false; 556 return false;
546 } 557 }
547 558
548 } // namespace chromeos 559 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698