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..c534efa10da3d16675379a04d272757d24a8821f 100644 |
| --- a/chrome/browser/resources/settings/people_page/lock_screen.js |
| +++ b/chrome/browser/resources/settings/people_page/lock_screen.js |
| @@ -17,7 +17,12 @@ |
| Polymer({ |
| is: 'settings-lock-screen', |
| - behaviors: [I18nBehavior, LockStateBehavior, settings.RouteObserverBehavior], |
| + behaviors: [ |
| + I18nBehavior, |
| + LockStateBehavior, |
| + WebUIListenerBehavior, |
| + settings.RouteObserverBehavior |
| + ], |
| properties: { |
| /** Preferences state. */ |
| @@ -79,10 +84,57 @@ Polymer({ |
| type: Number, |
| value: 0, |
| }, |
| + |
| + /** @private {!settings.EasyUnlockBrowserProxy} */ |
| + easyUnlockBrowserProxy_: { |
| + type: Object, |
| + value: function() { |
| + return settings.EasyUnlockBrowserProxyImpl.getInstance(); |
| + }, |
| + }, |
| + |
| + /** |
| + * 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.FingerprintBrowserProxy} */ |
| - browserProxy_: null, |
| + fingerprintBrowserProxy_: null, |
| /** selectedUnlockType is defined in LockStateBehavior. */ |
| observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'], |
| @@ -91,7 +143,16 @@ Polymer({ |
| attached: function() { |
| if (this.shouldAskForPassword_(settings.getCurrentRoute())) |
| this.$.passwordPrompt.open(); |
| - this.browserProxy_ = settings.FingerprintBrowserProxyImpl.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)); |
| + } |
| }, |
| /** |
| @@ -103,8 +164,8 @@ Polymer({ |
| currentRouteChanged: function(newRoute, oldRoute) { |
| if (newRoute == settings.Route.LOCK_SCREEN && |
| this.fingerprintUnlockEnabled_ && |
| - this.browserProxy_) { |
| - this.browserProxy_.getNumFingerprints().then( |
| + this.fingerprintBrowserProxy_) { |
| + this.fingerprintBrowserProxy_.getNumFingerprints().then( |
| function(numFingerprints) { |
| this.numFingerprints_ = numFingerprints; |
| }.bind(this)); |
| @@ -206,4 +267,33 @@ 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) { |
| + e.preventDefault(); |
|
jdufault
2017/04/06 21:04:45
Can the preventDefault be removed? Looks like this
sammiequon
2017/04/06 22:23:50
Seems like this is settings-wide thing explicitly
jdufault
2017/04/06 22:31:44
It if clearly breaks w/o e.preventDefault() no com
sammiequon
2017/04/06 23:36:27
Done.
|
| + this.showEasyUnlockTurnOffDialog_ = true; |
| + }, |
| + |
| + /** @private */ |
| + onEasyUnlockTurnOffDialogClose_: function() { |
| + this.showEasyUnlockTurnOffDialog_ = false; |
| + }, |
| }); |