| 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 A dialog allowing the user to turn off the Easy Unlock feature. | 6 * @fileoverview A dialog allowing the user to turn off the Easy Unlock feature. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 (function() { | 9 (function() { |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 'easy-unlock-enabled-status', | 51 'easy-unlock-enabled-status', |
| 52 this.handleEasyUnlockEnabledStatusChanged_.bind(this)); | 52 this.handleEasyUnlockEnabledStatusChanged_.bind(this)); |
| 53 }, | 53 }, |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Opens the dialog. | 56 * Opens the dialog. |
| 57 */ | 57 */ |
| 58 open: function() { | 58 open: function() { |
| 59 this.getTurnOffStatus_().then(function(status) { | 59 this.getTurnOffStatus_().then(function(status) { |
| 60 this.status_ = status; | 60 this.status_ = status; |
| 61 this.$.dialog.open(); | 61 this.$.dialog.showModal(); |
| 62 }.bind(this)); | 62 }.bind(this)); |
| 63 | 63 |
| 64 // The turn off flow status listener should only be active when the dialog | 64 // The turn off flow status listener should only be active when the dialog |
| 65 // is actually open. | 65 // is actually open. |
| 66 assert(this.turnOffStatusWebUiListener_ == null); | 66 assert(this.turnOffStatusWebUiListener_ == null); |
| 67 this.turnOffStatusWebUiListener_ = cr.addWebUIListener( | 67 this.turnOffStatusWebUiListener_ = cr.addWebUIListener( |
| 68 'easy-unlock-turn-off-flow-status', | 68 'easy-unlock-turn-off-flow-status', |
| 69 function(status) { this.status_ = status; }.bind(this)); | 69 function(status) { this.status_ = status; }.bind(this)); |
| 70 }, | 70 }, |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * @return {!Promise<!EasyUnlockTurnOffStatus>} | 73 * @return {!Promise<!EasyUnlockTurnOffStatus>} |
| 74 * @private | 74 * @private |
| 75 */ | 75 */ |
| 76 getTurnOffStatus_: function() { | 76 getTurnOffStatus_: function() { |
| 77 return navigator.onLine ? | 77 return navigator.onLine ? |
| 78 this.browserProxy_.getTurnOffFlowStatus() : | 78 this.browserProxy_.getTurnOffFlowStatus() : |
| 79 Promise.resolve(EasyUnlockTurnOffStatus.OFFLINE); | 79 Promise.resolve(EasyUnlockTurnOffStatus.OFFLINE); |
| 80 }, | 80 }, |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * This dialog listens for Easy Unlock to become disabled. This signals | 83 * This dialog listens for Easy Unlock to become disabled. This signals |
| 84 * that the turnoff process has succeeded. Regardless of whether the turnoff | 84 * that the turnoff process has succeeded. Regardless of whether the turnoff |
| 85 * was initiated from this tab or another, this closes the dialog. | 85 * was initiated from this tab or another, this closes the dialog. |
| 86 * @param {boolean} easyUnlockEnabled | 86 * @param {boolean} easyUnlockEnabled |
| 87 * @private | 87 * @private |
| 88 */ | 88 */ |
| 89 handleEasyUnlockEnabledStatusChanged_: function(easyUnlockEnabled) { | 89 handleEasyUnlockEnabledStatusChanged_: function(easyUnlockEnabled) { |
| 90 var dialog = /** @type {{opened: boolean}} */ this.$.dialog; | 90 var dialog = /** @type {!CrDialogElement} */ this.$.dialog; |
| 91 if (!easyUnlockEnabled && dialog.opened) | 91 if (!easyUnlockEnabled && dialog.open) |
| 92 this.onCancelTap_(); | 92 this.onCancelTap_(); |
| 93 }, | 93 }, |
| 94 | 94 |
| 95 /** @private */ | 95 /** @private */ |
| 96 onCancelTap_: function() { | 96 onCancelTap_: function() { |
| 97 if (this.turnOffStatusWebUiListener_) { | 97 if (this.turnOffStatusWebUiListener_) { |
| 98 cr.removeWebUIListener(this.turnOffStatusWebUiListener_); | 98 cr.removeWebUIListener(this.turnOffStatusWebUiListener_); |
| 99 this.turnOffStatusWebUiListener_ = null; | 99 this.turnOffStatusWebUiListener_ = null; |
| 100 } | 100 } |
| 101 | 101 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 * @return {boolean} | 197 * @return {boolean} |
| 198 * @private | 198 * @private |
| 199 */ | 199 */ |
| 200 isTurnOffButtonEnabled_: function(status) { | 200 isTurnOffButtonEnabled_: function(status) { |
| 201 return status == EasyUnlockTurnOffStatus.IDLE || | 201 return status == EasyUnlockTurnOffStatus.IDLE || |
| 202 status == EasyUnlockTurnOffStatus.SERVER_ERROR; | 202 status == EasyUnlockTurnOffStatus.SERVER_ERROR; |
| 203 }, | 203 }, |
| 204 }); | 204 }); |
| 205 | 205 |
| 206 })(); | 206 })(); |
| OLD | NEW |