Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview | |
| 7 * Contains utilities that help identify the current way that the lock screen | |
| 8 * will be displayed. | |
| 9 */ | |
| 10 | |
| 11 /** @enum {string} */ | |
| 12 var LockScreenUnlockType = { | |
| 13 VALUE_PENDING: 'value_pending', | |
| 14 PASSWORD: 'password', | |
| 15 PIN_PASSWORD: 'pin+password' | |
| 16 }; | |
| 17 | |
| 18 /** @polymerBehavior */ | |
| 19 var LockStateBehavior = { | |
| 20 properties: { | |
| 21 /** | |
| 22 * The currently selected unlock type. | |
| 23 * @type {!LockScreenUnlockType} | |
| 24 */ | |
| 25 selectedUnlockType: { | |
| 26 type: String, | |
| 27 notify: true, | |
| 28 value: LockScreenUnlockType.VALUE_PENDING | |
| 29 }, | |
| 30 | |
| 31 /** | |
| 32 * True/false if there is a PIN set; undefined if the computation is still | |
| 33 * pending. This is a separate value from selectedUnlockType because the UI | |
| 34 * can change the selectedUnlockType before setting up a PIN. | |
| 35 * @type {boolean|undefined} | |
| 36 */ | |
| 37 hasPin: { | |
|
tommycli
2016/08/05 17:46:19
Maybe this is no longer needed if selecting the la
jdufault
2016/08/05 20:59:52
Right! But unfortunately that's not the desired be
| |
| 38 type: Boolean, | |
| 39 notify: true | |
| 40 } | |
| 41 }, | |
| 42 | |
| 43 /** @override */ | |
| 44 attached: function() { | |
| 45 this.boundOnActiveModesChanged_ = this.updateUnlockType_.bind(this); | |
| 46 chrome.quickUnlockPrivate.onActiveModesChanged.addListener( | |
| 47 this.boundOnActiveModesChanged_); | |
| 48 | |
| 49 this.updateUnlockType_(); | |
| 50 }, | |
| 51 | |
| 52 /** @override */ | |
| 53 detached: function() { | |
| 54 chrome.quickUnlockPrivate.onActiveModesChanged.removeListener( | |
| 55 this.boundOnActiveModesChanged_); | |
| 56 }, | |
| 57 | |
| 58 /** | |
| 59 * Updates the selected unlock type radio group. This function will get called | |
| 60 * after preferences are initialized, after the quick unlock mode has been | |
| 61 * changed, and after the lockscreen preference has changed. | |
| 62 * | |
| 63 * @private | |
| 64 */ | |
| 65 updateUnlockType_: function() { | |
| 66 chrome.quickUnlockPrivate.getActiveModes(function(modes) { | |
| 67 if (modes.includes(chrome.quickUnlockPrivate.QuickUnlockMode.PIN)) { | |
| 68 this.hasPin = true; | |
| 69 this.selectedUnlockType = LockScreenUnlockType.PIN_PASSWORD; | |
| 70 } else { | |
| 71 this.hasPin = false; | |
| 72 this.selectedUnlockType = LockScreenUnlockType.PASSWORD; | |
| 73 } | |
| 74 }.bind(this)); | |
| 75 }, | |
| 76 }; | |
| OLD | NEW |