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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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), | 139 locked_(false), |
140 start_time_(base::Time::Now()), | 140 start_time_(base::Time::Now()), |
141 auth_status_consumer_(NULL), | 141 auth_status_consumer_(NULL), |
142 incorrect_passwords_count_(0), | 142 incorrect_passwords_count_(0), |
143 is_pin_attempt_(false), | |
jdufault
2016/08/12 21:57:33
Since you're already modifying this, please move a
sammiequon
2016/08/16 17:29:09
Done.
| |
143 weak_factory_(this) { | 144 weak_factory_(this) { |
144 DCHECK(!screen_locker_); | 145 DCHECK(!screen_locker_); |
145 screen_locker_ = this; | 146 screen_locker_ = this; |
146 | 147 |
147 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 148 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
148 media::SoundsManager* manager = media::SoundsManager::Get(); | 149 media::SoundsManager* manager = media::SoundsManager::Get(); |
149 manager->Initialize(SOUND_LOCK, | 150 manager->Initialize(SOUND_LOCK, |
150 bundle.GetRawDataResource(IDR_SOUND_LOCK_WAV)); | 151 bundle.GetRawDataResource(IDR_SOUND_LOCK_WAV)); |
151 manager->Initialize(SOUND_UNLOCK, | 152 manager->Initialize(SOUND_UNLOCK, |
152 bundle.GetRawDataResource(IDR_SOUND_UNLOCK_WAV)); | 153 bundle.GetRawDataResource(IDR_SOUND_UNLOCK_WAV)); |
(...skipping 29 matching lines...) Expand all Loading... | |
182 void ScreenLocker::OnAuthFailure(const AuthFailure& error) { | 183 void ScreenLocker::OnAuthFailure(const AuthFailure& error) { |
183 content::RecordAction(UserMetricsAction("ScreenLocker_OnLoginFailure")); | 184 content::RecordAction(UserMetricsAction("ScreenLocker_OnLoginFailure")); |
184 if (authentication_start_time_.is_null()) { | 185 if (authentication_start_time_.is_null()) { |
185 LOG(ERROR) << "Start time is not set at authentication failure"; | 186 LOG(ERROR) << "Start time is not set at authentication failure"; |
186 } else { | 187 } else { |
187 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; | 188 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; |
188 VLOG(1) << "Authentication failure: " << delta.InSecondsF() << " second(s)"; | 189 VLOG(1) << "Authentication failure: " << delta.InSecondsF() << " second(s)"; |
189 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationFailureTime", delta); | 190 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationFailureTime", delta); |
190 } | 191 } |
191 | 192 |
193 if (is_pin_attempt_) { | |
194 UMA_HISTOGRAM_ENUMERATION("ScreenLocker.AuthenticationFailure", | |
195 UnlockFailure::AUTH_FAILURE_PIN, | |
jdufault
2016/08/12 21:57:33
Can we replace this with
UMA(..., is_pin_attempt_
sammiequon
2016/08/16 17:29:09
Done.
| |
196 UnlockFailure::AUTH_FAILURE_COUNT); | |
197 } else { | |
198 UMA_HISTOGRAM_ENUMERATION("ScreenLocker.AuthenticationFailure", | |
199 UnlockFailure::AUTH_FAILURE_PASSWORD, | |
200 UnlockFailure::AUTH_FAILURE_COUNT); | |
201 } | |
202 | |
192 EnableInput(); | 203 EnableInput(); |
193 // Don't enable signout button here as we're showing | 204 // Don't enable signout button here as we're showing |
194 // MessageBubble. | 205 // MessageBubble. |
195 | 206 |
196 delegate_->ShowErrorMessage(incorrect_passwords_count_++ ? | 207 delegate_->ShowErrorMessage(incorrect_passwords_count_++ ? |
197 IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME : | 208 IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME : |
198 IDS_LOGIN_ERROR_AUTHENTICATING, | 209 IDS_LOGIN_ERROR_AUTHENTICATING, |
199 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 210 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
200 | 211 |
201 if (auth_status_consumer_) | 212 if (auth_status_consumer_) |
202 auth_status_consumer_->OnAuthFailure(error); | 213 auth_status_consumer_->OnAuthFailure(error); |
203 } | 214 } |
204 | 215 |
205 void ScreenLocker::OnAuthSuccess(const UserContext& user_context) { | 216 void ScreenLocker::OnAuthSuccess(const UserContext& user_context) { |
206 incorrect_passwords_count_ = 0; | 217 incorrect_passwords_count_ = 0; |
207 if (authentication_start_time_.is_null()) { | 218 if (authentication_start_time_.is_null()) { |
208 if (user_context.GetAccountId().is_valid()) | 219 if (user_context.GetAccountId().is_valid()) |
209 LOG(ERROR) << "Start time is not set at authentication success"; | 220 LOG(ERROR) << "Start time is not set at authentication success"; |
210 } else { | 221 } else { |
211 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; | 222 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; |
212 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)"; | 223 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)"; |
213 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta); | 224 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta); |
214 } | 225 } |
215 | 226 |
227 if (is_pin_attempt_) { | |
228 UMA_HISTOGRAM_ENUMERATION("ScreenLocker.AuthenticationSuccess", | |
229 UnlockSuccess::AUTH_SUCCESS_PIN, | |
230 UnlockSuccess::AUTH_SUCCESS_COUNT); | |
jdufault
2016/08/12 21:57:33
See above UMA comment
sammiequon
2016/08/16 17:29:09
Done.
| |
231 } else { | |
232 UMA_HISTOGRAM_ENUMERATION("ScreenLocker.AuthenticationSuccess", | |
233 UnlockSuccess::AUTH_SUCCESS_PASSWORD, | |
234 UnlockSuccess::AUTH_SUCCESS_COUNT); | |
235 } | |
236 | |
216 const user_manager::User* user = | 237 const user_manager::User* user = |
217 user_manager::UserManager::Get()->FindUser(user_context.GetAccountId()); | 238 user_manager::UserManager::Get()->FindUser(user_context.GetAccountId()); |
218 if (user) { | 239 if (user) { |
219 if (!user->is_active()) { | 240 if (!user->is_active()) { |
220 saved_ime_state_ = NULL; | 241 saved_ime_state_ = NULL; |
221 user_manager::UserManager::Get()->SwitchActiveUser( | 242 user_manager::UserManager::Get()->SwitchActiveUser( |
222 user_context.GetAccountId()); | 243 user_context.GetAccountId()); |
223 } | 244 } |
224 | 245 |
225 // Reset the number of PIN attempts available to the user. We always do this | 246 // 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 Loading... | |
276 chromeos::ScreenLocker::Hide(); | 297 chromeos::ScreenLocker::Hide(); |
277 } | 298 } |
278 | 299 |
279 void ScreenLocker::Authenticate(const UserContext& user_context) { | 300 void ScreenLocker::Authenticate(const UserContext& user_context) { |
280 LOG_ASSERT(IsUserLoggedIn(user_context.GetAccountId())) | 301 LOG_ASSERT(IsUserLoggedIn(user_context.GetAccountId())) |
281 << "Invalid user trying to unlock."; | 302 << "Invalid user trying to unlock."; |
282 | 303 |
283 authentication_start_time_ = base::Time::Now(); | 304 authentication_start_time_ = base::Time::Now(); |
284 delegate_->SetInputEnabled(false); | 305 delegate_->SetInputEnabled(false); |
285 delegate_->OnAuthenticate(); | 306 delegate_->OnAuthenticate(); |
307 is_pin_attempt_ = user_context.IsUsingPin(); | |
286 | 308 |
287 const user_manager::User* user = FindUnlockUser(user_context.GetAccountId()); | 309 const user_manager::User* user = FindUnlockUser(user_context.GetAccountId()); |
288 if (user) { | 310 if (user) { |
289 // Check to see if the user submitted a PIN and it is valid. | 311 // Check to see if the user submitted a PIN and it is valid. |
290 const std::string pin = user_context.GetKey()->GetSecret(); | 312 const std::string pin = user_context.GetKey()->GetSecret(); |
291 | 313 |
292 // We only want to try authenticating the pin if it is a number, | 314 // 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 | 315 // otherwise we will timeout PIN if the user enters their account password |
294 // incorrectly more than a few times. | 316 // incorrectly more than a few times. |
295 int dummy_value; | 317 int dummy_value; |
296 if (base::StringToInt(pin, &dummy_value)) { | 318 if (is_pin_attempt_ && base::StringToInt(pin, &dummy_value)) { |
297 chromeos::PinStorage* pin_storage = | 319 chromeos::PinStorage* pin_storage = |
298 chromeos::PinStorageFactory::GetForUser(user); | 320 chromeos::PinStorageFactory::GetForUser(user); |
299 if (pin_storage && pin_storage->TryAuthenticatePin(pin)) { | 321 if (pin_storage && pin_storage->TryAuthenticatePin(pin)) { |
300 OnAuthSuccess(user_context); | 322 OnAuthSuccess(user_context); |
301 return; | 323 return; |
302 } | 324 } |
303 } | 325 } |
304 | 326 |
305 // Special case: supervised users. Use special authenticator. | 327 // Special case: supervised users. Use special authenticator. |
306 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) { | 328 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 | 561 |
540 bool ScreenLocker::IsUserLoggedIn(const AccountId& account_id) const { | 562 bool ScreenLocker::IsUserLoggedIn(const AccountId& account_id) const { |
541 for (user_manager::User* user : users_) { | 563 for (user_manager::User* user : users_) { |
542 if (user->GetAccountId() == account_id) | 564 if (user->GetAccountId() == account_id) |
543 return true; | 565 return true; |
544 } | 566 } |
545 return false; | 567 return false; |
546 } | 568 } |
547 | 569 |
548 } // namespace chromeos | 570 } // namespace chromeos |
OLD | NEW |