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

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

Issue 2984843003: MD Settings: Convert all usages of .bind(this) to use ES6 arrow function. (Closed)
Patch Set: Resolve conflicts. Created 3 years, 5 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 6 * @fileoverview
7 * 7 *
8 * 'settings-password-prompt-dialog' shows a dialog which asks for the user to 8 * 'settings-password-prompt-dialog' shows a dialog which asks for the user to
9 * enter their password. It validates the password is correct. Once the user has 9 * enter their password. It validates the password is correct. Once the user has
10 * entered their account password, the page fires an 'authenticated' event and 10 * entered their account password, the page fires an 'authenticated' event and
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 passwordActiveDurationMs_: { 92 passwordActiveDurationMs_: {
93 type: Number, 93 type: Number,
94 value: PASSWORD_ACTIVE_DURATION_MS, 94 value: PASSWORD_ACTIVE_DURATION_MS,
95 }, 95 },
96 }, 96 },
97 97
98 /** @override */ 98 /** @override */
99 attached: function() { 99 attached: function() {
100 this.writeUma_(LockScreenProgress.START_SCREEN_LOCK); 100 this.writeUma_(LockScreenProgress.START_SCREEN_LOCK);
101 this.$.dialog.showModal(); 101 this.$.dialog.showModal();
102 this.async(function() { 102 this.async(() => {
103 this.$.passwordInput.focus(); 103 this.$.passwordInput.focus();
104 }.bind(this)); 104 });
105 }, 105 },
106 106
107 /** @private */ 107 /** @private */
108 onCancelTap_: function() { 108 onCancelTap_: function() {
109 if (this.$.dialog.open) 109 if (this.$.dialog.open)
110 this.$.dialog.close(); 110 this.$.dialog.close();
111 }, 111 },
112 112
113 /** 113 /**
114 * Called whenever the dialog is closed. 114 * Called whenever the dialog is closed.
(...skipping 21 matching lines...) Expand all
136 // The password might have been cleared during the duration of the 136 // The password might have been cleared during the duration of the
137 // getActiveModes call. 137 // getActiveModes call.
138 this.passwordInvalid_ = !valid && !!this.password_; 138 this.passwordInvalid_ = !valid && !!this.password_;
139 139
140 if (valid) { 140 if (valid) {
141 // Create the |this.setModes| closure and automatically clear it after 141 // Create the |this.setModes| closure and automatically clear it after
142 // |this.passwordActiveDurationMs_|. 142 // |this.passwordActiveDurationMs_|.
143 var password = this.password_; 143 var password = this.password_;
144 this.password_ = ''; 144 this.password_ = '';
145 145
146 this.setModes = function(modes, credentials, onComplete) { 146 this.setModes = (modes, credentials, onComplete) => {
147 this.quickUnlockPrivate_.setModes( 147 this.quickUnlockPrivate_.setModes(
148 password, modes, credentials, onComplete); 148 password, modes, credentials, onComplete);
149 }.bind(this); 149 };
150 150
151 function clearSetModes() { 151 function clearSetModes() {
152 // Reset the password so that any cached references to this.setModes 152 // Reset the password so that any cached references to this.setModes
153 // will fail. 153 // will fail.
154 password = ''; 154 password = '';
155 this.setModes = null; 155 this.setModes = null;
156 } 156 }
157 157
158 this.clearAccountPasswordTimeout_ = setTimeout( 158 this.clearAccountPasswordTimeout_ = setTimeout(
159 clearSetModes.bind(this), this.passwordActiveDurationMs_); 159 clearSetModes.bind(this), this.passwordActiveDurationMs_);
(...skipping 20 matching lines...) Expand all
180 return !!this.password_ && !this.passwordInvalid_; 180 return !!this.password_ && !this.passwordInvalid_;
181 }, 181 },
182 182
183 /** 183 /**
184 * Helper method that checks if the current password is valid. 184 * Helper method that checks if the current password is valid.
185 * @param {function(boolean):void} onCheck 185 * @param {function(boolean):void} onCheck
186 */ 186 */
187 checkAccountPassword_: function(onCheck) { 187 checkAccountPassword_: function(onCheck) {
188 // We check the account password by trying to update the active set of quick 188 // We check the account password by trying to update the active set of quick
189 // unlock modes without changing any credentials. 189 // unlock modes without changing any credentials.
190 this.quickUnlockPrivate_.getActiveModes(function(modes) { 190 this.quickUnlockPrivate_.getActiveModes(modes => {
191 var credentials = 191 var credentials =
192 /** @type {!Array<string>} */ (Array(modes.length).fill('')); 192 /** @type {!Array<string>} */ (Array(modes.length).fill(''));
193 this.quickUnlockPrivate_.setModes( 193 this.quickUnlockPrivate_.setModes(
194 this.password_, modes, credentials, onCheck); 194 this.password_, modes, credentials, onCheck);
195 }.bind(this)); 195 });
196 } 196 }
197 }); 197 });
198 198
199 })(); 199 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698