| 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 * 'settings-lock-screen' allows the user to change how they unlock their | 7 * 'settings-lock-screen' allows the user to change how they unlock their |
| 8 * device. | 8 * device. |
| 9 * | 9 * |
| 10 * Example: | 10 * Example: |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 }, | 82 }, |
| 83 | 83 |
| 84 /** @private {?settings.FingerprintBrowserProxy} */ | 84 /** @private {?settings.FingerprintBrowserProxy} */ |
| 85 browserProxy_: null, | 85 browserProxy_: null, |
| 86 | 86 |
| 87 /** selectedUnlockType is defined in LockStateBehavior. */ | 87 /** selectedUnlockType is defined in LockStateBehavior. */ |
| 88 observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'], | 88 observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'], |
| 89 | 89 |
| 90 /** @override */ | 90 /** @override */ |
| 91 attached: function() { | 91 attached: function() { |
| 92 // currentRouteChanged is not called during the initial navigation. If the | 92 if (this.shouldAskForPassword_(settings.getCurrentRoute())) |
| 93 // user navigates directly to the lockScreen page, we still want to show the | 93 this.$.passwordPrompt.open(); |
| 94 // password prompt page. | |
| 95 this.currentRouteChanged(settings.Route.LOCK_SCREEN, | |
| 96 settings.Route.LOCK_SCREEN); | |
| 97 this.browserProxy_ = settings.FingerprintBrowserProxyImpl.getInstance(); | 94 this.browserProxy_ = settings.FingerprintBrowserProxyImpl.getInstance(); |
| 98 }, | 95 }, |
| 99 | 96 |
| 100 /** | 97 /** |
| 101 * Overridden from settings.RouteObserverBehavior. | 98 * Overridden from settings.RouteObserverBehavior. |
| 102 * @param {!settings.Route} newRoute | 99 * @param {!settings.Route} newRoute |
| 103 * @param {!settings.Route} oldRoute | 100 * @param {!settings.Route} oldRoute |
| 104 * @protected | 101 * @protected |
| 105 */ | 102 */ |
| 106 currentRouteChanged: function(newRoute, oldRoute) { | 103 currentRouteChanged: function(newRoute, oldRoute) { |
| 107 if (newRoute == settings.Route.LOCK_SCREEN && | 104 if (newRoute == settings.Route.LOCK_SCREEN && |
| 108 this.fingerprintUnlockEnabled_ && | 105 this.fingerprintUnlockEnabled_ && |
| 109 this.browserProxy_) { | 106 this.browserProxy_) { |
| 110 this.browserProxy_.getNumFingerprints().then( | 107 this.browserProxy_.getNumFingerprints().then( |
| 111 function(numFingerprints) { | 108 function(numFingerprints) { |
| 112 this.numFingerprints_ = numFingerprints; | 109 this.numFingerprints_ = numFingerprints; |
| 113 }.bind(this)); | 110 }.bind(this)); |
| 114 } | 111 } |
| 115 | 112 |
| 116 if (newRoute == settings.Route.LOCK_SCREEN && !this.setModes_) { | 113 if (this.shouldAskForPassword_(newRoute)) { |
| 117 this.$.passwordPrompt.open(); | 114 this.$.passwordPrompt.open(); |
| 118 } else if (newRoute != settings.Route.FINGERPRINT && | 115 } else if (newRoute != settings.Route.FINGERPRINT && |
| 119 oldRoute != settings.Route.FINGERPRINT) { | 116 oldRoute != settings.Route.FINGERPRINT) { |
| 120 // If the user navigated away from the lock screen settings page they will | 117 // If the user navigated away from the lock screen settings page they will |
| 121 // have to re-enter their password. An exception is if they are navigating | 118 // have to re-enter their password. An exception is if they are navigating |
| 122 // to or from the fingerprint subpage. | 119 // to or from the fingerprint subpage. |
| 123 this.setModes_ = undefined; | 120 this.setModes_ = undefined; |
| 124 } | 121 } |
| 125 }, | 122 }, |
| 126 | 123 |
| 127 /** | 124 /** |
| 128 * Called when the unlock type has changed. | 125 * Called when the unlock type has changed. |
| 129 * @param {!string} selected The current unlock type. | 126 * @param {!string} selected The current unlock type. |
| 130 * @private | 127 * @private |
| 131 */ | 128 */ |
| 132 selectedUnlockTypeChanged_: function(selected) { | 129 selectedUnlockTypeChanged_: function(selected) { |
| 133 if (selected == LockScreenUnlockType.VALUE_PENDING) | 130 if (selected == LockScreenUnlockType.VALUE_PENDING) |
| 134 return; | 131 return; |
| 135 | 132 |
| 136 if (selected != LockScreenUnlockType.PIN_PASSWORD && this.setModes_) { | 133 if (selected != LockScreenUnlockType.PIN_PASSWORD && this.setModes_) { |
| 137 this.setModes_.call(null, [], [], function(didSet) { | 134 this.setModes_.call(null, [], [], function(didSet) { |
| 138 assert(didSet, 'Failed to clear quick unlock modes'); | 135 assert(didSet, 'Failed to clear quick unlock modes'); |
| 139 }); | 136 }); |
| 140 } | 137 } |
| 141 }, | 138 }, |
| 142 | 139 |
| 143 /** @private */ | 140 /** @private */ |
| 144 onSetModesChanged_: function() { | 141 onSetModesChanged_: function() { |
| 145 if (settings.getCurrentRoute() == settings.Route.LOCK_SCREEN && | 142 if (this.shouldAskForPassword_(settings.getCurrentRoute())) { |
| 146 !this.setModes_) { | |
| 147 this.$.setupPin.close(); | 143 this.$.setupPin.close(); |
| 148 this.$.passwordPrompt.open(); | 144 this.$.passwordPrompt.open(); |
| 149 } | 145 } |
| 150 }, | 146 }, |
| 151 | 147 |
| 152 /** @private */ | 148 /** @private */ |
| 153 onPasswordClosed_: function() { | 149 onPasswordClosed_: function() { |
| 154 if (!this.setModes_) | 150 if (!this.setModes_) |
| 155 settings.navigateTo(settings.Route.PEOPLE); | 151 settings.navigateTo(settings.Route.PEOPLE); |
| 156 }, | 152 }, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 onConfigurePin_: function(e) { | 190 onConfigurePin_: function(e) { |
| 195 e.preventDefault(); | 191 e.preventDefault(); |
| 196 this.$.setupPin.open(); | 192 this.$.setupPin.open(); |
| 197 this.writeUma_(LockScreenProgress.CHOOSE_PIN_OR_PASSWORD); | 193 this.writeUma_(LockScreenProgress.CHOOSE_PIN_OR_PASSWORD); |
| 198 }, | 194 }, |
| 199 | 195 |
| 200 /** @private */ | 196 /** @private */ |
| 201 onEditFingerprints_: function() { | 197 onEditFingerprints_: function() { |
| 202 settings.navigateTo(settings.Route.FINGERPRINT); | 198 settings.navigateTo(settings.Route.FINGERPRINT); |
| 203 }, | 199 }, |
| 200 |
| 201 /** |
| 202 * @param {!settings.Route} route |
| 203 * @return {boolean} Whether the password dialog should be shown. |
| 204 * @private |
| 205 */ |
| 206 shouldAskForPassword_: function(route) { |
| 207 return route == settings.Route.LOCK_SCREEN && !this.setModes_; |
| 208 }, |
| 204 }); | 209 }); |
| OLD | NEW |