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

Unified Diff: chrome/browser/chromeos/login/quick_unlock/pin_storage_prefs.h

Issue 2809993004: cros: Implement cryptohome backend for pin.
Patch Set: Rebase, remove some extraneous LOG statements Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/quick_unlock/pin_storage_prefs.h
diff --git a/chrome/browser/chromeos/login/quick_unlock/pin_storage.h b/chrome/browser/chromeos/login/quick_unlock/pin_storage_prefs.h
similarity index 67%
rename from chrome/browser/chromeos/login/quick_unlock/pin_storage.h
rename to chrome/browser/chromeos/login/quick_unlock/pin_storage_prefs.h
index e147bda0e366360cd14cb96788cdcff5f1c3660f..14c82ec7c78d298839958dea1505985344dd4e2e 100644
--- a/chrome/browser/chromeos/login/quick_unlock/pin_storage.h
+++ b/chrome/browser/chromeos/login/quick_unlock/pin_storage_prefs.h
@@ -2,16 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_H_
-#define CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_H_
+#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_PREFS_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_PREFS_H_
#include <string>
-#include "base/gtest_prod_util.h"
-#include "base/time/time.h"
+#include "base/macros.h"
class PrefRegistrySimple;
-class PrefService;
+class Profile;
namespace chromeos {
@@ -21,53 +20,63 @@ namespace quick_unlock {
class QuickUnlockStorage;
-class PinStorage {
+class PinStoragePrefs {
public:
- // TODO(sammiequon): Pull this value in from policy. See crbug.com/612271.
static const int kMaximumUnlockAttempts = 3;
// Registers profile prefs.
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
- explicit PinStorage(PrefService* pref_service);
- ~PinStorage();
-
- // Add a PIN unlock attempt count.
- void AddUnlockAttempt();
- // Reset the number of unlock attempts to 0.
- void ResetUnlockAttemptCount();
- // Returns the number of unlock attempts.
- int unlock_attempt_count() const { return unlock_attempt_count_; }
+ explicit PinStoragePrefs(Profile* profile);
+ ~PinStoragePrefs();
// Returns true if a pin is set.
bool IsPinSet() const;
- // Sets the pin to the given value; IsPinSet will return true.
+
+ // Sets the pin to the given value.
void SetPin(const std::string& pin);
+
// Removes the pin; IsPinSet will return false.
void RemovePin();
- private:
- friend class chromeos::PinStorageTestApi;
- friend class QuickUnlockStorage;
-
// Is PIN entry currently available?
bool IsPinAuthenticationAvailable() const;
// Tries to authenticate the given pin. This will consume an unlock attempt.
// This always returns false if IsPinAuthenticationAvailable returns false.
+ //
+ // This is a no-op for cryptohome implementation (standard password flow works
+ // there).
bool TryAuthenticatePin(const std::string& pin);
+ // Implementation should return true if it needs strong auth support, ie, the
+ // user has to type their password every x hours.
+ bool NeedsStrongAuth() const;
+
+ // Add a PIN unlock attempt count.
+ void AddUnlockAttempt();
+
+ // Reset the unlock attempt count to 0. Not applicable to all implementations.
+ void ResetUnlockAttemptCount();
+
+ // Returns the number of unlock attempts.
+ int unlock_attempt_count() const { return unlock_attempt_count_; }
+
+ private:
+ friend class chromeos::PinStorageTestApi;
+ friend class QuickUnlockStorage;
+
// Return the stored salt/secret. This is fetched directly from pref_service_.
std::string PinSalt() const;
std::string PinSecret() const;
- PrefService* pref_service_;
+ Profile* profile_;
int unlock_attempt_count_ = 0;
- DISALLOW_COPY_AND_ASSIGN(PinStorage);
+ DISALLOW_COPY_AND_ASSIGN(PinStoragePrefs);
};
} // namespace quick_unlock
} // namespace chromeos
-#endif // CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_H_
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_QUICK_UNLOCK_PIN_STORAGE_PREFS_H_

Powered by Google App Engine
This is Rietveld 408576698