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

Unified Diff: chrome/browser/resources/settings/people_page/lock_state_behavior.js

Issue 2208473007: Rework quick unlock settings to follow new specs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fix closure (bad merge) Created 4 years, 4 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/resources/settings/people_page/lock_state_behavior.js
diff --git a/chrome/browser/resources/settings/people_page/lock_state_behavior.js b/chrome/browser/resources/settings/people_page/lock_state_behavior.js
new file mode 100644
index 0000000000000000000000000000000000000000..e96c2af3453100799a6f718d6cd4e454ed97a4d4
--- /dev/null
+++ b/chrome/browser/resources/settings/people_page/lock_state_behavior.js
@@ -0,0 +1,76 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * Contains utilities that help identify the current way that the lock screen
+ * will be displayed.
+ */
+
+/** @enum {string} */
+var LockScreenUnlockType = {
+ VALUE_PENDING: 'value_pending',
+ PASSWORD: 'password',
+ PIN_PASSWORD: 'pin+password'
+};
+
+/** @polymerBehavior */
+var LockStateBehavior = {
+ properties: {
+ /**
+ * The currently selected unlock type.
+ * @type {!LockScreenUnlockType}
+ */
+ selectedUnlockType: {
+ type: String,
+ notify: true,
+ value: LockScreenUnlockType.VALUE_PENDING
+ },
+
+ /**
+ * True/false if there is a PIN set; undefined if the computation is still
+ * pending. This is a separate value from selectedUnlockType because the UI
+ * can change the selectedUnlockType before setting up a PIN.
+ * @type {boolean|undefined}
+ */
+ hasPin: {
+ type: Boolean,
+ notify: true
+ }
+ },
+
+ /** @override */
+ attached: function() {
+ this.boundOnActiveModesChanged_ = this.updateUnlockType_.bind(this);
+ chrome.quickUnlockPrivate.onActiveModesChanged.addListener(
+ this.boundOnActiveModesChanged_);
+
+ this.updateUnlockType_();
+ },
+
+ /** @override */
+ detached: function() {
+ chrome.quickUnlockPrivate.onActiveModesChanged.removeListener(
+ this.boundOnActiveModesChanged_);
+ },
+
+ /**
+ * Updates the selected unlock type radio group. This function will get called
+ * after preferences are initialized, after the quick unlock mode has been
+ * changed, and after the lockscreen preference has changed.
+ *
+ * @private
+ */
+ updateUnlockType_: function() {
+ chrome.quickUnlockPrivate.getActiveModes(function(modes) {
+ if (modes.includes(chrome.quickUnlockPrivate.QuickUnlockMode.PIN)) {
+ this.hasPin = true;
+ this.selectedUnlockType = LockScreenUnlockType.PIN_PASSWORD;
+ } else {
+ this.hasPin = false;
+ this.selectedUnlockType = LockScreenUnlockType.PASSWORD;
+ }
+ }.bind(this));
+ },
+};

Powered by Google App Engine
This is Rietveld 408576698