Chromium Code Reviews| Index: chrome/browser/resources/settings/people_page/lock_screen.js |
| diff --git a/chrome/browser/resources/settings/people_page/lock_screen.js b/chrome/browser/resources/settings/people_page/lock_screen.js |
| index 419671ac46b7f9b5432e6b1023c0b1cfb932051a..9f8afe42ec1aab38c920e9a03d4c20dc0205decf 100644 |
| --- a/chrome/browser/resources/settings/people_page/lock_screen.js |
| +++ b/chrome/browser/resources/settings/people_page/lock_screen.js |
| @@ -17,13 +17,14 @@ |
| Polymer({ |
| is: 'settings-lock-screen', |
| - behaviors: [I18nBehavior, LockStateBehavior, settings.RouteObserverBehavior], |
| + behaviors: [ |
| + I18nBehavior, LockStateBehavior, WebUIListenerBehavior, |
| + settings.RouteObserverBehavior |
| + ], |
| properties: { |
| /** Preferences state. */ |
| - prefs: { |
| - type: Object |
| - }, |
| + prefs: {type: Object}, |
| /** |
| * setModes_ is a partially applied function that stores the previously |
| @@ -33,10 +34,7 @@ Polymer({ |
| * @type {Object|undefined} |
| * @private |
| */ |
| - setModes_: { |
| - type: Object, |
| - observer: 'onSetModesChanged_' |
| - }, |
| + setModes_: {type: Object, observer: 'onSetModesChanged_'}, |
|
stevenjb
2017/04/11 17:29:38
nit: You can force multiple lines here (which I pr
sammiequon
2017/04/11 17:57:11
Done.
|
| /** |
| * writeUma_ is a function that handles writing uma stats. It may be |
| @@ -47,7 +45,9 @@ Polymer({ |
| */ |
| writeUma_: { |
| type: Object, |
| - value: function() { return settings.recordLockScreenProgress; } |
| + value: function() { |
| + return settings.recordLockScreenProgress; |
| + } |
| }, |
| /** |
| @@ -79,10 +79,52 @@ Polymer({ |
| type: Number, |
| value: 0, |
| }, |
| + |
| + /** |
| + * True if Easy Unlock is allowed on this machine. |
| + */ |
| + easyUnlockAllowed_: { |
| + type: Boolean, |
| + value: function() { |
| + return loadTimeData.getBoolean('easyUnlockAllowed'); |
| + }, |
| + readOnly: true, |
| + }, |
| + |
| + /** |
| + * True if Easy Unlock is enabled. |
| + */ |
| + easyUnlockEnabled_: { |
| + type: Boolean, |
| + value: function() { |
| + return loadTimeData.getBoolean('easyUnlockEnabled'); |
| + }, |
| + }, |
| + |
| + /** |
| + * True if Easy Unlock's proximity detection feature is allowed. |
| + */ |
| + easyUnlockProximityDetectionAllowed_: { |
| + type: Boolean, |
| + value: function() { |
| + return loadTimeData.getBoolean('easyUnlockAllowed') && |
| + loadTimeData.getBoolean('easyUnlockProximityDetectionAllowed'); |
| + }, |
| + readOnly: true, |
| + }, |
| + |
| + /** @private */ |
| + showEasyUnlockTurnOffDialog_: { |
| + type: Boolean, |
| + value: false, |
| + }, |
| }, |
| + /** @private {!settings.EasyUnlockBrowserProxy} */ |
| + easyUnlockBrowserProxy_: null, |
| + |
| /** @private {?settings.FingerprintBrowserProxy} */ |
| - browserProxy_: null, |
| + fingerprintBrowserProxy_: null, |
| /** selectedUnlockType is defined in LockStateBehavior. */ |
| observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'], |
| @@ -91,7 +133,19 @@ Polymer({ |
| attached: function() { |
| if (this.shouldAskForPassword_(settings.getCurrentRoute())) |
| this.$.passwordPrompt.open(); |
| - this.browserProxy_ = settings.FingerprintBrowserProxyImpl.getInstance(); |
| + |
| + this.easyUnlockBrowserProxy_ = |
| + settings.EasyUnlockBrowserProxyImpl.getInstance(); |
| + this.fingerprintBrowserProxy_ = |
| + settings.FingerprintBrowserProxyImpl.getInstance(); |
| + |
| + if (this.easyUnlockAllowed_) { |
| + this.addWebUIListener( |
| + 'easy-unlock-enabled-status', |
| + this.handleEasyUnlockEnabledStatusChanged_.bind(this)); |
| + this.easyUnlockBrowserProxy_.getEnabledStatus().then( |
| + this.handleEasyUnlockEnabledStatusChanged_.bind(this)); |
| + } |
| }, |
| /** |
| @@ -102,9 +156,8 @@ Polymer({ |
| */ |
| currentRouteChanged: function(newRoute, oldRoute) { |
| if (newRoute == settings.Route.LOCK_SCREEN && |
| - this.fingerprintUnlockEnabled_ && |
| - this.browserProxy_) { |
| - this.browserProxy_.getNumFingerprints().then( |
| + this.fingerprintUnlockEnabled_ && this.fingerprintBrowserProxy_) { |
| + this.fingerprintBrowserProxy_.getNumFingerprints().then( |
| function(numFingerprints) { |
| this.numFingerprints_ = numFingerprints; |
| }.bind(this)); |
| @@ -206,4 +259,61 @@ Polymer({ |
| shouldAskForPassword_: function(route) { |
| return route == settings.Route.LOCK_SCREEN && !this.setModes_; |
| }, |
| + |
| + /** |
| + * Handler for when the Easy Unlock enabled status has changed. |
| + * @private |
| + */ |
| + handleEasyUnlockEnabledStatusChanged_: function(easyUnlockEnabled) { |
| + this.easyUnlockEnabled_ = easyUnlockEnabled; |
| + this.showEasyUnlockTurnOffDialog_ = |
| + easyUnlockEnabled && this.showEasyUnlockTurnOffDialog_; |
| + }, |
| + |
| + /** @private */ |
| + onEasyUnlockSetupTap_: function() { |
| + this.easyUnlockBrowserProxy_.startTurnOnFlow(); |
| + }, |
| + |
| + /** |
| + * @param {!Event} e |
| + * @private |
| + */ |
| + onEasyUnlockTurnOffTap_: function(e) { |
| + // Prevent the end of the tap event from focusing what is underneath the |
| + // button. |
| + e.preventDefault(); |
| + this.showEasyUnlockTurnOffDialog_ = true; |
| + }, |
| + |
| + /** @private */ |
| + onEasyUnlockTurnOffDialogClose_: function() { |
| + this.showEasyUnlockTurnOffDialog_ = false; |
| + |
| + // Restores focus on close to either the turn-off or set-up button, |
| + // whichever is being displayed. |
| + this.$$('.secondary-button').focus(); |
| + }, |
| + |
| + /** |
| + * @param {boolean} enabled |
| + * @param {!string} enabledStr |
| + * @param {!string} disabledStr |
| + * @private |
| + */ |
| + getEasyUnlockDescription_: function(enabled, enabledStr, disabledStr) { |
| + if (enabled) |
| + return enabledStr; |
| + |
| + return disabledStr; |
|
stevenjb
2017/04/11 17:29:37
nit: return enabled ? enabledStr : disabledStr;
sammiequon
2017/04/11 17:57:11
Done.
|
| + }, |
| + |
| + /** |
| + * @param {boolean} enabled |
|
stevenjb
2017/04/11 17:29:38
nit: easyUnlockEnabled (here and below)
sammiequon
2017/04/11 17:57:10
Done.
|
| + * @param {boolean} proximityDetectionAllowed |
| + * @private |
| + */ |
| + getShowEasyUnlockToggle_: function(enabled, proximityDetectionAllowed) { |
| + return enabled && proximityDetectionAllowed; |
| + }, |
| }); |