OLD | NEW |
(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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_STORAGE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_STORAGE_H_ |
| 7 |
| 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/chromeos/login/quick_unlock/fingerprint_storage.h" |
| 11 #include "chrome/browser/chromeos/login/quick_unlock/pin_storage.h" |
| 12 #include "components/keyed_service/core/keyed_service.h" |
| 13 |
| 14 class PrefService; |
| 15 |
| 16 namespace chromeos { |
| 17 |
| 18 class QuickUnlockStorageTestApi; |
| 19 |
| 20 namespace quick_unlock { |
| 21 |
| 22 class QuickUnlockStorage : public KeyedService { |
| 23 public: |
| 24 explicit QuickUnlockStorage(PrefService* pref_service); |
| 25 ~QuickUnlockStorage() override; |
| 26 |
| 27 // Mark that the user has had a strong authentication. This means |
| 28 // that they authenticated with their password, for example. Quick |
| 29 // unlock will timeout after a delay. |
| 30 void MarkStrongAuth(); |
| 31 |
| 32 // Returns true if the user has been strongly authenticated. |
| 33 bool HasStrongAuth() const; |
| 34 |
| 35 // Returns the time since the last strong authentication. This should not be |
| 36 // called if HasStrongAuth returns false. |
| 37 base::TimeDelta TimeSinceLastStrongAuth() const; |
| 38 |
| 39 // Returns true if fingerprint unlock is currently available. |
| 40 bool IsFingerprintAuthenticationAvailable() const; |
| 41 |
| 42 // Returns true if PIN unlock is currently available. |
| 43 bool IsPinAuthenticationAvailable() const; |
| 44 |
| 45 // Tries to authenticate the given pin. This will consume a pin unlock |
| 46 // attempt. This always returns false if HasStrongAuth returns false. |
| 47 bool TryAuthenticatePin(const std::string& pin); |
| 48 |
| 49 FingerprintStorage* fingerprint_storage(); |
| 50 |
| 51 PinStorage* pin_storage(); |
| 52 |
| 53 private: |
| 54 friend class chromeos::QuickUnlockStorageTestApi; |
| 55 |
| 56 // KeyedService: |
| 57 void Shutdown() override; |
| 58 |
| 59 PrefService* pref_service_; |
| 60 base::Time last_strong_auth_; |
| 61 std::unique_ptr<FingerprintStorage> fingerprint_storage_; |
| 62 std::unique_ptr<PinStorage> pin_storage_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(QuickUnlockStorage); |
| 65 }; |
| 66 |
| 67 } // namespace quick_unlock |
| 68 } // namespace chromeos |
| 69 |
| 70 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_STORAGE_H_ |
OLD | NEW |