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

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

Issue 2882143003: MD Settings: Improve Sync Page Enter key handling. (Closed)
Patch Set: fix type def Created 3 years, 7 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
« no previous file with comments | « chrome/browser/resources/settings/people_page/sync_page.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 (function() { 5 (function() {
6 6
7 /** 7 /**
8 * Names of the radio buttons which allow the user to choose their encryption 8 * Names of the radio buttons which allow the user to choose their encryption
9 * mechanism. 9 * mechanism.
10 * @enum {string} 10 * @enum {string}
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 * @return {boolean} Whether the passphrase save button should be enabled. 286 * @return {boolean} Whether the passphrase save button should be enabled.
287 * @private 287 * @private
288 */ 288 */
289 isSaveNewPassphraseEnabled_: function(passphrase, confirmation) { 289 isSaveNewPassphraseEnabled_: function(passphrase, confirmation) {
290 return passphrase !== '' && confirmation !== ''; 290 return passphrase !== '' && confirmation !== '';
291 }, 291 },
292 292
293 /** 293 /**
294 * Sends the newly created custom sync passphrase to the browser. 294 * Sends the newly created custom sync passphrase to the browser.
295 * @private 295 * @private
296 * @param {Event} e
296 */ 297 */
297 onSaveNewPassphraseTap_: function() { 298 onSaveNewPassphraseTap_: function(e) {
298 assert(this.creatingNewPassphrase_); 299 assert(this.creatingNewPassphrase_);
299 300
301 // Ignore events on irrevelant elements or with irrelevant keys.
302 if (e.target.tagName != 'PAPER-BUTTON' && e.target.tagName != 'PAPER-INPUT')
303 return;
304 if (e.type == 'keypress' && e.key != 'Enter')
305 return;
306
300 // If a new password has been entered but it is invalid, do not send the 307 // If a new password has been entered but it is invalid, do not send the
301 // sync state to the API. 308 // sync state to the API.
302 if (!this.validateCreatedPassphrases_()) 309 if (!this.validateCreatedPassphrases_())
303 return; 310 return;
304 311
305 this.syncPrefs.encryptAllData = true; 312 this.syncPrefs.encryptAllData = true;
306 this.syncPrefs.setNewPassphrase = true; 313 this.syncPrefs.setNewPassphrase = true;
307 this.syncPrefs.passphrase = this.passphrase_; 314 this.syncPrefs.passphrase = this.passphrase_;
308 315
309 this.browserProxy_.setSyncEncryption(this.syncPrefs).then( 316 this.browserProxy_.setSyncEncryption(this.syncPrefs).then(
310 this.handlePageStatusChanged_.bind(this)); 317 this.handlePageStatusChanged_.bind(this));
311 }, 318 },
312 319
313 /** 320 /**
314 * Sends the user-entered existing password to re-enable sync. 321 * Sends the user-entered existing password to re-enable sync.
315 * @private 322 * @private
323 * @param {Event} e
316 */ 324 */
317 onSubmitExistingPassphraseTap_: function() { 325 onSubmitExistingPassphraseTap_: function(e) {
326 if (e.type == 'keypress' && e.key != 'Enter')
327 return;
328
318 assert(!this.creatingNewPassphrase_); 329 assert(!this.creatingNewPassphrase_);
319 330
320 this.syncPrefs.setNewPassphrase = false; 331 this.syncPrefs.setNewPassphrase = false;
321 332
322 this.syncPrefs.passphrase = this.existingPassphrase_; 333 this.syncPrefs.passphrase = this.existingPassphrase_;
323 this.existingPassphrase_ = ''; 334 this.existingPassphrase_ = '';
324 335
325 this.browserProxy_.setSyncEncryption(this.syncPrefs).then( 336 this.browserProxy_.setSyncEncryption(this.syncPrefs).then(
326 this.handlePageStatusChanged_.bind(this)); 337 this.handlePageStatusChanged_.bind(this));
327 }, 338 },
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 onLearnMoreTap_: function(event) { 438 onLearnMoreTap_: function(event) {
428 if (event.target.tagName == 'A') { 439 if (event.target.tagName == 'A') {
429 // Stop the propagation of events, so that clicking on links inside 440 // Stop the propagation of events, so that clicking on links inside
430 // checkboxes or radio buttons won't change the value. 441 // checkboxes or radio buttons won't change the value.
431 event.stopPropagation(); 442 event.stopPropagation();
432 } 443 }
433 } 444 }
434 }); 445 });
435 446
436 })(); 447 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/people_page/sync_page.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698