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

Side by Side Diff: chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock.cc

Issue 2715823004: Add FingerprintUnlock KeyedService for each profile (Closed)
Patch Set: Created 3 years, 9 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock.h"
6
7 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
8 #include "chrome/common/pref_names.h"
9 #include "components/prefs/pref_service.h"
10
11 namespace chromeos {
12 namespace quick_unlock {
13
14 FingerprintUnlock::FingerprintUnlock(PrefService* pref_service)
15 : pref_service_(pref_service) {}
16
17 FingerprintUnlock::~FingerprintUnlock() {}
18
19 void FingerprintUnlock::MarkStrongAuth() {
20 last_strong_auth_ = base::Time::Now();
21 ResetUnlockAttemptCount();
22 }
23
24 bool FingerprintUnlock::HasStrongAuth() const {
25 if (last_strong_auth_.is_null())
26 return false;
27
28 // 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.
29 PasswordConfirmationFrequency strong_auth_interval =
30 static_cast<PasswordConfirmationFrequency>(
31 pref_service_->GetInteger(prefs::kQuickUnlockTimeout));
32 base::TimeDelta strong_auth_timeout =
33 PasswordConfirmationFrequencyToTimeDelta(strong_auth_interval);
34
35 return TimeSinceLastStrongAuth() < strong_auth_timeout;
36 }
37
38 bool FingerprintUnlock::HasEnrollment() const {
39 return has_enrollments_;
40 }
41
42 base::TimeDelta FingerprintUnlock::TimeSinceLastStrongAuth() const {
43 DCHECK(!last_strong_auth_.is_null());
44 return base::Time::Now() - last_strong_auth_;
45 }
46
47 void FingerprintUnlock::AddUnlockAttempt() {
48 ++unlock_attempt_count_;
49 }
50
51 void FingerprintUnlock::ResetUnlockAttemptCount() {
52 unlock_attempt_count_ = 0;
53 }
54
55 bool FingerprintUnlock::IsFingerprintAuthenticationAvailable() const {
56 const bool exceeded_unlock_attempts =
57 unlock_attempt_count() >= kMaximumUnlockAttempts;
58
59 return IsFingerprintEnabled() && HasEnrollment() && HasStrongAuth() &&
60 !exceeded_unlock_attempts;
61 }
62
63 } // namespace quick_unlock
64 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698