OLD | NEW |
| (Empty) |
1 // Copyright 2016 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_PIN_STORAGE_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/gtest_prod_util.h" | |
11 #include "base/time/time.h" | |
12 | |
13 class PrefRegistrySimple; | |
14 class PrefService; | |
15 | |
16 namespace chromeos { | |
17 | |
18 class PinStorageTestApi; | |
19 | |
20 namespace quick_unlock { | |
21 | |
22 class QuickUnlockStorage; | |
23 | |
24 class PinStorage { | |
25 public: | |
26 // TODO(sammiequon): Pull this value in from policy. See crbug.com/612271. | |
27 static const int kMaximumUnlockAttempts = 3; | |
28 | |
29 // Registers profile prefs. | |
30 static void RegisterProfilePrefs(PrefRegistrySimple* registry); | |
31 | |
32 explicit PinStorage(PrefService* pref_service); | |
33 ~PinStorage(); | |
34 | |
35 // Add a PIN unlock attempt count. | |
36 void AddUnlockAttempt(); | |
37 // Reset the number of unlock attempts to 0. | |
38 void ResetUnlockAttemptCount(); | |
39 // Returns the number of unlock attempts. | |
40 int unlock_attempt_count() const { return unlock_attempt_count_; } | |
41 | |
42 // Returns true if a pin is set. | |
43 bool IsPinSet() const; | |
44 // Sets the pin to the given value; IsPinSet will return true. | |
45 void SetPin(const std::string& pin); | |
46 // Removes the pin; IsPinSet will return false. | |
47 void RemovePin(); | |
48 | |
49 private: | |
50 friend class chromeos::PinStorageTestApi; | |
51 friend class QuickUnlockStorage; | |
52 | |
53 // Is PIN entry currently available? | |
54 bool IsPinAuthenticationAvailable() const; | |
55 | |
56 // Tries to authenticate the given pin. This will consume an unlock attempt. | |
57 // This always returns false if IsPinAuthenticationAvailable returns false. | |
58 bool TryAuthenticatePin(const std::string& pin); | |
59 | |
60 // Return the stored salt/secret. This is fetched directly from pref_service_. | |
61 std::string PinSalt() const; | |
62 std::string PinSecret() const; | |
63 | |
64 PrefService* pref_service_; | |
65 int unlock_attempt_count_ = 0; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(PinStorage); | |
68 }; | |
69 | |
70 } // namespace quick_unlock | |
71 } // namespace chromeos | |
72 | |
73 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_H_ | |
OLD | NEW |