Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 {!{target: !{tagName: string}, | |
| 297 * type: string, | |
| 298 * key: (string|undefined)}} e | |
|
Dan Beam
2017/05/16 02:20:55
KeyboardEvent?
tommycli
2017/05/16 16:17:53
Done. I used Event because it could be a mouse eve
| |
| 296 */ | 299 */ |
| 297 onSaveNewPassphraseTap_: function() { | 300 onSaveNewPassphraseTap_: function(e) { |
| 298 assert(this.creatingNewPassphrase_); | 301 assert(this.creatingNewPassphrase_); |
| 299 | 302 |
| 303 // Ignore events on irrevelant elements or with irrelevant keys. | |
| 304 if (e.target.tagName != 'PAPER-BUTTON' && e.target.tagName != 'PAPER-INPUT') | |
| 305 return; | |
| 306 if (e.type == 'keypress' && e.key != 'Enter') | |
| 307 return; | |
| 308 | |
| 300 // If a new password has been entered but it is invalid, do not send the | 309 // If a new password has been entered but it is invalid, do not send the |
| 301 // sync state to the API. | 310 // sync state to the API. |
| 302 if (!this.validateCreatedPassphrases_()) | 311 if (!this.validateCreatedPassphrases_()) |
| 303 return; | 312 return; |
| 304 | 313 |
| 305 this.syncPrefs.encryptAllData = true; | 314 this.syncPrefs.encryptAllData = true; |
| 306 this.syncPrefs.setNewPassphrase = true; | 315 this.syncPrefs.setNewPassphrase = true; |
| 307 this.syncPrefs.passphrase = this.passphrase_; | 316 this.syncPrefs.passphrase = this.passphrase_; |
| 308 | 317 |
| 309 this.browserProxy_.setSyncEncryption(this.syncPrefs).then( | 318 this.browserProxy_.setSyncEncryption(this.syncPrefs).then( |
| 310 this.handlePageStatusChanged_.bind(this)); | 319 this.handlePageStatusChanged_.bind(this)); |
| 311 }, | 320 }, |
| 312 | 321 |
| 313 /** | 322 /** |
| 314 * Sends the user-entered existing password to re-enable sync. | 323 * Sends the user-entered existing password to re-enable sync. |
| 315 * @private | 324 * @private |
| 325 * @param {Event} e | |
| 316 */ | 326 */ |
| 317 onSubmitExistingPassphraseTap_: function() { | 327 onSubmitExistingPassphraseTap_: function(e) { |
| 328 if (e.type == 'keypress' && e.key != 'Enter') | |
| 329 return; | |
| 330 | |
| 318 assert(!this.creatingNewPassphrase_); | 331 assert(!this.creatingNewPassphrase_); |
| 319 | 332 |
| 320 this.syncPrefs.setNewPassphrase = false; | 333 this.syncPrefs.setNewPassphrase = false; |
| 321 | 334 |
| 322 this.syncPrefs.passphrase = this.existingPassphrase_; | 335 this.syncPrefs.passphrase = this.existingPassphrase_; |
| 323 this.existingPassphrase_ = ''; | 336 this.existingPassphrase_ = ''; |
| 324 | 337 |
| 325 this.browserProxy_.setSyncEncryption(this.syncPrefs).then( | 338 this.browserProxy_.setSyncEncryption(this.syncPrefs).then( |
| 326 this.handlePageStatusChanged_.bind(this)); | 339 this.handlePageStatusChanged_.bind(this)); |
| 327 }, | 340 }, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 onLearnMoreTap_: function(event) { | 440 onLearnMoreTap_: function(event) { |
| 428 if (event.target.tagName == 'A') { | 441 if (event.target.tagName == 'A') { |
| 429 // Stop the propagation of events, so that clicking on links inside | 442 // Stop the propagation of events, so that clicking on links inside |
| 430 // checkboxes or radio buttons won't change the value. | 443 // checkboxes or radio buttons won't change the value. |
| 431 event.stopPropagation(); | 444 event.stopPropagation(); |
| 432 } | 445 } |
| 433 } | 446 } |
| 434 }); | 447 }); |
| 435 | 448 |
| 436 })(); | 449 })(); |
| OLD | NEW |