| 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * Contains utilities that help identify the current way that the lock screen | 7 * Contains utilities that help identify the current way that the lock screen |
| 8 * will be displayed. | 8 * will be displayed. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * True/false if there is a PIN set; undefined if the computation is still | 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 | 33 * pending. This is a separate value from selectedUnlockType because the UI |
| 34 * can change the selectedUnlockType before setting up a PIN. | 34 * can change the selectedUnlockType before setting up a PIN. |
| 35 * @type {boolean|undefined} | 35 * @type {boolean|undefined} |
| 36 */ | 36 */ |
| 37 hasPin: { | 37 hasPin: { |
| 38 type: Boolean, | 38 type: Boolean, |
| 39 notify: true | 39 notify: true |
| 40 } | 40 }, |
| 41 |
| 42 /** |
| 43 * Interface for chrome.quickUnlockPrivate calls. May be overriden by tests. |
| 44 * @private |
| 45 */ |
| 46 quickUnlockPrivate_: { |
| 47 type: Object, |
| 48 value: chrome.quickUnlockPrivate |
| 49 }, |
| 41 }, | 50 }, |
| 42 | 51 |
| 43 /** @override */ | 52 /** @override */ |
| 44 attached: function() { | 53 attached: function() { |
| 45 this.boundOnActiveModesChanged_ = this.updateUnlockType_.bind(this); | 54 this.boundOnActiveModesChanged_ = this.updateUnlockType_.bind(this); |
| 46 chrome.quickUnlockPrivate.onActiveModesChanged.addListener( | 55 this.quickUnlockPrivate_.onActiveModesChanged.addListener( |
| 47 this.boundOnActiveModesChanged_); | 56 this.boundOnActiveModesChanged_); |
| 48 | 57 |
| 49 this.updateUnlockType_(); | 58 this.updateUnlockType_(); |
| 50 }, | 59 }, |
| 51 | 60 |
| 52 /** @override */ | 61 /** @override */ |
| 53 detached: function() { | 62 detached: function() { |
| 54 chrome.quickUnlockPrivate.onActiveModesChanged.removeListener( | 63 this.quickUnlockPrivate_.onActiveModesChanged.removeListener( |
| 55 this.boundOnActiveModesChanged_); | 64 this.boundOnActiveModesChanged_); |
| 56 }, | 65 }, |
| 57 | 66 |
| 58 /** | 67 /** |
| 59 * Updates the selected unlock type radio group. This function will get called | 68 * Updates the selected unlock type radio group. This function will get called |
| 60 * after preferences are initialized, after the quick unlock mode has been | 69 * after preferences are initialized, after the quick unlock mode has been |
| 61 * changed, and after the lockscreen preference has changed. | 70 * changed, and after the lockscreen preference has changed. |
| 62 * | 71 * |
| 63 * @private | 72 * @private |
| 64 */ | 73 */ |
| 65 updateUnlockType_: function() { | 74 updateUnlockType_: function() { |
| 66 chrome.quickUnlockPrivate.getActiveModes(function(modes) { | 75 this.quickUnlockPrivate_.getActiveModes(function(modes) { |
| 67 if (modes.includes(chrome.quickUnlockPrivate.QuickUnlockMode.PIN)) { | 76 if (modes.includes(chrome.quickUnlockPrivate.QuickUnlockMode.PIN)) { |
| 68 this.hasPin = true; | 77 this.hasPin = true; |
| 69 this.selectedUnlockType = LockScreenUnlockType.PIN_PASSWORD; | 78 this.selectedUnlockType = LockScreenUnlockType.PIN_PASSWORD; |
| 70 } else { | 79 } else { |
| 71 this.hasPin = false; | 80 this.hasPin = false; |
| 72 this.selectedUnlockType = LockScreenUnlockType.PASSWORD; | 81 this.selectedUnlockType = LockScreenUnlockType.PASSWORD; |
| 73 } | 82 } |
| 74 }.bind(this)); | 83 }.bind(this)); |
| 75 }, | 84 }, |
| 76 }; | 85 }; |
| OLD | NEW |