Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_STORAGE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_STORAGE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_STORAGE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_STORAGE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | |
| 8 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 9 #include "base/time/time.h" | 10 #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" | 11 #include "components/keyed_service/core/keyed_service.h" |
| 13 | 12 |
| 14 class PrefService; | 13 class PrefService; |
| 14 class Profile; | |
| 15 | 15 |
| 16 namespace chromeos { | 16 namespace chromeos { |
| 17 | 17 |
| 18 class QuickUnlockStorageTestApi; | 18 class QuickUnlockStorageTestApi; |
| 19 | 19 |
| 20 namespace quick_unlock { | 20 namespace quick_unlock { |
| 21 | 21 |
| 22 class FingerprintStorage; | |
| 23 class PinStoragePrefs; | |
| 24 | |
| 22 class QuickUnlockStorage : public KeyedService { | 25 class QuickUnlockStorage : public KeyedService { |
| 23 public: | 26 public: |
| 24 explicit QuickUnlockStorage(PrefService* pref_service); | 27 using BoolCallback = base::Callback<void(bool)>; |
|
achuithb
2017/05/13 01:01:58
Where's this used?
jdufault
2017/06/06 18:17:06
Removed.
| |
| 28 | |
| 29 explicit QuickUnlockStorage(Profile* profile); | |
| 25 ~QuickUnlockStorage() override; | 30 ~QuickUnlockStorage() override; |
| 26 | 31 |
| 27 // Mark that the user has had a strong authentication. This means | 32 // Mark that the user has had a strong authentication. This means |
| 28 // that they authenticated with their password, for example. Quick | 33 // that they authenticated with their password, for example. Quick |
| 29 // unlock will timeout after a delay. | 34 // unlock will timeout after a delay. |
| 30 void MarkStrongAuth(); | 35 void MarkStrongAuth(); |
| 31 | 36 |
| 32 // Returns true if the user has been strongly authenticated. | 37 // Returns true if the user has been strongly authenticated. |
| 33 bool HasStrongAuth() const; | 38 bool HasStrongAuth() const; |
| 34 | 39 |
| 35 // Returns the time since the last strong authentication. This should not be | 40 // Returns the time since the last strong authentication. This should not be |
| 36 // called if HasStrongAuth returns false. | 41 // called if HasStrongAuth returns false. |
| 37 base::TimeDelta TimeSinceLastStrongAuth() const; | 42 base::TimeDelta TimeSinceLastStrongAuth() const; |
| 38 | 43 |
| 39 // Returns true if fingerprint unlock is currently available. | 44 // Returns true if fingerprint unlock is currently available. |
| 40 bool IsFingerprintAuthenticationAvailable() const; | 45 bool IsFingerprintAuthenticationAvailable() const; |
| 41 | 46 |
| 42 // Returns true if PIN unlock is currently available. | 47 FingerprintStorage* fingerprint_storage() const { |
| 43 bool IsPinAuthenticationAvailable() const; | 48 return fingerprint_storage_.get(); |
| 49 } | |
| 44 | 50 |
| 45 // Tries to authenticate the given pin. This will consume a pin unlock | 51 // Fetch the underlying pref pin storage. If iteracting with pin generally, |
| 46 // attempt. This always returns false if HasStrongAuth returns false. | 52 // use the PinBackend APIs. |
| 47 bool TryAuthenticatePin(const std::string& pin); | 53 PinStoragePrefs* pin_storage_prefs() const { return pin_storage_.get(); } |
| 48 | |
| 49 FingerprintStorage* fingerprint_storage(); | |
| 50 | |
| 51 PinStorage* pin_storage(); | |
| 52 | 54 |
| 53 private: | 55 private: |
| 54 friend class chromeos::QuickUnlockStorageTestApi; | 56 friend class chromeos::QuickUnlockStorageTestApi; |
| 55 | 57 |
| 56 // KeyedService: | 58 // KeyedService: |
| 57 void Shutdown() override; | 59 void Shutdown() override; |
| 58 | 60 |
| 59 PrefService* pref_service_; | 61 PrefService* pref_service_; |
| 60 base::Time last_strong_auth_; | 62 base::Time last_strong_auth_; |
| 61 std::unique_ptr<FingerprintStorage> fingerprint_storage_; | 63 std::unique_ptr<FingerprintStorage> fingerprint_storage_; |
| 62 std::unique_ptr<PinStorage> pin_storage_; | 64 std::unique_ptr<PinStoragePrefs> pin_storage_; |
| 63 | 65 |
| 64 DISALLOW_COPY_AND_ASSIGN(QuickUnlockStorage); | 66 DISALLOW_COPY_AND_ASSIGN(QuickUnlockStorage); |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 } // namespace quick_unlock | 69 } // namespace quick_unlock |
| 68 } // namespace chromeos | 70 } // namespace chromeos |
| 69 | 71 |
| 70 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_STORAGE_H_ | 72 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_STORAGE_H_ |
| OLD | NEW |