OLD | NEW |
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 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h" | 5 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h" |
6 | 6 |
7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/time/time.h" |
8 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 10 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
10 #include "chrome/common/chrome_features.h" | 11 #include "chrome/common/chrome_features.h" |
11 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
12 #include "components/prefs/pref_registry_simple.h" | 13 #include "components/prefs/pref_registry_simple.h" |
13 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
14 #include "components/user_manager/user_manager.h" | 15 #include "components/user_manager/user_manager.h" |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 namespace quick_unlock { | 18 namespace quick_unlock { |
18 | 19 |
19 namespace { | 20 namespace { |
20 bool enable_for_testing_ = false; | 21 bool enable_for_testing_ = false; |
21 // Options for the quick unlock whitelist. | 22 // Options for the quick unlock whitelist. |
22 const char kQuickUnlockWhitelistOptionAll[] = "all"; | 23 const char kQuickUnlockWhitelistOptionAll[] = "all"; |
23 const char kQuickUnlockWhitelistOptionPin[] = "PIN"; | 24 const char kQuickUnlockWhitelistOptionPin[] = "PIN"; |
24 // Default minimum PIN length. Policy can increase or decrease this value. | 25 // Default minimum PIN length. Policy can increase or decrease this value. |
25 constexpr int kDefaultMinimumPinLength = 6; | 26 constexpr int kDefaultMinimumPinLength = 6; |
26 } // namespace | 27 } // namespace |
27 | 28 |
| 29 base::TimeDelta PasswordConfirmationFrequencyToTimeDelta( |
| 30 PasswordConfirmationFrequency frequency) { |
| 31 switch (frequency) { |
| 32 case PasswordConfirmationFrequency::SIX_HOURS: |
| 33 return base::TimeDelta::FromHours(6); |
| 34 case PasswordConfirmationFrequency::TWELVE_HOURS: |
| 35 return base::TimeDelta::FromHours(12); |
| 36 case PasswordConfirmationFrequency::DAY: |
| 37 return base::TimeDelta::FromDays(1); |
| 38 case PasswordConfirmationFrequency::WEEK: |
| 39 return base::TimeDelta::FromDays(7); |
| 40 } |
| 41 NOTREACHED(); |
| 42 return base::TimeDelta(); |
| 43 } |
| 44 |
28 void RegisterProfilePrefs(PrefRegistrySimple* registry) { | 45 void RegisterProfilePrefs(PrefRegistrySimple* registry) { |
29 base::ListValue quick_unlock_whitelist_default; | 46 base::ListValue quick_unlock_whitelist_default; |
30 quick_unlock_whitelist_default.AppendString(kQuickUnlockWhitelistOptionPin); | 47 quick_unlock_whitelist_default.AppendString(kQuickUnlockWhitelistOptionPin); |
31 registry->RegisterListPref(prefs::kQuickUnlockModeWhitelist, | 48 registry->RegisterListPref(prefs::kQuickUnlockModeWhitelist, |
32 quick_unlock_whitelist_default.DeepCopy()); | 49 quick_unlock_whitelist_default.DeepCopy()); |
33 registry->RegisterIntegerPref( | 50 registry->RegisterIntegerPref( |
34 prefs::kQuickUnlockTimeout, | 51 prefs::kQuickUnlockTimeout, |
35 static_cast<int>(PasswordConfirmationFrequency::DAY)); | 52 static_cast<int>(PasswordConfirmationFrequency::DAY)); |
36 | 53 |
37 // Preferences related the lock screen pin unlock. | 54 // Preferences related the lock screen pin unlock. |
(...skipping 26 matching lines...) Expand all Loading... |
64 // to set the PIN. See crbug.com/632797. | 81 // to set the PIN. See crbug.com/632797. |
65 user_manager::User* user = user_manager::UserManager::Get()->GetActiveUser(); | 82 user_manager::User* user = user_manager::UserManager::Get()->GetActiveUser(); |
66 if (user && user->IsSupervised()) | 83 if (user && user->IsSupervised()) |
67 return false; | 84 return false; |
68 | 85 |
69 // Enable quick unlock only if the switch is present. | 86 // Enable quick unlock only if the switch is present. |
70 return base::FeatureList::IsEnabled(features::kQuickUnlockPin); | 87 return base::FeatureList::IsEnabled(features::kQuickUnlockPin); |
71 } | 88 } |
72 | 89 |
73 bool IsFingerprintEnabled() { | 90 bool IsFingerprintEnabled() { |
| 91 if (enable_for_testing_) |
| 92 return true; |
| 93 |
74 // Enable fingerprint unlock only if the switch is present. | 94 // Enable fingerprint unlock only if the switch is present. |
75 return base::FeatureList::IsEnabled(features::kQuickUnlockFingerprint); | 95 return base::FeatureList::IsEnabled(features::kQuickUnlockFingerprint); |
76 } | 96 } |
77 | 97 |
78 void EnableForTesting() { | 98 void EnableForTesting() { |
79 enable_for_testing_ = true; | 99 enable_for_testing_ = true; |
80 } | 100 } |
81 | 101 |
82 } // namespace quick_unlock | 102 } // namespace quick_unlock |
83 } // namespace chromeos | 103 } // namespace chromeos |
OLD | NEW |