OLD | NEW |
---|---|
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 void ScreenLocker::OnAuthFailure(const AuthFailure& error) { | 182 void ScreenLocker::OnAuthFailure(const AuthFailure& error) { |
183 content::RecordAction(UserMetricsAction("ScreenLocker_OnLoginFailure")); | 183 content::RecordAction(UserMetricsAction("ScreenLocker_OnLoginFailure")); |
184 if (authentication_start_time_.is_null()) { | 184 if (authentication_start_time_.is_null()) { |
185 LOG(ERROR) << "Start time is not set at authentication failure"; | 185 LOG(ERROR) << "Start time is not set at authentication failure"; |
186 } else { | 186 } else { |
187 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; | 187 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; |
188 VLOG(1) << "Authentication failure: " << delta.InSecondsF() << " second(s)"; | 188 VLOG(1) << "Authentication failure: " << delta.InSecondsF() << " second(s)"; |
189 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationFailureTime", delta); | 189 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationFailureTime", delta); |
190 } | 190 } |
191 | 191 |
192 if (error.IsPinAttempt()) { | |
193 UMA_HISTOGRAM_ENUMERATION("ScreenLocker.AuthenticationFailure", | |
194 UnlockFailure::AUTH_FAILURE_PIN, | |
195 UnlockFailure::AUTH_FAILURE_COUNT); | |
196 } else { | |
197 UMA_HISTOGRAM_ENUMERATION("ScreenLocker.AuthenticationFailure", | |
198 UnlockFailure::AUTH_FAILURE_PASSWORD, | |
199 UnlockFailure::AUTH_FAILURE_COUNT); | |
200 } | |
201 | |
192 EnableInput(); | 202 EnableInput(); |
193 // Don't enable signout button here as we're showing | 203 // Don't enable signout button here as we're showing |
194 // MessageBubble. | 204 // MessageBubble. |
195 | 205 |
196 delegate_->ShowErrorMessage(incorrect_passwords_count_++ ? | 206 delegate_->ShowErrorMessage(incorrect_passwords_count_++ ? |
197 IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME : | 207 IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME : |
198 IDS_LOGIN_ERROR_AUTHENTICATING, | 208 IDS_LOGIN_ERROR_AUTHENTICATING, |
199 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 209 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
200 | 210 |
201 if (auth_status_consumer_) | 211 if (auth_status_consumer_) |
202 auth_status_consumer_->OnAuthFailure(error); | 212 auth_status_consumer_->OnAuthFailure(error); |
203 } | 213 } |
204 | 214 |
205 void ScreenLocker::OnAuthSuccess(const UserContext& user_context) { | 215 void ScreenLocker::OnAuthSuccess(const UserContext& user_context) { |
206 incorrect_passwords_count_ = 0; | 216 incorrect_passwords_count_ = 0; |
207 if (authentication_start_time_.is_null()) { | 217 if (authentication_start_time_.is_null()) { |
208 if (user_context.GetAccountId().is_valid()) | 218 if (user_context.GetAccountId().is_valid()) |
209 LOG(ERROR) << "Start time is not set at authentication success"; | 219 LOG(ERROR) << "Start time is not set at authentication success"; |
210 } else { | 220 } else { |
211 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; | 221 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; |
212 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)"; | 222 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)"; |
213 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta); | 223 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta); |
214 } | 224 } |
215 | 225 |
226 if (user_context.IsUsingPin()) { | |
227 UMA_HISTOGRAM_ENUMERATION("ScreenLocker.AuthenticationSuccess", | |
228 int{UnlockSuccess::AUTH_SUCCESS_PIN}, | |
jdufault
2016/08/08 18:54:26
Do you need these casts? You don't have them above
sammiequon
2016/08/09 00:31:25
Done.
| |
229 int{UnlockSuccess::AUTH_SUCCESS_COUNT}); | |
230 } else { | |
231 UMA_HISTOGRAM_ENUMERATION("ScreenLocker.AuthenticationSuccess", | |
232 int{UnlockSuccess::AUTH_SUCCESS_PASSWORD}, | |
233 int{UnlockSuccess::AUTH_SUCCESS_COUNT}); | |
234 } | |
235 | |
216 const user_manager::User* user = | 236 const user_manager::User* user = |
217 user_manager::UserManager::Get()->FindUser(user_context.GetAccountId()); | 237 user_manager::UserManager::Get()->FindUser(user_context.GetAccountId()); |
218 if (user) { | 238 if (user) { |
219 if (!user->is_active()) { | 239 if (!user->is_active()) { |
220 saved_ime_state_ = NULL; | 240 saved_ime_state_ = NULL; |
221 user_manager::UserManager::Get()->SwitchActiveUser( | 241 user_manager::UserManager::Get()->SwitchActiveUser( |
222 user_context.GetAccountId()); | 242 user_context.GetAccountId()); |
223 } | 243 } |
224 | 244 |
225 // Reset the number of PIN attempts available to the user. We always do this | 245 // Reset the number of PIN attempts available to the user. We always do this |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 | 306 |
287 const user_manager::User* user = FindUnlockUser(user_context.GetAccountId()); | 307 const user_manager::User* user = FindUnlockUser(user_context.GetAccountId()); |
288 if (user) { | 308 if (user) { |
289 // Check to see if the user submitted a PIN and it is valid. | 309 // Check to see if the user submitted a PIN and it is valid. |
290 const std::string pin = user_context.GetKey()->GetSecret(); | 310 const std::string pin = user_context.GetKey()->GetSecret(); |
291 | 311 |
292 // We only want to try authenticating the pin if it is a number, | 312 // 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 | 313 // otherwise we will timeout PIN if the user enters their account password |
294 // incorrectly more than a few times. | 314 // incorrectly more than a few times. |
295 int dummy_value; | 315 int dummy_value; |
296 if (base::StringToInt(pin, &dummy_value)) { | 316 if (base::StringToInt(pin, &dummy_value)) { |
jdufault
2016/08/08 18:54:26
Also check if user_context.IsUsingPin() is set to
sammiequon
2016/08/09 00:31:25
Done.
| |
297 chromeos::PinStorage* pin_storage = | 317 chromeos::PinStorage* pin_storage = |
298 chromeos::PinStorageFactory::GetForUser(user); | 318 chromeos::PinStorageFactory::GetForUser(user); |
299 if (pin_storage && pin_storage->TryAuthenticatePin(pin)) { | 319 if (pin_storage && pin_storage->TryAuthenticatePin(pin)) { |
300 OnAuthSuccess(user_context); | 320 OnAuthSuccess(user_context); |
301 return; | 321 return; |
302 } | 322 } |
303 } | 323 } |
304 | 324 |
305 // Special case: supervised users. Use special authenticator. | 325 // Special case: supervised users. Use special authenticator. |
306 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) { | 326 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 | 559 |
540 bool ScreenLocker::IsUserLoggedIn(const AccountId& account_id) const { | 560 bool ScreenLocker::IsUserLoggedIn(const AccountId& account_id) const { |
541 for (user_manager::User* user : users_) { | 561 for (user_manager::User* user : users_) { |
542 if (user->GetAccountId() == account_id) | 562 if (user->GetAccountId() == account_id) |
543 return true; | 563 return true; |
544 } | 564 } |
545 return false; | 565 return false; |
546 } | 566 } |
547 | 567 |
548 } // namespace chromeos | 568 } // namespace chromeos |
OLD | NEW |