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

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

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 months 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
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 cr.exportPath('settings'); 9 cr.exportPath('settings');
10 10
11 /** 11 /**
12 * Possible UI statuses for the EasyUnlockTurnOffDialogElement. 12 * Possible UI statuses for the EasyUnlockTurnOffDialogElement.
13 * See easy_unlock_settings_handler.cc. 13 * See easy_unlock_settings_handler.cc.
14 * @enum {string} 14 * @enum {string}
15 */ 15 */
16 settings.EasyUnlockTurnOffStatus = { 16 settings.EasyUnlockTurnOffStatus = {
17 UNKNOWN: 'unknown', 17 UNKNOWN: 'unknown',
18 OFFLINE: 'offline', 18 OFFLINE: 'offline',
19 IDLE: 'idle', 19 IDLE: 'idle',
20 PENDING: 'pending', 20 PENDING: 'pending',
21 SERVER_ERROR: 'server-error', 21 SERVER_ERROR: 'server-error',
22 }; 22 };
23 23
24 (function() { 24 (function() {
25 25
26 Polymer({ 26 Polymer({
27 is: 'easy-unlock-turn-off-dialog', 27 is: 'easy-unlock-turn-off-dialog',
28 28
29 behaviors: [I18nBehavior, WebUIListenerBehavior], 29 behaviors: [I18nBehavior, WebUIListenerBehavior],
30 30
31 properties: { 31 properties: {
32 /** @private {!settings.EasyUnlockTurnOffStatus} */ 32 /** @private {!settings.EasyUnlockTurnOffStatus} */
33 status_: { 33 status_: {
34 type: String, 34 type: String,
35 value: settings.EasyUnlockTurnOffStatus.UNKNOWN, 35 value: settings.EasyUnlockTurnOffStatus.UNKNOWN,
36 },
36 }, 37 },
37 },
38 38
39 /** @private {settings.EasyUnlockBrowserProxy} */ 39 /** @private {settings.EasyUnlockBrowserProxy} */
40 browserProxy_: null, 40 browserProxy_: null,
41 41
42 /** @override */ 42 /** @override */
43 attached: function() { 43 attached: function() {
44 this.browserProxy_ = settings.EasyUnlockBrowserProxyImpl.getInstance(); 44 this.browserProxy_ = settings.EasyUnlockBrowserProxyImpl.getInstance();
45 45
46 this.addWebUIListener( 46 this.addWebUIListener(
47 'easy-unlock-enabled-status', 47 'easy-unlock-enabled-status',
48 this.handleEasyUnlockEnabledStatusChanged_.bind(this)); 48 this.handleEasyUnlockEnabledStatusChanged_.bind(this));
49 49
50 this.addWebUIListener( 50 this.addWebUIListener(
51 'easy-unlock-turn-off-flow-status', 51 'easy-unlock-turn-off-flow-status', function(status) {
52 function(status) { this.status_ = status; }.bind(this)); 52 this.status_ = status;
53 }.bind(this));
53 54
54 // Since the dialog text depends on the status, defer opening until we have 55 // Since the dialog text depends on the status, defer opening until we
55 // retrieved the turn off status to prevent UI flicker. 56 // have
56 this.getTurnOffStatus_().then(function(status) { 57 // retrieved the turn off status to prevent UI flicker.
57 this.status_ = status; 58 this.getTurnOffStatus_().then(function(status) {
58 this.$.dialog.showModal(); 59 this.status_ = status;
59 }.bind(this)); 60 this.$.dialog.showModal();
60 }, 61 }.bind(this));
62 },
61 63
62 /** 64 /**
63 * @return {!Promise<!settings.EasyUnlockTurnOffStatus>} 65 * @return {!Promise<!settings.EasyUnlockTurnOffStatus>}
64 * @private 66 * @private
65 */ 67 */
66 getTurnOffStatus_: function() { 68 getTurnOffStatus_: function() {
67 return navigator.onLine ? 69 return navigator.onLine ?
68 this.browserProxy_.getTurnOffFlowStatus() : 70 this.browserProxy_.getTurnOffFlowStatus() :
69 Promise.resolve(settings.EasyUnlockTurnOffStatus.OFFLINE); 71 Promise.resolve(settings.EasyUnlockTurnOffStatus.OFFLINE);
70 }, 72 },
71 73
72 /** 74 /**
73 * This dialog listens for Easy Unlock to become disabled. This signals 75 * This dialog listens for Easy Unlock to become disabled. This signals
74 * that the turnoff process has succeeded. Regardless of whether the turnoff 76 * that the turnoff process has succeeded. Regardless of whether the turnoff
75 * was initiated from this tab or another, this closes the dialog. 77 * was initiated from this tab or another, this closes the dialog.
76 * @param {boolean} easyUnlockEnabled 78 * @param {boolean} easyUnlockEnabled
77 * @private 79 * @private
78 */ 80 */
79 handleEasyUnlockEnabledStatusChanged_: function(easyUnlockEnabled) { 81 handleEasyUnlockEnabledStatusChanged_: function(easyUnlockEnabled) {
80 var dialog = /** @type {!CrDialogElement} */ this.$.dialog; 82 var dialog = /** @type {!CrDialogElement} */ this.$.dialog;
81 if (!easyUnlockEnabled && dialog.open) 83 if (!easyUnlockEnabled && dialog.open)
82 this.onCancelTap_(); 84 this.onCancelTap_();
83 }, 85 },
84 86
85 /** @private */ 87 /** @private */
86 onCancelTap_: function() { 88 onCancelTap_: function() {
87 this.browserProxy_.cancelTurnOffFlow(); 89 this.browserProxy_.cancelTurnOffFlow();
88 this.$.dialog.close(); 90 this.$.dialog.close();
89 }, 91 },
90 92
91 /** @private */ 93 /** @private */
92 onTurnOffTap_: function() { 94 onTurnOffTap_: function() {
93 this.browserProxy_.startTurnOffFlow(); 95 this.browserProxy_.startTurnOffFlow();
94 }, 96 },
95 97
96 /** 98 /**
97 * @param {!settings.EasyUnlockTurnOffStatus} status 99 * @param {!settings.EasyUnlockTurnOffStatus} status
98 * @return {string} 100 * @return {string}
99 * @private 101 * @private
100 */ 102 */
101 getTitleText_: function(status) { 103 getTitleText_: function(status) {
102 switch (status) { 104 switch (status) {
103 case settings.EasyUnlockTurnOffStatus.OFFLINE: 105 case settings.EasyUnlockTurnOffStatus.OFFLINE:
104 return this.i18n('easyUnlockTurnOffOfflineTitle'); 106 return this.i18n('easyUnlockTurnOffOfflineTitle');
105 case settings.EasyUnlockTurnOffStatus.UNKNOWN: 107 case settings.EasyUnlockTurnOffStatus.UNKNOWN:
106 case settings.EasyUnlockTurnOffStatus.IDLE: 108 case settings.EasyUnlockTurnOffStatus.IDLE:
107 case settings.EasyUnlockTurnOffStatus.PENDING: 109 case settings.EasyUnlockTurnOffStatus.PENDING:
108 return this.i18n('easyUnlockTurnOffTitle'); 110 return this.i18n('easyUnlockTurnOffTitle');
109 case settings.EasyUnlockTurnOffStatus.SERVER_ERROR: 111 case settings.EasyUnlockTurnOffStatus.SERVER_ERROR:
110 return this.i18n('easyUnlockTurnOffErrorTitle'); 112 return this.i18n('easyUnlockTurnOffErrorTitle');
111 } 113 }
112 assertNotReached(); 114 assertNotReached();
113 }, 115 },
114 116
115 /** 117 /**
116 * @param {!settings.EasyUnlockTurnOffStatus} status 118 * @param {!settings.EasyUnlockTurnOffStatus} status
117 * @return {string} 119 * @return {string}
118 * @private 120 * @private
119 */ 121 */
120 getDescriptionText_: function(status) { 122 getDescriptionText_: function(status) {
121 switch (status) { 123 switch (status) {
122 case settings.EasyUnlockTurnOffStatus.OFFLINE: 124 case settings.EasyUnlockTurnOffStatus.OFFLINE:
123 return this.i18n('easyUnlockTurnOffOfflineMessage'); 125 return this.i18n('easyUnlockTurnOffOfflineMessage');
124 case settings.EasyUnlockTurnOffStatus.UNKNOWN: 126 case settings.EasyUnlockTurnOffStatus.UNKNOWN:
125 case settings.EasyUnlockTurnOffStatus.IDLE: 127 case settings.EasyUnlockTurnOffStatus.IDLE:
126 case settings.EasyUnlockTurnOffStatus.PENDING: 128 case settings.EasyUnlockTurnOffStatus.PENDING:
127 return this.i18n('easyUnlockTurnOffDescription'); 129 return this.i18n('easyUnlockTurnOffDescription');
128 case settings.EasyUnlockTurnOffStatus.SERVER_ERROR: 130 case settings.EasyUnlockTurnOffStatus.SERVER_ERROR:
129 return this.i18n('easyUnlockTurnOffErrorMessage'); 131 return this.i18n('easyUnlockTurnOffErrorMessage');
130 } 132 }
131 assertNotReached(); 133 assertNotReached();
132 }, 134 },
133 135
134 /** 136 /**
135 * @param {!settings.EasyUnlockTurnOffStatus} status 137 * @param {!settings.EasyUnlockTurnOffStatus} status
136 * @return {string} 138 * @return {string}
137 * @private 139 * @private
138 */ 140 */
139 getTurnOffButtonText_: function(status) { 141 getTurnOffButtonText_: function(status) {
140 switch (status) { 142 switch (status) {
141 case settings.EasyUnlockTurnOffStatus.OFFLINE: 143 case settings.EasyUnlockTurnOffStatus.OFFLINE:
142 return ''; 144 return '';
143 case settings.EasyUnlockTurnOffStatus.UNKNOWN: 145 case settings.EasyUnlockTurnOffStatus.UNKNOWN:
144 case settings.EasyUnlockTurnOffStatus.IDLE: 146 case settings.EasyUnlockTurnOffStatus.IDLE:
145 case settings.EasyUnlockTurnOffStatus.PENDING: 147 case settings.EasyUnlockTurnOffStatus.PENDING:
146 return this.i18n('easyUnlockTurnOffButton'); 148 return this.i18n('easyUnlockTurnOffButton');
147 case settings.EasyUnlockTurnOffStatus.SERVER_ERROR: 149 case settings.EasyUnlockTurnOffStatus.SERVER_ERROR:
148 return this.i18n('easyUnlockTurnOffRetryButton'); 150 return this.i18n('easyUnlockTurnOffRetryButton');
149 } 151 }
150 assertNotReached(); 152 assertNotReached();
151 }, 153 },
152 154
153 /** 155 /**
154 * @param {!settings.EasyUnlockTurnOffStatus} status 156 * @param {!settings.EasyUnlockTurnOffStatus} status
155 * @return {boolean} 157 * @return {boolean}
156 * @private 158 * @private
157 */ 159 */
158 isButtonBarHidden_: function(status) { 160 isButtonBarHidden_: function(status) {
159 return status == settings.EasyUnlockTurnOffStatus.OFFLINE; 161 return status == settings.EasyUnlockTurnOffStatus.OFFLINE;
160 }, 162 },
161 163
162 /** 164 /**
163 * @param {!settings.EasyUnlockTurnOffStatus} status 165 * @param {!settings.EasyUnlockTurnOffStatus} status
164 * @return {boolean} 166 * @return {boolean}
165 * @private 167 * @private
166 */ 168 */
167 isSpinnerActive_: function(status) { 169 isSpinnerActive_: function(status) {
168 return status == settings.EasyUnlockTurnOffStatus.PENDING; 170 return status == settings.EasyUnlockTurnOffStatus.PENDING;
169 }, 171 },
170 172
171 /** 173 /**
172 * @param {!settings.EasyUnlockTurnOffStatus} status 174 * @param {!settings.EasyUnlockTurnOffStatus} status
173 * @return {boolean} 175 * @return {boolean}
174 * @private 176 * @private
175 */ 177 */
176 isCancelButtonHidden_: function(status) { 178 isCancelButtonHidden_: function(status) {
177 return status == settings.EasyUnlockTurnOffStatus.SERVER_ERROR; 179 return status == settings.EasyUnlockTurnOffStatus.SERVER_ERROR;
178 }, 180 },
179 181
180 /** 182 /**
181 * @param {!settings.EasyUnlockTurnOffStatus} status 183 * @param {!settings.EasyUnlockTurnOffStatus} status
182 * @return {boolean} 184 * @return {boolean}
183 * @private 185 * @private
184 */ 186 */
185 isTurnOffButtonEnabled_: function(status) { 187 isTurnOffButtonEnabled_: function(status) {
186 return status == settings.EasyUnlockTurnOffStatus.IDLE || 188 return status == settings.EasyUnlockTurnOffStatus.IDLE ||
187 status == settings.EasyUnlockTurnOffStatus.SERVER_ERROR; 189 status == settings.EasyUnlockTurnOffStatus.SERVER_ERROR;
188 }, 190 },
189 }); 191 });
190 192
191 })(); 193 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698