OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 */ var OptionsPage = options.OptionsPage; | 6 /** @const */ var 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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 function(elt) { elt.disabled = true; }); | 671 function(elt) { elt.disabled = true; }); |
672 forEach(page.getElementsByClassName('reset-enabled'), | 672 forEach(page.getElementsByClassName('reset-enabled'), |
673 function(elt) { elt.disabled = false; }); | 673 function(elt) { elt.disabled = false; }); |
674 forEach(page.getElementsByClassName('reset-value'), | 674 forEach(page.getElementsByClassName('reset-value'), |
675 function(elt) { elt.value = ''; }); | 675 function(elt) { elt.value = ''; }); |
676 forEach(page.getElementsByClassName('reset-opaque'), | 676 forEach(page.getElementsByClassName('reset-opaque'), |
677 function(elt) { elt.classList.remove('transparent'); }); | 677 function(elt) { elt.classList.remove('transparent'); }); |
678 }, | 678 }, |
679 | 679 |
680 showGaiaLogin_: function(args) { | 680 showGaiaLogin_: function(args) { |
| 681 var oldAccessCodeValue = $('access-code').value; |
681 this.resetPage_('sync-setup-login'); | 682 this.resetPage_('sync-setup-login'); |
682 $('sync-setup-login').hidden = false; | 683 $('sync-setup-login').hidden = false; |
683 this.allowEmptyPassword_ = false; | 684 this.allowEmptyPassword_ = false; |
684 this.captchaChallengeActive_ = false; | 685 this.captchaChallengeActive_ = false; |
685 | 686 |
686 var f = $('gaia-login-form'); | 687 var f = $('gaia-login-form'); |
687 var email = $('gaia-email'); | 688 var email = $('gaia-email'); |
688 var passwd = $('gaia-passwd'); | 689 var passwd = $('gaia-passwd'); |
689 if (f) { | 690 if (f) { |
690 if (args.user != undefined) { | 691 if (args.user != undefined) { |
691 if (email.value != args.user) | 692 if (email.value != args.user) |
692 passwd.value = ''; // Reset the password field | 693 passwd.value = ''; // Reset the password field |
693 email.value = args.user; | 694 email.value = args.user; |
694 } | 695 } |
695 | 696 |
696 if (!args.editableUser) { | 697 if (!args.editableUser) { |
697 $('email-row').hidden = true; | 698 $('email-row').hidden = true; |
698 var span = $('email-readonly'); | 699 var span = $('email-readonly'); |
699 span.textContent = email.value; | 700 span.textContent = email.value; |
700 $('email-readonly-row').hidden = false; | 701 $('email-readonly-row').hidden = false; |
701 $('create-account-div').hidden = true; | 702 $('create-account-div').hidden = true; |
702 } | 703 } |
703 | 704 |
704 f.accessCode.disabled = true; | 705 f.accessCode.disabled = true; |
705 f.otp.disabled = true; | 706 f.otp.disabled = true; |
706 } | 707 } |
707 | 708 |
708 if (1 == args.error) { | 709 if (1 == args.error) { |
709 var accessCode = $('access-code'); | 710 if (oldAccessCodeValue) { |
710 if (accessCode.value) { | |
711 $('errormsg-0-access-code').hidden = false; | 711 $('errormsg-0-access-code').hidden = false; |
712 this.showAccessCodeRequired_(); | 712 this.showAccessCodeRequired_(); |
713 } else { | 713 } else { |
714 $('errormsg-1-password').hidden = (args.errorMessage != undefined); | 714 $('errormsg-1-password').hidden = (args.errorMessage != undefined); |
715 } | 715 } |
716 this.setBlurbError_(args.errorMessage); | 716 this.setBlurbError_(args.errorMessage); |
717 } else if (3 == args.error) { | 717 } else if (3 == args.error) { |
718 $('errormsg-0-connection').hidden = false; | 718 $('errormsg-0-connection').hidden = false; |
719 this.setBlurbError_(args.errorMessage); | 719 this.setBlurbError_(args.errorMessage); |
720 } else if (4 == args.error) { | 720 } else if (4 == args.error) { |
721 this.showCaptcha_(args); | 721 this.showCaptcha_(args); |
722 } else if (7 == args.error) { | 722 } else if (7 == args.error) { |
723 this.setBlurbError_(loadTimeData.getString('serviceUnavailableError')); | 723 this.setBlurbError_(loadTimeData.getString('serviceUnavailableError')); |
724 } else if (8 == args.error) { | 724 } else if (8 == args.error) { |
725 if (args.askForOtp) { | 725 if (args.askForOtp) { |
726 this.showOtpRequired_(); | 726 this.showOtpRequired_(); |
727 } else { | 727 } else { |
| 728 if (oldAccessCodeValue) |
| 729 $('errormsg-0-access-code').hidden = false; |
728 this.showAccessCodeRequired_(); | 730 this.showAccessCodeRequired_(); |
729 } | 731 } |
730 } else if (args.errorMessage) { | 732 } else if (args.errorMessage) { |
731 this.setBlurbError_(args.errorMessage); | 733 this.setBlurbError_(args.errorMessage); |
732 } | 734 } |
733 | 735 |
734 if (args.fatalError) { | 736 if (args.fatalError) { |
735 $('errormsg-fatal').hidden = false; | 737 $('errormsg-fatal').hidden = false; |
736 $('sign-in').disabled = true; | 738 $('sign-in').disabled = true; |
737 return; | 739 return; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 } | 791 } |
790 // Don't enforce password being non-blank when checking access code (it | 792 // Don't enforce password being non-blank when checking access code (it |
791 // will have been cleared when the page was displayed). | 793 // will have been cleared when the page was displayed). |
792 if (!this.allowEmptyPassword_ && !passwd.value) { | 794 if (!this.allowEmptyPassword_ && !passwd.value) { |
793 $('errormsg-0-password').hidden = false; | 795 $('errormsg-0-password').hidden = false; |
794 this.setBlurbError_(); | 796 this.setBlurbError_(); |
795 return false; | 797 return false; |
796 } | 798 } |
797 | 799 |
798 if (!f.accessCode.disabled && !f.accessCode.value) { | 800 if (!f.accessCode.disabled && !f.accessCode.value) { |
799 $('errormsg-0-password').hidden = false; | 801 $('errormsg-0-access-code').hidden = false; |
800 return false; | 802 return false; |
801 } | 803 } |
802 | 804 |
803 if (f.accessCode.disabled && this.matchesASPRegex_(passwd.value) && | 805 if (f.accessCode.disabled && this.matchesASPRegex_(passwd.value) && |
804 $('asp-warning-div').hidden) { | 806 $('asp-warning-div').hidden) { |
805 $('asp-warning-div').hidden = false; | 807 $('asp-warning-div').hidden = false; |
806 $('gaia-passwd').value = ''; | 808 $('gaia-passwd').value = ''; |
807 return false; | 809 return false; |
808 } | 810 } |
809 | 811 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 | 959 |
958 SyncSetupOverlay.showStopSyncingUI = function() { | 960 SyncSetupOverlay.showStopSyncingUI = function() { |
959 SyncSetupOverlay.getInstance().showStopSyncingUI_(); | 961 SyncSetupOverlay.getInstance().showStopSyncingUI_(); |
960 }; | 962 }; |
961 | 963 |
962 // Export | 964 // Export |
963 return { | 965 return { |
964 SyncSetupOverlay: SyncSetupOverlay | 966 SyncSetupOverlay: SyncSetupOverlay |
965 }; | 967 }; |
966 }); | 968 }); |
OLD | NEW |