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

Side by Side Diff: chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.cc

Issue 2815733003: cros: Add PinStorageProvider enum which describes pin backend in use. (Closed)
Patch Set: Address comments 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/time/time.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 10 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
11 #include "chrome/common/chrome_features.h" 11 #include "chrome/common/chrome_features.h"
12 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "components/prefs/pref_registry_simple.h" 13 #include "components/prefs/pref_registry_simple.h"
14 #include "components/prefs/pref_service.h" 14 #include "components/prefs/pref_service.h"
15 #include "components/user_manager/user_manager.h" 15 #include "components/user_manager/user_manager.h"
16 16
17 namespace chromeos { 17 namespace chromeos {
18 namespace quick_unlock { 18 namespace quick_unlock {
19 19
20 namespace { 20 namespace {
21 // Quick unlock is enabled regardless of flags.
21 bool enable_for_testing_ = false; 22 bool enable_for_testing_ = false;
23 // If testing is enabled, PIN will use prefs as backend. Otherwise, it will use
24 // cryptohome.
25 PinStorageType testing_pin_storage_type_ = PinStorageType::kPrefs;
26
22 // Options for the quick unlock whitelist. 27 // Options for the quick unlock whitelist.
23 const char kQuickUnlockWhitelistOptionAll[] = "all"; 28 const char kQuickUnlockWhitelistOptionAll[] = "all";
24 const char kQuickUnlockWhitelistOptionPin[] = "PIN"; 29 const char kQuickUnlockWhitelistOptionPin[] = "PIN";
25 // Default minimum PIN length. Policy can increase or decrease this value. 30 // Default minimum PIN length. Policy can increase or decrease this value.
26 constexpr int kDefaultMinimumPinLength = 6; 31 constexpr int kDefaultMinimumPinLength = 6;
27 } // namespace 32 } // namespace
28 33
29 base::TimeDelta PasswordConfirmationFrequencyToTimeDelta( 34 base::TimeDelta PasswordConfirmationFrequencyToTimeDelta(
30 PasswordConfirmationFrequency frequency) { 35 PasswordConfirmationFrequency frequency) {
31 switch (frequency) { 36 switch (frequency) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // TODO(jdufault): Disable PIN for supervised users until we allow the owner 85 // TODO(jdufault): Disable PIN for supervised users until we allow the owner
81 // to set the PIN. See crbug.com/632797. 86 // to set the PIN. See crbug.com/632797.
82 user_manager::User* user = user_manager::UserManager::Get()->GetActiveUser(); 87 user_manager::User* user = user_manager::UserManager::Get()->GetActiveUser();
83 if (user && user->IsSupervised()) 88 if (user && user->IsSupervised())
84 return false; 89 return false;
85 90
86 // Enable quick unlock only if the switch is present. 91 // Enable quick unlock only if the switch is present.
87 return base::FeatureList::IsEnabled(features::kQuickUnlockPin); 92 return base::FeatureList::IsEnabled(features::kQuickUnlockPin);
88 } 93 }
89 94
95 PinStorageType GetPinStorageType() {
96 if (enable_for_testing_)
97 return testing_pin_storage_type_;
98
99 if (base::FeatureList::IsEnabled(features::kQuickUnlockPinSignin))
100 return PinStorageType::kCryptohome;
101 return PinStorageType::kPrefs;
102 }
103
90 bool IsFingerprintEnabled() { 104 bool IsFingerprintEnabled() {
91 if (enable_for_testing_) 105 if (enable_for_testing_)
92 return true; 106 return true;
93 107
94 // Enable fingerprint unlock only if the switch is present. 108 // Enable fingerprint unlock only if the switch is present.
95 return base::FeatureList::IsEnabled(features::kQuickUnlockFingerprint); 109 return base::FeatureList::IsEnabled(features::kQuickUnlockFingerprint);
96 } 110 }
97 111
98 void EnableForTesting() { 112 void EnableForTesting(PinStorageType pin_storage_type) {
99 enable_for_testing_ = true; 113 enable_for_testing_ = true;
114 testing_pin_storage_type_ = pin_storage_type;
100 } 115 }
101 116
102 } // namespace quick_unlock 117 } // namespace quick_unlock
103 } // namespace chromeos 118 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698