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

Unified Diff: chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.cc

Issue 2387253002: cros: Added policies for screen unlock. (Closed)
Patch Set: Fixed patch set 5 errors. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.cc
diff --git a/chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.cc b/chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.cc
index afd4e68382a125618bf15689f464cbf84223e2c3..30d28fad4308727aaf6d374d408576cdda6caf1e 100644
--- a/chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.cc
+++ b/chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.cc
@@ -8,6 +8,8 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/common/chrome_features.h"
+#include "chrome/common/pref_names.h"
+#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
namespace chromeos {
@@ -16,17 +18,13 @@ namespace {
bool enable_for_testing_ = false;
} // namespace
-bool IsQuickUnlockEnabled() {
+bool IsQuickUnlockEnabled(PrefService* pref_service) {
if (enable_for_testing_)
return true;
- // TODO(jdufault): Implement a proper policy check. For now, just disable if
- // the device is enterprise enrolled. See crbug.com/612271.
- if (g_browser_process->platform_part()
- ->browser_policy_connector_chromeos()
- ->IsEnterpriseManaged()) {
+ // Check if policy allows PIN.
+ if (!IsPinUnlockEnabled(pref_service))
return false;
- }
// TODO(jdufault): Disable PIN for supervised users until we allow the owner
// to set the PIN. See crbug.com/632797.
@@ -38,6 +36,16 @@ bool IsQuickUnlockEnabled() {
return base::FeatureList::IsEnabled(features::kQuickUnlockPin);
}
+bool IsPinUnlockEnabled(PrefService* pref_service) {
+ const base::ListValue* screen_lock_whitelist =
+ pref_service->GetList(prefs::kQuickUnlockModeWhitelist);
+ base::StringValue all_value("all");
+ base::StringValue pin_value("pin");
+ return screen_lock_whitelist->Find(all_value) !=
+ screen_lock_whitelist->end() ||
+ screen_lock_whitelist->Find(pin_value) != screen_lock_whitelist->end();
+}
+
void EnableQuickUnlockForTesting() {
enable_for_testing_ = true;
}

Powered by Google App Engine
This is Rietveld 408576698