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

Unified Diff: chrome/browser/chromeos/login/quick_unlock/pin_storage.cc

Issue 2387253002: cros: Added policies for screen unlock. (Closed)
Patch Set: Fixed rebase error. Created 4 years, 2 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.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) {

Powered by Google App Engine
This is Rietveld 408576698