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

Side by Side Diff: chrome/browser/chromeos/login/quick_unlock/pin_storage.h

Issue 2715823004: Add FingerprintUnlock KeyedService for each profile (Closed)
Patch Set: rebase 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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_PIN_STORAGE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "components/keyed_service/core/keyed_service.h"
13 12
14 class PrefRegistrySimple; 13 class PrefRegistrySimple;
15 class PrefService; 14 class PrefService;
16 15
17 namespace chromeos { 16 namespace chromeos {
18 17
19 class PinStorageTestApi; 18 class PinStorageTestApi;
20 19
21 namespace quick_unlock { 20 namespace quick_unlock {
22 21
23 class PinStorage : public KeyedService { 22 class QuickUnlockStorage;
23
24 class PinStorage {
24 public: 25 public:
25 // TODO(sammiequon): Pull this value in from policy. See crbug.com/612271. 26 // TODO(sammiequon): Pull this value in from policy. See crbug.com/612271.
26 static const int kMaximumUnlockAttempts = 3; 27 static const int kMaximumUnlockAttempts = 3;
27 28
28 // Registers profile prefs. 29 // Registers profile prefs.
29 static void RegisterProfilePrefs(PrefRegistrySimple* registry); 30 static void RegisterProfilePrefs(PrefRegistrySimple* registry);
30 31
31 explicit PinStorage(PrefService* pref_service); 32 explicit PinStorage(PrefService* pref_service);
32 ~PinStorage() override; 33 ~PinStorage();
33
34 // Mark in storage that the user has had a strong authentication. This means
35 // that they authenticated with their password, for example. PIN unlock will
36 // timeout after a delay.
37 void MarkStrongAuth();
38 // Returns true if the user has been strongly authenticated.
39 bool HasStrongAuth() const;
40 // Returns the time since the last strong authentication. This should not be
41 // called if HasStrongAuth returns false.
42 base::TimeDelta TimeSinceLastStrongAuth() const;
43 34
44 // Add a PIN unlock attempt count. 35 // Add a PIN unlock attempt count.
45 void AddUnlockAttempt(); 36 void AddUnlockAttempt();
46 // Reset the number of unlock attempts to 0. 37 // Reset the number of unlock attempts to 0.
47 void ResetUnlockAttemptCount(); 38 void ResetUnlockAttemptCount();
48 // Returns the number of unlock attempts. 39 // Returns the number of unlock attempts.
49 int unlock_attempt_count() const { return unlock_attempt_count_; } 40 int unlock_attempt_count() const { return unlock_attempt_count_; }
50 41
51 // Returns true if a pin is set. 42 // Returns true if a pin is set.
52 bool IsPinSet() const; 43 bool IsPinSet() const;
53 // Sets the pin to the given value; IsPinSet will return true. 44 // Sets the pin to the given value; IsPinSet will return true.
54 void SetPin(const std::string& pin); 45 void SetPin(const std::string& pin);
55 // Removes the pin; IsPinSet will return false. 46 // Removes the pin; IsPinSet will return false.
56 void RemovePin(); 47 void RemovePin();
57 48
49 private:
50 friend class chromeos::PinStorageTestApi;
51 friend class QuickUnlockStorage;
52
58 // Is PIN entry currently available? 53 // Is PIN entry currently available?
59 bool IsPinAuthenticationAvailable() const; 54 bool IsPinAuthenticationAvailable() const;
60 55
61 // Tries to authenticate the given pin. This will consume an unlock attempt. 56 // Tries to authenticate the given pin. This will consume an unlock attempt.
62 // This always returns false if IsPinAuthenticationAvailable returns false. 57 // This always returns false if IsPinAuthenticationAvailable returns false.
63 bool TryAuthenticatePin(const std::string& pin); 58 bool TryAuthenticatePin(const std::string& pin);
64 59
65 private:
66 // Return the stored salt/secret. This is fetched directly from pref_service_. 60 // Return the stored salt/secret. This is fetched directly from pref_service_.
67 std::string PinSalt() const; 61 std::string PinSalt() const;
68 std::string PinSecret() const; 62 std::string PinSecret() const;
69 63
70 friend class chromeos::PinStorageTestApi;
71
72 PrefService* pref_service_; 64 PrefService* pref_service_;
73 int unlock_attempt_count_ = 0; 65 int unlock_attempt_count_ = 0;
74 base::Time last_strong_auth_;
75 66
76 DISALLOW_COPY_AND_ASSIGN(PinStorage); 67 DISALLOW_COPY_AND_ASSIGN(PinStorage);
77 }; 68 };
78 69
79 } // namespace quick_unlock 70 } // namespace quick_unlock
80 } // namespace chromeos 71 } // namespace chromeos
81 72
82 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_H_ 73 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698