Chromium Code Reviews| Index: chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock.cc |
| diff --git a/chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock.cc b/chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b1f8eec6691958b28706093a51d098ffa153ca9c |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock.cc |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock.h" |
| + |
| +#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h" |
| +#include "chrome/common/pref_names.h" |
| +#include "components/prefs/pref_service.h" |
| + |
| +namespace chromeos { |
| +namespace quick_unlock { |
| + |
| +FingerprintUnlock::FingerprintUnlock(PrefService* pref_service) |
| + : pref_service_(pref_service) {} |
| + |
| +FingerprintUnlock::~FingerprintUnlock() {} |
| + |
| +void FingerprintUnlock::MarkStrongAuth() { |
| + last_strong_auth_ = base::Time::Now(); |
| + ResetUnlockAttemptCount(); |
| +} |
| + |
| +bool FingerprintUnlock::HasStrongAuth() const { |
| + if (last_strong_auth_.is_null()) |
| + return false; |
| + |
| + // Assume the policy for fingerprint is same as pin, will change if different. |
|
jdufault
2017/02/24 23:37:10
What about
// PIN and fingerprint share the sam
xiaoyinh(OOO Sep 11-29)
2017/02/27 21:36:42
Done.
I keep this function in both fingerprint and
jdufault
2017/02/27 21:38:38
Yes, I would merge it into QuickUnlockStorage.
|
| + PasswordConfirmationFrequency strong_auth_interval = |
| + static_cast<PasswordConfirmationFrequency>( |
| + pref_service_->GetInteger(prefs::kQuickUnlockTimeout)); |
| + base::TimeDelta strong_auth_timeout = |
| + PasswordConfirmationFrequencyToTimeDelta(strong_auth_interval); |
| + |
| + return TimeSinceLastStrongAuth() < strong_auth_timeout; |
| +} |
| + |
| +bool FingerprintUnlock::HasEnrollment() const { |
| + return has_enrollments_; |
| +} |
| + |
| +base::TimeDelta FingerprintUnlock::TimeSinceLastStrongAuth() const { |
| + DCHECK(!last_strong_auth_.is_null()); |
| + return base::Time::Now() - last_strong_auth_; |
| +} |
| + |
| +void FingerprintUnlock::AddUnlockAttempt() { |
| + ++unlock_attempt_count_; |
| +} |
| + |
| +void FingerprintUnlock::ResetUnlockAttemptCount() { |
| + unlock_attempt_count_ = 0; |
| +} |
| + |
| +bool FingerprintUnlock::IsFingerprintAuthenticationAvailable() const { |
| + const bool exceeded_unlock_attempts = |
| + unlock_attempt_count() >= kMaximumUnlockAttempts; |
| + |
| + return IsFingerprintEnabled() && HasEnrollment() && HasStrongAuth() && |
| + !exceeded_unlock_attempts; |
| +} |
| + |
| +} // namespace quick_unlock |
| +} // namespace chromeos |