Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/browser/resources/settings/people_page/easy_unlock_turn_off_dialog.js

Issue 2539733004: MD Settings: Overhaul Easy Unlock Turn Off Dialog. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/settings/people_page/people_page.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 SERVER_ERROR: 'server-error', 21 SERVER_ERROR: 'server-error',
22 }; 22 };
23 23
24 Polymer({ 24 Polymer({
25 is: 'easy-unlock-turn-off-dialog', 25 is: 'easy-unlock-turn-off-dialog',
26 26
27 behaviors: [I18nBehavior, WebUIListenerBehavior], 27 behaviors: [I18nBehavior, WebUIListenerBehavior],
28 28
29 properties: { 29 properties: {
30 /** @private {!settings.EasyUnlockBrowserProxy} */ 30 /** @private {!settings.EasyUnlockBrowserProxy} */
31 browserProxy_: Object, 31 browserProxy_: {
dpapad 2016/11/30 20:07:44 FWIW, we've started being OK with declaring browse
tommycli 2016/11/30 20:19:29 Done.
32 type: Object,
33 value: function() {
34 return settings.EasyUnlockBrowserProxyImpl.getInstance();
35 }
36 },
32 37
33 /** @private {!EasyUnlockTurnOffStatus} */ 38 /** @private {!EasyUnlockTurnOffStatus} */
34 status_: { 39 status_: {
35 type: String, 40 type: String,
36 value: EasyUnlockTurnOffStatus.UNKNOWN, 41 value: EasyUnlockTurnOffStatus.UNKNOWN,
37 }, 42 },
38
39 /** @private {?WebUIListener} */
40 turnOffStatusWebUiListener_: {
41 type: Object,
42 value: null,
43 },
44 }, 43 },
45 44
46 /** @override */ 45 /** @override */
47 ready: function() { 46 attached: function() {
48 this.browserProxy_ = settings.EasyUnlockBrowserProxyImpl.getInstance();
49
50 this.addWebUIListener( 47 this.addWebUIListener(
51 'easy-unlock-enabled-status', 48 'easy-unlock-enabled-status',
52 this.handleEasyUnlockEnabledStatusChanged_.bind(this)); 49 this.handleEasyUnlockEnabledStatusChanged_.bind(this));
53 },
54 50
55 /** 51 this.addWebUIListener(
56 * Opens the dialog. 52 'easy-unlock-turn-off-flow-status',
57 */ 53 function(status) { this.status_ = status; }.bind(this));
58 open: function() { 54
55 // Since the dialog text depends on the status, defer opening until we have
56 // retrieved the turn off status to prevent UI flicker.
59 this.getTurnOffStatus_().then(function(status) { 57 this.getTurnOffStatus_().then(function(status) {
60 this.status_ = status; 58 this.status_ = status;
61 this.$.dialog.showModal(); 59 this.$.dialog.showModal();
62 }.bind(this)); 60 }.bind(this));
63
64 // The turn off flow status listener should only be active when the dialog
65 // is actually open.
66 assert(this.turnOffStatusWebUiListener_ == null);
67 this.turnOffStatusWebUiListener_ = cr.addWebUIListener(
68 'easy-unlock-turn-off-flow-status',
69 function(status) { this.status_ = status; }.bind(this));
70 }, 61 },
71 62
72 /** 63 /**
73 * @return {!Promise<!EasyUnlockTurnOffStatus>} 64 * @return {!Promise<!EasyUnlockTurnOffStatus>}
74 * @private 65 * @private
75 */ 66 */
76 getTurnOffStatus_: function() { 67 getTurnOffStatus_: function() {
77 return navigator.onLine ? 68 return navigator.onLine ?
78 this.browserProxy_.getTurnOffFlowStatus() : 69 this.browserProxy_.getTurnOffFlowStatus() :
79 Promise.resolve(EasyUnlockTurnOffStatus.OFFLINE); 70 Promise.resolve(EasyUnlockTurnOffStatus.OFFLINE);
80 }, 71 },
81 72
82 /** 73 /**
83 * This dialog listens for Easy Unlock to become disabled. This signals 74 * This dialog listens for Easy Unlock to become disabled. This signals
84 * that the turnoff process has succeeded. Regardless of whether the turnoff 75 * that the turnoff process has succeeded. Regardless of whether the turnoff
85 * was initiated from this tab or another, this closes the dialog. 76 * was initiated from this tab or another, this closes the dialog.
86 * @param {boolean} easyUnlockEnabled 77 * @param {boolean} easyUnlockEnabled
87 * @private 78 * @private
88 */ 79 */
89 handleEasyUnlockEnabledStatusChanged_: function(easyUnlockEnabled) { 80 handleEasyUnlockEnabledStatusChanged_: function(easyUnlockEnabled) {
90 var dialog = /** @type {!CrDialogElement} */ this.$.dialog; 81 var dialog = /** @type {!CrDialogElement} */ this.$.dialog;
91 if (!easyUnlockEnabled && dialog.open) 82 if (!easyUnlockEnabled && dialog.open)
92 this.onCancelTap_(); 83 this.onCancelTap_();
93 }, 84 },
94 85
95 /** @private */ 86 /** @private */
96 onCancelTap_: function() { 87 onCancelTap_: function() {
97 if (this.turnOffStatusWebUiListener_) {
98 cr.removeWebUIListener(this.turnOffStatusWebUiListener_);
99 this.turnOffStatusWebUiListener_ = null;
100 }
101
102 this.browserProxy_.cancelTurnOffFlow(); 88 this.browserProxy_.cancelTurnOffFlow();
103 this.$.dialog.close(); 89 this.$.dialog.close();
104 }, 90 },
105 91
106 /** @private */ 92 /** @private */
107 onTurnOffTap_: function() { 93 onTurnOffTap_: function() {
108 this.browserProxy_.startTurnOffFlow(); 94 this.browserProxy_.startTurnOffFlow();
109 }, 95 },
110 96
111 /** 97 /**
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 * @return {boolean} 183 * @return {boolean}
198 * @private 184 * @private
199 */ 185 */
200 isTurnOffButtonEnabled_: function(status) { 186 isTurnOffButtonEnabled_: function(status) {
201 return status == EasyUnlockTurnOffStatus.IDLE || 187 return status == EasyUnlockTurnOffStatus.IDLE ||
202 status == EasyUnlockTurnOffStatus.SERVER_ERROR; 188 status == EasyUnlockTurnOffStatus.SERVER_ERROR;
203 }, 189 },
204 }); 190 });
205 191
206 })(); 192 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/settings/people_page/people_page.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698