| 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" |
| 12 #include "components/prefs/pref_registry_simple.h" |
| 13 #include "components/prefs/pref_service.h" |
| 11 #include "components/user_manager/user_manager.h" | 14 #include "components/user_manager/user_manager.h" |
| 12 | 15 |
| 13 namespace chromeos { | 16 namespace chromeos { |
| 14 | 17 |
| 15 namespace { | 18 namespace { |
| 16 bool enable_for_testing_ = false; | 19 bool enable_for_testing_ = false; |
| 20 // Options for the quick unlock whitelist. |
| 21 const char kQuickUnlockWhitelistOptionAll[] = "all"; |
| 22 const char kQuickUnlockWhitelistOptionPin[] = "PIN"; |
| 17 } // namespace | 23 } // namespace |
| 18 | 24 |
| 19 bool IsQuickUnlockEnabled() { | 25 void RegisterQuickUnlockProfilePrefs(PrefRegistrySimple* registry) { |
| 26 base::ListValue quick_unlock_whitelist_default; |
| 27 quick_unlock_whitelist_default.AppendString(kQuickUnlockWhitelistOptionPin); |
| 28 registry->RegisterListPref(prefs::kQuickUnlockModeWhitelist, |
| 29 quick_unlock_whitelist_default.DeepCopy()); |
| 30 registry->RegisterIntegerPref( |
| 31 prefs::kQuickUnlockTimeout, |
| 32 static_cast<int>(QuickUnlockPasswordConfirmationFrequency::DAY)); |
| 33 } |
| 34 |
| 35 bool IsPinUnlockEnabled(PrefService* pref_service) { |
| 20 if (enable_for_testing_) | 36 if (enable_for_testing_) |
| 21 return true; | 37 return true; |
| 22 | 38 |
| 23 // TODO(jdufault): Implement a proper policy check. For now, just disable if | 39 // Check if policy allows PIN. |
| 24 // the device is enterprise enrolled. See crbug.com/612271. | 40 const base::ListValue* quick_unlock_whitelist = |
| 25 if (g_browser_process->platform_part() | 41 pref_service->GetList(prefs::kQuickUnlockModeWhitelist); |
| 26 ->browser_policy_connector_chromeos() | 42 base::StringValue all_value(kQuickUnlockWhitelistOptionAll); |
| 27 ->IsEnterpriseManaged()) { | 43 base::StringValue pin_value(kQuickUnlockWhitelistOptionPin); |
| 44 if (quick_unlock_whitelist->Find(all_value) == |
| 45 quick_unlock_whitelist->end() && |
| 46 quick_unlock_whitelist->Find(pin_value) == |
| 47 quick_unlock_whitelist->end()) { |
| 28 return false; | 48 return false; |
| 29 } | 49 } |
| 30 | 50 |
| 31 // TODO(jdufault): Disable PIN for supervised users until we allow the owner | 51 // TODO(jdufault): Disable PIN for supervised users until we allow the owner |
| 32 // to set the PIN. See crbug.com/632797. | 52 // to set the PIN. See crbug.com/632797. |
| 33 user_manager::User* user = user_manager::UserManager::Get()->GetActiveUser(); | 53 user_manager::User* user = user_manager::UserManager::Get()->GetActiveUser(); |
| 34 if (user && user->IsSupervised()) | 54 if (user && user->IsSupervised()) |
| 35 return false; | 55 return false; |
| 36 | 56 |
| 37 // Enable quick unlock only if the switch is present. | 57 // Enable quick unlock only if the switch is present. |
| 38 return base::FeatureList::IsEnabled(features::kQuickUnlockPin); | 58 return base::FeatureList::IsEnabled(features::kQuickUnlockPin); |
| 39 } | 59 } |
| 40 | 60 |
| 41 void EnableQuickUnlockForTesting() { | 61 void EnableQuickUnlockForTesting() { |
| 42 enable_for_testing_ = true; | 62 enable_for_testing_ = true; |
| 43 } | 63 } |
| 44 | 64 |
| 45 } // namespace chromeos | 65 } // namespace chromeos |
| OLD | NEW |