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