| 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_service.h" |
| 11 #include "components/user_manager/user_manager.h" | 13 #include "components/user_manager/user_manager.h" |
| 12 | 14 |
| 13 namespace chromeos { | 15 namespace chromeos { |
| 14 | 16 |
| 15 namespace { | 17 namespace { |
| 16 bool enable_for_testing_ = false; | 18 bool enable_for_testing_ = false; |
| 17 } // namespace | 19 } // namespace |
| 18 | 20 |
| 19 bool IsQuickUnlockEnabled() { | 21 bool IsQuickUnlockEnabled(PrefService* pref_service) { |
| 20 if (enable_for_testing_) | 22 if (enable_for_testing_) |
| 21 return true; | 23 return true; |
| 22 | 24 |
| 23 // TODO(jdufault): Implement a proper policy check. For now, just disable if | 25 // Check if policy allows PIN. |
| 24 // the device is enterprise enrolled. See crbug.com/612271. | 26 if (!IsPinUnlockEnabled(pref_service)) |
| 25 if (g_browser_process->platform_part() | |
| 26 ->browser_policy_connector_chromeos() | |
| 27 ->IsEnterpriseManaged()) { | |
| 28 return false; | 27 return false; |
| 29 } | |
| 30 | 28 |
| 31 // TODO(jdufault): Disable PIN for supervised users until we allow the owner | 29 // TODO(jdufault): Disable PIN for supervised users until we allow the owner |
| 32 // to set the PIN. See crbug.com/632797. | 30 // to set the PIN. See crbug.com/632797. |
| 33 user_manager::User* user = user_manager::UserManager::Get()->GetActiveUser(); | 31 user_manager::User* user = user_manager::UserManager::Get()->GetActiveUser(); |
| 34 if (user && user->IsSupervised()) | 32 if (user && user->IsSupervised()) |
| 35 return false; | 33 return false; |
| 36 | 34 |
| 37 // Enable quick unlock only if the switch is present. | 35 // Enable quick unlock only if the switch is present. |
| 38 return base::FeatureList::IsEnabled(features::kQuickUnlockPin); | 36 return base::FeatureList::IsEnabled(features::kQuickUnlockPin); |
| 39 } | 37 } |
| 40 | 38 |
| 39 bool IsPinUnlockEnabled(PrefService* pref_service) { |
| 40 const base::ListValue* screen_lock_whitelist = |
| 41 pref_service->GetList(prefs::kQuickUnlockModeWhitelist); |
| 42 base::StringValue all_value("all"); |
| 43 base::StringValue pin_value("pin"); |
| 44 return screen_lock_whitelist->Find(all_value) != |
| 45 screen_lock_whitelist->end() || |
| 46 screen_lock_whitelist->Find(pin_value) != screen_lock_whitelist->end(); |
| 47 } |
| 48 |
| 41 void EnableQuickUnlockForTesting() { | 49 void EnableQuickUnlockForTesting() { |
| 42 enable_for_testing_ = true; | 50 enable_for_testing_ = true; |
| 43 } | 51 } |
| 44 | 52 |
| 45 } // namespace chromeos | 53 } // namespace chromeos |
| OLD | NEW |