| Index: chrome/browser/chromeos/login/quick_unlock/pin_storage.cc
|
| diff --git a/chrome/browser/chromeos/login/quick_unlock/pin_storage.cc b/chrome/browser/chromeos/login/quick_unlock/pin_storage.cc
|
| index 25abdaf2417994b33e3be641a5eedb34f7f25441..d6204756c3d2f27b7473f4f7324f7f2f6aa7631a 100644
|
| --- a/chrome/browser/chromeos/login/quick_unlock/pin_storage.cc
|
| +++ b/chrome/browser/chromeos/login/quick_unlock/pin_storage.cc
|
| @@ -37,11 +37,23 @@ std::string ComputeSecret(const std::string& pin, const std::string& salt) {
|
| return key.GetSecret();
|
| }
|
|
|
| -} // namespace
|
| +base::TimeDelta PasswordConfirmationFrequencyFrequencyToTimeDelta(
|
| + quick_unlock::PasswordConfirmationFrequency frequency) {
|
| + switch (frequency) {
|
| + case quick_unlock::PasswordConfirmationFrequency::SIX_HOURS:
|
| + return base::TimeDelta::FromHours(6);
|
| + case quick_unlock::PasswordConfirmationFrequency::TWELVE_HOURS:
|
| + return base::TimeDelta::FromHours(12);
|
| + case quick_unlock::PasswordConfirmationFrequency::DAY:
|
| + return base::TimeDelta::FromDays(1);
|
| + case quick_unlock::PasswordConfirmationFrequency::WEEK:
|
| + return base::TimeDelta::FromDays(7);
|
| + }
|
| + NOTREACHED();
|
| + return base::TimeDelta();
|
| +}
|
|
|
| -// static
|
| -const base::TimeDelta PinStorage::kStrongAuthTimeout =
|
| - base::TimeDelta::FromHours(24);
|
| +} // namespace
|
|
|
| // static
|
| void PinStorage::RegisterProfilePrefs(
|
| @@ -63,7 +75,16 @@ void PinStorage::MarkStrongAuth() {
|
| }
|
|
|
| bool PinStorage::HasStrongAuth() const {
|
| - return !last_strong_auth_.is_null();
|
| + if (last_strong_auth_.is_null())
|
| + return false;
|
| +
|
| + quick_unlock::PasswordConfirmationFrequency strong_auth_interval =
|
| + static_cast<quick_unlock::PasswordConfirmationFrequency>(
|
| + pref_service_->GetInteger(prefs::kQuickUnlockTimeout));
|
| + base::TimeDelta strong_auth_timeout =
|
| + PasswordConfirmationFrequencyFrequencyToTimeDelta(strong_auth_interval);
|
| +
|
| + return TimeSinceLastStrongAuth() < strong_auth_timeout;
|
| }
|
|
|
| base::TimeDelta PinStorage::TimeSinceLastStrongAuth() const {
|
| @@ -107,11 +128,9 @@ std::string PinStorage::PinSecret() const {
|
| bool PinStorage::IsPinAuthenticationAvailable() const {
|
| const bool exceeded_unlock_attempts =
|
| unlock_attempt_count() >= kMaximumUnlockAttempts;
|
| - const bool has_strong_auth =
|
| - HasStrongAuth() && TimeSinceLastStrongAuth() < kStrongAuthTimeout;
|
|
|
| - return IsQuickUnlockEnabled() && IsPinSet() && has_strong_auth &&
|
| - !exceeded_unlock_attempts;
|
| + return quick_unlock::IsPinUnlockEnabled(pref_service_) && IsPinSet() &&
|
| + HasStrongAuth() && !exceeded_unlock_attempts;
|
| }
|
|
|
| bool PinStorage::TryAuthenticatePin(const std::string& pin) {
|
|
|