| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 const OptionsPage = options.OptionsPage; | 6 const OptionsPage = options.OptionsPage; |
| 7 | 7 |
| 8 // Variable to track if a captcha challenge was issued. If this gets set to | 8 // Variable to track if a captcha challenge was issued. If this gets set to |
| 9 // true, it stays that way until we are told about successful login from | 9 // true, it stays that way until we are told about successful login from |
| 10 // the browser. This means subsequent errors (like invalid password) are | 10 // the browser. This means subsequent errors (like invalid password) are |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 365 |
| 366 // Called once, when this html/js is loaded. | 366 // Called once, when this html/js is loaded. |
| 367 showConfigure_: function(args) { | 367 showConfigure_: function(args) { |
| 368 var datatypeSelect = document.getElementById('sync-select-datatypes'); | 368 var datatypeSelect = document.getElementById('sync-select-datatypes'); |
| 369 var self = this; | 369 var self = this; |
| 370 datatypeSelect.onchange = function() { | 370 datatypeSelect.onchange = function() { |
| 371 var syncAll = this.selectedIndex == 0; | 371 var syncAll = this.selectedIndex == 0; |
| 372 self.setCheckboxesToKeepEverythingSynced_(syncAll); | 372 self.setCheckboxesToKeepEverythingSynced_(syncAll); |
| 373 }; | 373 }; |
| 374 | 374 |
| 375 this.resetPage_('sync-setup-configure'); |
| 375 $('sync-setup-configure').hidden = false; | 376 $('sync-setup-configure').hidden = false; |
| 376 | 377 |
| 377 this.clearPassphraseInputs_(); | |
| 378 | |
| 379 if (args) { | 378 if (args) { |
| 380 if (!args['encryptionEnabled']) | 379 if (!args['encryptionEnabled']) |
| 381 $('customize-sync-encryption').hidden = true; | 380 $('customize-sync-encryption').hidden = true; |
| 382 this.setCheckboxesAndErrors_(args); | 381 this.setCheckboxesAndErrors_(args); |
| 383 | 382 |
| 384 // Whether to display the 'Sync everything' confirmation page or the | 383 // Whether to display the 'Sync everything' confirmation page or the |
| 385 // customize data types page. | 384 // customize data types page. |
| 386 var keepEverythingSynced = args['keepEverythingSynced']; | 385 var keepEverythingSynced = args['keepEverythingSynced']; |
| 387 this.usePassphrase_ = args['usePassphrase']; | 386 this.usePassphrase_ = args['usePassphrase']; |
| 388 if (args['showSyncEverythingPage'] == false || this.usePassphrase_ || | 387 if (args['showSyncEverythingPage'] == false || this.usePassphrase_ || |
| 389 keepEverythingSynced == false || args['show_passphrase']) { | 388 keepEverythingSynced == false || args['show_passphrase']) { |
| 390 this.showCustomizePage_(args, keepEverythingSynced); | 389 this.showCustomizePage_(args, keepEverythingSynced); |
| 391 } else { | 390 } else { |
| 392 this.showSyncEverythingPage_(); | 391 this.showSyncEverythingPage_(); |
| 393 } | 392 } |
| 394 } | 393 } |
| 395 }, | 394 }, |
| 396 | 395 |
| 397 /** | |
| 398 * Clears the value of the custom passphrase inputs. | |
| 399 * @private | |
| 400 */ | |
| 401 clearPassphraseInputs_: function() { | |
| 402 $('custom-passphrase').value = ''; | |
| 403 $('confirm-passphrase').value = ''; | |
| 404 }, | |
| 405 | |
| 406 showSyncEverythingPage_: function() { | 396 showSyncEverythingPage_: function() { |
| 407 $('confirm-sync-preferences').hidden = false; | 397 $('confirm-sync-preferences').hidden = false; |
| 408 $('customize-sync-preferences').hidden = true; | 398 $('customize-sync-preferences').hidden = true; |
| 409 this.clearPassphraseInputs_(); | |
| 410 | 399 |
| 411 // Reset the selection to 'Sync everything'. | 400 // Reset the selection to 'Sync everything'. |
| 412 $('sync-select-datatypes').selectedIndex = 0; | 401 $('sync-select-datatypes').selectedIndex = 0; |
| 413 | 402 |
| 414 // The default state is to sync everything. | 403 // The default state is to sync everything. |
| 415 this.setCheckboxesToKeepEverythingSynced_(true); | 404 this.setCheckboxesToKeepEverythingSynced_(true); |
| 416 | 405 |
| 417 // If the account is not synced with a custom passphrase, reset the | 406 // If the account is not synced with a custom passphrase, reset the |
| 418 // passphrase radio when switching to the 'Sync everything' page. | 407 // passphrase radio when switching to the 'Sync everything' page. |
| 419 if (!this.usePassphrase_) { | 408 if (!this.usePassphrase_) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 439 $('sync-existing-passphrase-container').hidden = false; | 428 $('sync-existing-passphrase-container').hidden = false; |
| 440 | 429 |
| 441 if (args["passphrase_creation_rejected"]) | 430 if (args["passphrase_creation_rejected"]) |
| 442 $('passphrase-rejected-body').hidden = false; | 431 $('passphrase-rejected-body').hidden = false; |
| 443 else | 432 else |
| 444 $('normal-body').hidden = false; | 433 $('normal-body').hidden = false; |
| 445 | 434 |
| 446 if (args["passphrase_setting_rejected"]) | 435 if (args["passphrase_setting_rejected"]) |
| 447 $('incorrect-passphrase').hidden = false; | 436 $('incorrect-passphrase').hidden = false; |
| 448 | 437 |
| 449 $('sync-passphrase-warning').innerHTML = | 438 $('sync-passphrase-warning').hidden = false; |
| 450 localStrings.getString('passphraseRecover'); | |
| 451 | 439 |
| 452 $('passphrase').focus(); | 440 $('passphrase').focus(); |
| 453 }, | 441 }, |
| 454 | 442 |
| 455 showCustomizePage_: function(args, syncEverything) { | 443 showCustomizePage_: function(args, syncEverything) { |
| 456 $('confirm-sync-preferences').hidden = true; | 444 $('confirm-sync-preferences').hidden = true; |
| 457 $('customize-sync-preferences').hidden = false; | 445 $('customize-sync-preferences').hidden = false; |
| 458 | 446 |
| 459 $('sync-custom-passphrase-container').hidden = false; | 447 $('sync-custom-passphrase-container').hidden = false; |
| 460 $('sync-existing-passphrase-container').hidden = true; | 448 $('sync-existing-passphrase-container').hidden = true; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 $('create-account-cell').hidden = true; | 525 $('create-account-cell').hidden = true; |
| 538 | 526 |
| 539 // It's showtime for the captcha now. | 527 // It's showtime for the captcha now. |
| 540 $('captcha-div').hidden = false; | 528 $('captcha-div').hidden = false; |
| 541 $('gaia-email').disabled = true; | 529 $('gaia-email').disabled = true; |
| 542 $('gaia-passwd').disabled = false; | 530 $('gaia-passwd').disabled = false; |
| 543 $('captcha-value').disabled = false; | 531 $('captcha-value').disabled = false; |
| 544 $('captcha-wrapper').style.backgroundImage = url(args.captchaUrl); | 532 $('captcha-wrapper').style.backgroundImage = url(args.captchaUrl); |
| 545 }, | 533 }, |
| 546 | 534 |
| 535 /** |
| 536 * Reset the state of all descendant elements of a root element to their |
| 537 * initial state. |
| 538 * The initial state is specified by adding a class to the descendant |
| 539 * element in sync_setup_overlay.html. |
| 540 * @param pageElementId The root page element id. |
| 541 * @private |
| 542 */ |
| 547 resetPage_: function(pageElementId) { | 543 resetPage_: function(pageElementId) { |
| 548 var page = $(pageElementId); | 544 var page = $(pageElementId); |
| 549 var forEach = function(arr, fn) { | 545 var forEach = function(arr, fn) { |
| 550 var length = arr.length; | 546 var length = arr.length; |
| 551 for (var i = 0; i < length; i++) { | 547 for (var i = 0; i < length; i++) { |
| 552 fn(arr[i]); | 548 fn(arr[i]); |
| 553 } | 549 } |
| 554 }; | 550 }; |
| 555 | 551 |
| 556 forEach(page.getElementsByClassName('reset-hidden'), | 552 forEach(page.getElementsByClassName('reset-hidden'), |
| 557 function(elt) { elt.hidden = true; }); | 553 function(elt) { elt.hidden = true; }); |
| 558 forEach(page.getElementsByClassName('reset-shown'), | 554 forEach(page.getElementsByClassName('reset-shown'), |
| 559 function(elt) { elt.hidden = false; }); | 555 function(elt) { elt.hidden = false; }); |
| 560 forEach(page.getElementsByClassName('reset-disabled'), | 556 forEach(page.getElementsByClassName('reset-disabled'), |
| 561 function(elt) { elt.disabled = true; }); | 557 function(elt) { elt.disabled = true; }); |
| 562 forEach(page.getElementsByClassName('reset-enabled'), | 558 forEach(page.getElementsByClassName('reset-enabled'), |
| 563 function(elt) { elt.disabled = false; }); | 559 function(elt) { elt.disabled = false; }); |
| 564 forEach(page.getElementsByClassName('reset-visibility-hidden'), | 560 forEach(page.getElementsByClassName('reset-visibility-hidden'), |
| 565 function(elt) { elt.style.visibility = 'hidden'; }); | 561 function(elt) { elt.style.visibility = 'hidden'; }); |
| 562 forEach(page.getElementsByClassName('reset-value'), |
| 563 function(elt) { elt.value = ''; }); |
| 566 }, | 564 }, |
| 567 | 565 |
| 568 showGaiaLogin_: function(args) { | 566 showGaiaLogin_: function(args) { |
| 569 this.resetPage_('sync-setup-login'); | 567 this.resetPage_('sync-setup-login'); |
| 570 $('sync-setup-login').hidden = false; | 568 $('sync-setup-login').hidden = false; |
| 571 | 569 |
| 572 var f = $('gaia-login-form'); | 570 var f = $('gaia-login-form'); |
| 573 var email = $('gaia-email'); | 571 var email = $('gaia-email'); |
| 574 var passwd = $('gaia-passwd'); | 572 var passwd = $('gaia-passwd'); |
| 575 if (f) { | 573 if (f) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 | 724 |
| 727 SyncSetupOverlay.showSuccessAndSettingUp = function() { | 725 SyncSetupOverlay.showSuccessAndSettingUp = function() { |
| 728 SyncSetupOverlay.getInstance().showSuccessAndSettingUp_(); | 726 SyncSetupOverlay.getInstance().showSuccessAndSettingUp_(); |
| 729 }; | 727 }; |
| 730 | 728 |
| 731 // Export | 729 // Export |
| 732 return { | 730 return { |
| 733 SyncSetupOverlay: SyncSetupOverlay | 731 SyncSetupOverlay: SyncSetupOverlay |
| 734 }; | 732 }; |
| 735 }); | 733 }); |
| OLD | NEW |