| 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 * @private | 262 * @private |
| 263 */ | 263 */ |
| 264 setInputElementsDisabledState_: function(disabled) { | 264 setInputElementsDisabledState_: function(disabled) { |
| 265 var configureElements = | 265 var configureElements = |
| 266 $('customize-sync-preferences').querySelectorAll('input'); | 266 $('customize-sync-preferences').querySelectorAll('input'); |
| 267 for (var i = 0; i < configureElements.length; i++) | 267 for (var i = 0; i < configureElements.length; i++) |
| 268 configureElements[i].disabled = disabled; | 268 configureElements[i].disabled = disabled; |
| 269 }, | 269 }, |
| 270 | 270 |
| 271 setChooseDataTypesCheckboxes_: function(args) { | 271 setChooseDataTypesCheckboxes_: function(args) { |
| 272 // If this frame is on top, the focus should be on it, so pressing enter | |
| 273 // submits this form. | |
| 274 if (args.iframeToShow == 'configure') { | |
| 275 $('choose-datatypes-ok').focus(); | |
| 276 } | |
| 277 | |
| 278 var datatypeSelect = document.getElementById('sync-select-datatypes'); | 272 var datatypeSelect = document.getElementById('sync-select-datatypes'); |
| 279 datatypeSelect.selectedIndex = args.keepEverythingSynced ? 0 : 1; | 273 datatypeSelect.selectedIndex = args.keepEverythingSynced ? 0 : 1; |
| 280 | 274 |
| 281 $('bookmarks-checkbox').checked = args.syncBookmarks; | 275 $('bookmarks-checkbox').checked = args.syncBookmarks; |
| 282 $('preferences-checkbox').checked = args.syncPreferences; | 276 $('preferences-checkbox').checked = args.syncPreferences; |
| 283 $('themes-checkbox').checked = args.syncThemes; | 277 $('themes-checkbox').checked = args.syncThemes; |
| 284 | 278 |
| 285 if (args.passwordsRegistered) { | 279 if (args.passwordsRegistered) { |
| 286 $('passwords-checkbox').checked = args.syncPasswords; | 280 $('passwords-checkbox').checked = args.syncPasswords; |
| 287 $('passwords-item').className = "sync-item-show"; | 281 $('passwords-item').className = "sync-item-show"; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 $('choose-datatypes-ok').disabled = true; | 346 $('choose-datatypes-ok').disabled = true; |
| 353 }, | 347 }, |
| 354 | 348 |
| 355 setCheckboxesAndErrors_: function(args) { | 349 setCheckboxesAndErrors_: function(args) { |
| 356 this.setChooseDataTypesCheckboxes_(args); | 350 this.setChooseDataTypesCheckboxes_(args); |
| 357 this.setEncryptionRadios_(args); | 351 this.setEncryptionRadios_(args); |
| 358 this.setPassphraseRadios_(args); | 352 this.setPassphraseRadios_(args); |
| 359 this.setErrorState_(args); | 353 this.setErrorState_(args); |
| 360 }, | 354 }, |
| 361 | 355 |
| 362 // Called once, when this html/js is loaded. | |
| 363 showConfigure_: function(args) { | 356 showConfigure_: function(args) { |
| 364 var datatypeSelect = document.getElementById('sync-select-datatypes'); | 357 var datatypeSelect = document.getElementById('sync-select-datatypes'); |
| 365 var self = this; | 358 var self = this; |
| 366 datatypeSelect.onchange = function() { | 359 datatypeSelect.onchange = function() { |
| 367 var syncAll = this.selectedIndex == 0; | 360 var syncAll = this.selectedIndex == 0; |
| 368 self.setCheckboxesToKeepEverythingSynced_(syncAll); | 361 self.setCheckboxesToKeepEverythingSynced_(syncAll); |
| 369 }; | 362 }; |
| 370 | 363 |
| 371 this.resetPage_('sync-setup-configure'); | 364 this.resetPage_('sync-setup-configure'); |
| 372 $('sync-setup-configure').hidden = false; | 365 $('sync-setup-configure').hidden = false; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 | 442 |
| 450 $('sync-custom-passphrase-container').hidden = false; | 443 $('sync-custom-passphrase-container').hidden = false; |
| 451 $('sync-existing-passphrase-container').hidden = true; | 444 $('sync-existing-passphrase-container').hidden = true; |
| 452 | 445 |
| 453 // If the user has selected the 'Customize' page on initial set up, it's | 446 // If the user has selected the 'Customize' page on initial set up, it's |
| 454 // likely he intends to change the data types. Select the | 447 // likely he intends to change the data types. Select the |
| 455 // 'Choose data types' option in this case. | 448 // 'Choose data types' option in this case. |
| 456 var index = syncEverything ? 0 : 1; | 449 var index = syncEverything ? 0 : 1; |
| 457 document.getElementById('sync-select-datatypes').selectedIndex = index; | 450 document.getElementById('sync-select-datatypes').selectedIndex = index; |
| 458 this.setDataTypeCheckboxesEnabled_(!syncEverything); | 451 this.setDataTypeCheckboxesEnabled_(!syncEverything); |
| 452 |
| 453 // The passphrase input may need to take over focus from the OK button, so |
| 454 // set focus before that logic. |
| 459 $('choose-datatypes-ok').focus(); | 455 $('choose-datatypes-ok').focus(); |
| 460 | 456 |
| 461 if (args && args['show_passphrase']) | 457 if (args && args['show_passphrase']) |
| 462 this.showPassphraseContainer_(args); | 458 this.showPassphraseContainer_(args); |
| 463 }, | 459 }, |
| 464 | 460 |
| 465 attach_: function() { | 461 attach_: function() { |
| 466 chrome.send('SyncSetupAttachHandler'); | 462 chrome.send('SyncSetupAttachHandler'); |
| 467 }, | 463 }, |
| 468 | 464 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 | 689 |
| 694 showSuccessAndClose_: function() { | 690 showSuccessAndClose_: function() { |
| 695 $('sign-in').value = localStrings.getString('loginSuccess'); | 691 $('sign-in').value = localStrings.getString('loginSuccess'); |
| 696 setTimeout(this.closeOverlay_, 1600); | 692 setTimeout(this.closeOverlay_, 1600); |
| 697 }, | 693 }, |
| 698 | 694 |
| 699 showSuccessAndSettingUp_: function() { | 695 showSuccessAndSettingUp_: function() { |
| 700 $('sign-in').value = localStrings.getString('settingUp'); | 696 $('sign-in').value = localStrings.getString('settingUp'); |
| 701 }, | 697 }, |
| 702 | 698 |
| 703 /** @inheritDoc */ | 699 /** |
| 704 shouldClose: function() { | 700 * Initiates attachment to the Sync setup flow and steps into the |
| 705 if (!$('cancel-warning-box').hidden) { | 701 * appropriate error UI. |
| 706 chrome.send('SyncSetupPassphraseCancel', ['']); | 702 * @private |
| 707 return true; | 703 */ |
| 708 } else if (!$('sync-setup-passphrase').hidden) { | 704 showErrorUI_: function() { |
| 709 // The Passphrase page is showing, and the use has pressed escape. | 705 this.attach_(); |
| 710 // Activate the cancel logic in this case. | 706 chrome.send('SyncSetupShowErrorUI'); |
| 711 this.showCancelWarning_(); | 707 }, |
| 712 return false; | 708 }; |
| 713 } | |
| 714 | 709 |
| 715 return true; | 710 SyncSetupOverlay.showErrorUI = function() { |
| 716 }, | 711 SyncSetupOverlay.getInstance().showErrorUI_(); |
| 717 }; | 712 }; |
| 718 | 713 |
| 719 SyncSetupOverlay.showSyncDialog = function() { | 714 SyncSetupOverlay.showSyncDialog = function() { |
| 720 SyncSetupOverlay.getInstance().attach_(); | 715 SyncSetupOverlay.getInstance().attach_(); |
| 721 }; | 716 }; |
| 722 | 717 |
| 723 SyncSetupOverlay.showSyncSetupPage = function(page, args) { | 718 SyncSetupOverlay.showSyncSetupPage = function(page, args) { |
| 724 SyncSetupOverlay.getInstance().showSyncSetupPage_(page, args); | 719 SyncSetupOverlay.getInstance().showSyncSetupPage_(page, args); |
| 725 }; | 720 }; |
| 726 | 721 |
| 727 SyncSetupOverlay.showSuccessAndClose = function() { | 722 SyncSetupOverlay.showSuccessAndClose = function() { |
| 728 SyncSetupOverlay.getInstance().showSuccessAndClose_(); | 723 SyncSetupOverlay.getInstance().showSuccessAndClose_(); |
| 729 }; | 724 }; |
| 730 | 725 |
| 731 SyncSetupOverlay.showSuccessAndSettingUp = function() { | 726 SyncSetupOverlay.showSuccessAndSettingUp = function() { |
| 732 SyncSetupOverlay.getInstance().showSuccessAndSettingUp_(); | 727 SyncSetupOverlay.getInstance().showSuccessAndSettingUp_(); |
| 733 }; | 728 }; |
| 734 | 729 |
| 735 // Export | 730 // Export |
| 736 return { | 731 return { |
| 737 SyncSetupOverlay: SyncSetupOverlay | 732 SyncSetupOverlay: SyncSetupOverlay |
| 738 }; | 733 }; |
| 739 }); | 734 }); |
| OLD | NEW |