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 "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 9 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
10 #include "chrome/common/chrome_features.h" | 10 #include "chrome/common/chrome_features.h" |
11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
12 #include "components/pref_registry/pref_registry_syncable.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 | 18 |
18 namespace { | 19 namespace { |
19 bool enable_for_testing_ = false; | 20 bool enable_for_testing_ = false; |
20 // Options for the quick unlock whitelist. | 21 // Options for the quick unlock whitelist. |
21 const char kQuickUnlockWhitelistOptionAll[] = "all"; | 22 const char kQuickUnlockWhitelistOptionAll[] = "all"; |
22 const char kQuickUnlockWhitelistOptionPin[] = "PIN"; | 23 const char kQuickUnlockWhitelistOptionPin[] = "PIN"; |
23 } // namespace | 24 } // namespace |
24 | 25 |
25 void RegisterQuickUnlockProfilePrefs(PrefRegistrySimple* registry) { | 26 void RegisterQuickUnlockProfilePrefs(PrefRegistrySimple* registry) { |
26 base::ListValue quick_unlock_whitelist_default; | 27 base::ListValue quick_unlock_whitelist_default; |
27 quick_unlock_whitelist_default.AppendString(kQuickUnlockWhitelistOptionPin); | 28 quick_unlock_whitelist_default.AppendString(kQuickUnlockWhitelistOptionPin); |
28 registry->RegisterListPref(prefs::kQuickUnlockModeWhitelist, | 29 registry->RegisterListPref(prefs::kQuickUnlockModeWhitelist, |
29 quick_unlock_whitelist_default.DeepCopy()); | 30 quick_unlock_whitelist_default.DeepCopy()); |
30 registry->RegisterIntegerPref( | 31 registry->RegisterIntegerPref( |
31 prefs::kQuickUnlockTimeout, | 32 prefs::kQuickUnlockTimeout, |
32 static_cast<int>(QuickUnlockPasswordConfirmationFrequency::DAY)); | 33 static_cast<int>(QuickUnlockPasswordConfirmationFrequency::DAY)); |
34 registry->RegisterBooleanPref( | |
35 prefs::kEnableQuickUnlockFingerprint, false, | |
jdufault
2016/12/01 17:11:19
I believe the pref is syncable by default, so this
sammiequon
2016/12/01 20:52:28
Done.
| |
36 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | |
33 } | 37 } |
34 | 38 |
35 bool IsPinUnlockEnabled(PrefService* pref_service) { | 39 bool IsPinUnlockEnabled(PrefService* pref_service) { |
36 if (enable_for_testing_) | 40 if (enable_for_testing_) |
37 return true; | 41 return true; |
38 | 42 |
39 // Check if policy allows PIN. | 43 // Check if policy allows PIN. |
40 const base::ListValue* quick_unlock_whitelist = | 44 const base::ListValue* quick_unlock_whitelist = |
41 pref_service->GetList(prefs::kQuickUnlockModeWhitelist); | 45 pref_service->GetList(prefs::kQuickUnlockModeWhitelist); |
42 base::StringValue all_value(kQuickUnlockWhitelistOptionAll); | 46 base::StringValue all_value(kQuickUnlockWhitelistOptionAll); |
43 base::StringValue pin_value(kQuickUnlockWhitelistOptionPin); | 47 base::StringValue pin_value(kQuickUnlockWhitelistOptionPin); |
44 if (quick_unlock_whitelist->Find(all_value) == | 48 if (quick_unlock_whitelist->Find(all_value) == |
45 quick_unlock_whitelist->end() && | 49 quick_unlock_whitelist->end() && |
46 quick_unlock_whitelist->Find(pin_value) == | 50 quick_unlock_whitelist->Find(pin_value) == |
47 quick_unlock_whitelist->end()) { | 51 quick_unlock_whitelist->end()) { |
48 return false; | 52 return false; |
49 } | 53 } |
50 | 54 |
51 // TODO(jdufault): Disable PIN for supervised users until we allow the owner | 55 // TODO(jdufault): Disable PIN for supervised users until we allow the owner |
52 // to set the PIN. See crbug.com/632797. | 56 // to set the PIN. See crbug.com/632797. |
53 user_manager::User* user = user_manager::UserManager::Get()->GetActiveUser(); | 57 user_manager::User* user = user_manager::UserManager::Get()->GetActiveUser(); |
54 if (user && user->IsSupervised()) | 58 if (user && user->IsSupervised()) |
55 return false; | 59 return false; |
56 | 60 |
57 // Enable quick unlock only if the switch is present. | 61 // Enable quick unlock only if the switch is present. |
58 return base::FeatureList::IsEnabled(features::kQuickUnlockPin); | 62 return base::FeatureList::IsEnabled(features::kQuickUnlockPin); |
59 } | 63 } |
60 | 64 |
65 bool IsFingerprintUnlockEnabled() { | |
66 // Enable fingerprint unlock only if the switch is present. For now, | |
67 // fingerprint unlock will not be seen if quick unlock switch is not present, | |
68 // so check that too. | |
69 return base::FeatureList::IsEnabled(features::kQuickUnlockPin) && | |
jdufault
2016/12/01 17:11:19
Why are these tied together like this?
sammiequon
2016/12/01 20:52:29
The fingerprint settings are under the lock screen
jdufault
2016/12/02 23:02:11
You should update the comment with that info.
sammiequon
2016/12/03 21:40:51
Done.
| |
70 base::FeatureList::IsEnabled(features::kQuickUnlockFingerprint); | |
71 } | |
72 | |
61 void EnableQuickUnlockForTesting() { | 73 void EnableQuickUnlockForTesting() { |
62 enable_for_testing_ = true; | 74 enable_for_testing_ = true; |
63 } | 75 } |
64 | 76 |
65 } // namespace chromeos | 77 } // namespace chromeos |
OLD | NEW |