Chromium Code Reviews| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 self.sendConfiguration_(); | 76 self.sendConfiguration_(); |
| 77 }; | 77 }; |
| 78 $('use-default-link').onclick = function() { | 78 $('use-default-link').onclick = function() { |
| 79 self.showSyncEverythingPage_(); | 79 self.showSyncEverythingPage_(); |
| 80 }; | 80 }; |
| 81 $('cancel-no-button').onclick = function() { | 81 $('cancel-no-button').onclick = function() { |
| 82 self.hideCancelWarning_(); | 82 self.hideCancelWarning_(); |
| 83 return false; | 83 return false; |
| 84 }; | 84 }; |
| 85 $('cancel-yes-button').onclick = function() { | 85 $('cancel-yes-button').onclick = function() { |
| 86 chrome.send('PassphraseCancel', ['']); | 86 chrome.send('SyncSetupPassphraseCancel', ['']); |
| 87 return false; | 87 return false; |
| 88 }; | 88 }; |
| 89 $('passphrase-form').onsubmit = $('passphrase-ok').onclick = function() { | 89 $('passphrase-form').onsubmit = $('passphrase-ok').onclick = function() { |
| 90 self.sendPassphraseAndClose_(); | 90 self.sendPassphraseAndClose_(); |
| 91 return false; | 91 return false; |
| 92 }; | 92 }; |
| 93 $('passphrase-cancel').onclick = function() { | 93 $('passphrase-cancel').onclick = function() { |
| 94 self.showCancelWarning_(); | 94 self.showCancelWarning_(); |
| 95 return false; | 95 return false; |
| 96 }; | 96 }; |
| 97 }, | 97 }, |
| 98 | 98 |
| 99 showOverlay_: function() { | |
| 100 OptionsPage.navigateToPage('syncSetup'); | |
| 101 }, | |
| 102 | |
| 99 closeOverlay_: function() { | 103 closeOverlay_: function() { |
| 100 OptionsPage.closeOverlay(); | 104 OptionsPage.closeOverlay(); |
| 101 }, | 105 }, |
| 102 | 106 |
| 103 /** @inheritDoc */ | 107 /** @inheritDoc */ |
| 104 didShowPage: function() { | 108 didShowPage: function() { |
| 105 chrome.send('didShowPage'); | 109 chrome.send('SyncSetupAttachHandler'); |
| 106 }, | 110 }, |
| 107 | 111 |
| 108 /** @inheritDoc */ | 112 /** @inheritDoc */ |
| 109 didClosePage: function() { | 113 didClosePage: function() { |
| 110 chrome.send('didClosePage'); | 114 chrome.send('SyncSetupDidClosePage'); |
| 111 }, | 115 }, |
| 112 | 116 |
| 113 showCancelWarning_: function() { | 117 showCancelWarning_: function() { |
| 114 $('cancel-warning-box').hidden = false; | 118 $('cancel-warning-box').hidden = false; |
| 115 $('passphrase-ok').disabled = true; | 119 $('passphrase-ok').disabled = true; |
| 116 $('passphrase-cancel').disabled = true; | 120 $('passphrase-cancel').disabled = true; |
| 117 $('cancel-no-button').focus(); | 121 $('cancel-no-button').focus(); |
| 118 }, | 122 }, |
| 119 | 123 |
| 120 sendPassphraseAndClose_: function() { | 124 sendPassphraseAndClose_: function() { |
| 121 var f = $('passphrase-form'); | 125 var f = $('passphrase-form'); |
| 122 var result = JSON.stringify({"passphrase": f.passphrase.value}); | 126 var result = JSON.stringify({"passphrase": f.passphrase.value}); |
| 123 chrome.send("Passphrase", [result]); | 127 chrome.send('SyncSetupPassphrase', [result]); |
| 124 }, | 128 }, |
| 125 | 129 |
| 126 getRadioCheckedValue_: function() { | 130 getRadioCheckedValue_: function() { |
| 127 var f = $('choose-data-types-form'); | 131 var f = $('choose-data-types-form'); |
| 128 for (var i = 0; i < f.option.length; ++i) { | 132 for (var i = 0; i < f.option.length; ++i) { |
| 129 if (f.option[i].checked) { | 133 if (f.option[i].checked) { |
| 130 return f.option[i].value; | 134 return f.option[i].value; |
| 131 } | 135 } |
| 132 } | 136 } |
| 133 | 137 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 $('error-text').className = "sync-error-show"; | 233 $('error-text').className = "sync-error-show"; |
| 230 return; | 234 return; |
| 231 } | 235 } |
| 232 | 236 |
| 233 var f = $('choose-data-types-form'); | 237 var f = $('choose-data-types-form'); |
| 234 if (!this.checkPassphraseMatch_()) | 238 if (!this.checkPassphraseMatch_()) |
| 235 return; | 239 return; |
| 236 | 240 |
| 237 // Don't allow the user to tweak the settings once we send the | 241 // Don't allow the user to tweak the settings once we send the |
| 238 // configuration to the backend. | 242 // configuration to the backend. |
| 239 this.disableConfigureElements_(); | 243 this.setInputElementsDisabledState_(true); |
| 240 | 244 |
| 241 var syncAll = | 245 var syncAll = |
| 242 document.getElementById('sync-select-datatypes').selectedIndex == 0; | 246 document.getElementById('sync-select-datatypes').selectedIndex == 0; |
| 243 | 247 |
| 244 // These values need to be kept in sync with where they are read in | 248 // These values need to be kept in sync with where they are read in |
| 245 // SyncSetupFlow::GetDataTypeChoiceData(). | 249 // SyncSetupFlow::GetDataTypeChoiceData(). |
| 246 var result = JSON.stringify({ | 250 var result = JSON.stringify({ |
| 247 "keepEverythingSynced": syncAll, | 251 "keepEverythingSynced": syncAll, |
| 248 "syncBookmarks": syncAll || $('bookmarks-checkbox').checked, | 252 "syncBookmarks": syncAll || $('bookmarks-checkbox').checked, |
| 249 "syncPreferences": syncAll || $('preferences-checkbox').checked, | 253 "syncPreferences": syncAll || $('preferences-checkbox').checked, |
| 250 "syncThemes": syncAll || $('themes-checkbox').checked, | 254 "syncThemes": syncAll || $('themes-checkbox').checked, |
| 251 "syncPasswords": syncAll || $('passwords-checkbox').checked, | 255 "syncPasswords": syncAll || $('passwords-checkbox').checked, |
| 252 "syncAutofill": syncAll || $('autofill-checkbox').checked, | 256 "syncAutofill": syncAll || $('autofill-checkbox').checked, |
| 253 "syncExtensions": syncAll || $('extensions-checkbox').checked, | 257 "syncExtensions": syncAll || $('extensions-checkbox').checked, |
| 254 "syncTypedUrls": syncAll || $('typed-urls-checkbox').checked, | 258 "syncTypedUrls": syncAll || $('typed-urls-checkbox').checked, |
| 255 "syncApps": syncAll || $('apps-checkbox').checked, | 259 "syncApps": syncAll || $('apps-checkbox').checked, |
| 256 "syncSessions": syncAll || $('sessions-checkbox').checked, | 260 "syncSessions": syncAll || $('sessions-checkbox').checked, |
| 257 "usePassphrase": (this.getRadioCheckedValue_() == 'explicit'), | 261 "usePassphrase": (this.getRadioCheckedValue_() == 'explicit'), |
| 258 "passphrase": $('custom-passphrase').value | 262 "passphrase": $('custom-passphrase').value |
| 259 }); | 263 }); |
| 260 chrome.send("Configure", [result]); | 264 chrome.send('SyncSetupConfigure', [result]); |
| 261 }, | 265 }, |
| 262 | 266 |
| 263 /** | 267 /** |
| 264 * Disables all input elements within the 'Customize Sync Preferences' | 268 * Sets the disabled property of all input elements within the 'Customize |
| 265 * screen. This is used to prohibit the user from changing the inputs after | 269 * Sync Preferences' screen. This is used to prohibit the user from changing |
| 266 * confirming the customized sync preferences. | 270 * the inputs after confirming the customized sync preferences, or resetting |
| 271 * the state when re-showing the dialog. | |
| 267 * @private | 272 * @private |
|
James Hawkins
2011/05/23 22:00:37
nit: @param
csilv
2011/05/23 23:29:03
Done.
| |
| 268 */ | 273 */ |
| 269 disableConfigureElements_: function() { | 274 setInputElementsDisabledState_: function(disabled) { |
| 270 var configureElements = | 275 var configureElements = |
| 271 $('customize-sync-preferences').querySelectorAll('input'); | 276 $('customize-sync-preferences').querySelectorAll('input'); |
| 272 for (var i = 0; i < configureElements.length; i++) | 277 for (var i = 0; i < configureElements.length; i++) |
| 273 configureElements[i].disabled = true; | 278 configureElements[i].disabled = disabled; |
| 274 }, | 279 }, |
| 275 | 280 |
| 276 setChooseDataTypesCheckboxes_: function(args) { | 281 setChooseDataTypesCheckboxes_: function(args) { |
| 277 // If this frame is on top, the focus should be on it, so pressing enter | 282 // If this frame is on top, the focus should be on it, so pressing enter |
| 278 // submits this form. | 283 // submits this form. |
| 279 if (args.iframeToShow == 'configure') { | 284 if (args.iframeToShow == 'configure') { |
| 280 $('choose-datatypes-ok').focus(); | 285 $('choose-datatypes-ok').focus(); |
| 281 } | 286 } |
| 282 | 287 |
| 283 var datatypeSelect = document.getElementById('sync-select-datatypes'); | 288 var datatypeSelect = document.getElementById('sync-select-datatypes'); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 | 413 |
| 409 // If the user has selected the 'Customize' page on initial set up, it's | 414 // If the user has selected the 'Customize' page on initial set up, it's |
| 410 // likely he intends to change the data types. Select the | 415 // likely he intends to change the data types. Select the |
| 411 // 'Choose data types' option in this case. | 416 // 'Choose data types' option in this case. |
| 412 var index = syncEverything ? 0 : 1; | 417 var index = syncEverything ? 0 : 1; |
| 413 document.getElementById('sync-select-datatypes').selectedIndex = index; | 418 document.getElementById('sync-select-datatypes').selectedIndex = index; |
| 414 this.setDataTypeCheckboxesEnabled_(!syncEverything); | 419 this.setDataTypeCheckboxesEnabled_(!syncEverything); |
| 415 $('choose-datatypes-ok').focus(); | 420 $('choose-datatypes-ok').focus(); |
| 416 }, | 421 }, |
| 417 | 422 |
| 423 attach_: function() { | |
| 424 chrome.send('SyncSetupAttachHandler'); | |
| 425 }, | |
| 426 | |
| 418 showSyncSetupPage_: function(page, args) { | 427 showSyncSetupPage_: function(page, args) { |
| 419 if (page == 'settingUp') { | 428 if (page == 'settingUp') { |
| 420 this.setThrobbersVisible_(true); | 429 this.setThrobbersVisible_(true); |
| 421 return; | 430 return; |
| 422 } else { | 431 } else { |
| 423 this.setThrobbersVisible_(false); | 432 this.setThrobbersVisible_(false); |
| 424 } | 433 } |
| 425 | 434 |
| 426 // Hide an existing visible overlay. | 435 // Hide an existing visible overlay. |
| 427 var overlay = $('sync-setup-overlay'); | 436 var overlay = $('sync-setup-overlay'); |
| 428 for (var i = 0; i < overlay.children.length; i++) | 437 for (var i = 0; i < overlay.children.length; i++) |
| 429 overlay.children[i].classList.add('hidden'); | 438 overlay.children[i].classList.add('hidden'); |
| 430 | 439 |
| 440 this.setInputElementsDisabledState_(false); | |
| 441 | |
| 431 if (page == 'login') | 442 if (page == 'login') |
| 432 this.showGaiaLogin_(args); | 443 this.showGaiaLogin_(args); |
| 433 else if (page == 'configure') | 444 else if (page == 'configure') |
| 434 this.showConfigure_(args); | 445 this.showConfigure_(args); |
| 435 else if (page == 'passphrase') | 446 else if (page == 'passphrase') |
| 436 this.showPassphrase_(args); | 447 this.showPassphrase_(args); |
| 437 else if (page == 'done') | 448 |
| 449 if (page == 'done') | |
| 438 this.closeOverlay_(); | 450 this.closeOverlay_(); |
| 451 else | |
| 452 this.showOverlay_(); | |
| 439 }, | 453 }, |
| 440 | 454 |
| 441 setThrobbersVisible_: function(visible) { | 455 setThrobbersVisible_: function(visible) { |
| 442 var throbbers = document.getElementsByClassName("throbber"); | 456 var throbbers = document.getElementsByClassName("throbber"); |
| 443 for (var i = 0; i < throbbers.length; i++) | 457 for (var i = 0; i < throbbers.length; i++) |
| 444 throbbers[i].style.visibility = visible ? "visible" : "hidden"; | 458 throbbers[i].style.visibility = visible ? "visible" : "hidden"; |
| 445 }, | 459 }, |
| 446 | 460 |
| 447 showPassphrase_: function(args) { | 461 showPassphrase_: function(args) { |
| 448 $('sync-setup-passphrase').classList.remove('hidden'); | 462 $('sync-setup-passphrase').classList.remove('hidden'); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 623 $('logging-in-throbber').style.visibility = "visible"; | 637 $('logging-in-throbber').style.visibility = "visible"; |
| 624 | 638 |
| 625 var f = $('gaia-login-form'); | 639 var f = $('gaia-login-form'); |
| 626 var email = $('gaia-email'); | 640 var email = $('gaia-email'); |
| 627 var passwd = $('gaia-passwd'); | 641 var passwd = $('gaia-passwd'); |
| 628 var result = JSON.stringify({"user" : email.value, | 642 var result = JSON.stringify({"user" : email.value, |
| 629 "pass" : passwd.value, | 643 "pass" : passwd.value, |
| 630 "captcha" : f.captchaValue.value, | 644 "captcha" : f.captchaValue.value, |
| 631 "access_code" : f.accessCode.value}); | 645 "access_code" : f.accessCode.value}); |
| 632 $('sign-in').disabled = true; | 646 $('sign-in').disabled = true; |
| 633 chrome.send("SubmitAuth", [result]); | 647 chrome.send('SyncSetupSubmitAuth', [result]); |
| 634 }, | 648 }, |
| 635 | 649 |
| 636 showGaiaSuccessAndClose_: function() { | 650 showGaiaSuccessAndClose_: function() { |
| 637 $('sign-in').value = localStrings.getString('loginSuccess'); | 651 $('sign-in').value = localStrings.getString('loginSuccess'); |
| 638 setTimeout(this.closeOverlay_, 1600); | 652 setTimeout(this.closeOverlay_, 1600); |
| 639 }, | 653 }, |
| 640 | 654 |
| 641 showSuccessAndSettingUp_: function() { | 655 showSuccessAndSettingUp_: function() { |
| 642 $('sign-in').value = localStrings.getString('settingUp'); | 656 $('sign-in').value = localStrings.getString('settingUp'); |
| 643 }, | 657 }, |
| 644 | 658 |
| 645 /** @inheritDoc */ | 659 /** @inheritDoc */ |
| 646 shouldClose: function() { | 660 shouldClose: function() { |
| 647 if (!$('cancel-warning-box').hidden) { | 661 if (!$('cancel-warning-box').hidden) { |
| 648 chrome.send('PassphraseCancel', ['']); | 662 chrome.send('SyncSetupPassphraseCancel', ['']); |
| 649 return true; | 663 return true; |
| 650 } else if (!$('sync-setup-passphrase').classList.contains('hidden')) { | 664 } else if (!$('sync-setup-passphrase').classList.contains('hidden')) { |
| 651 // The Passphrase page is showing, and the use has pressed escape. | 665 // The Passphrase page is showing, and the use has pressed escape. |
| 652 // Activate the cancel logic in this case. | 666 // Activate the cancel logic in this case. |
| 653 this.showCancelWarning_(); | 667 this.showCancelWarning_(); |
| 654 return false; | 668 return false; |
| 655 } | 669 } |
| 656 | 670 |
| 657 return true; | 671 return true; |
| 658 }, | 672 }, |
| 659 }; | 673 }; |
| 660 | 674 |
| 675 SyncSetupOverlay.showSyncDialog = function() { | |
| 676 SyncSetupOverlay.getInstance().attach_(); | |
| 677 }; | |
| 678 | |
| 661 SyncSetupOverlay.showSyncSetupPage = function(page, args) { | 679 SyncSetupOverlay.showSyncSetupPage = function(page, args) { |
| 662 SyncSetupOverlay.getInstance().showSyncSetupPage_(page, args); | 680 SyncSetupOverlay.getInstance().showSyncSetupPage_(page, args); |
| 663 }; | 681 }; |
| 664 | 682 |
| 665 SyncSetupOverlay.showSuccessAndClose = function() { | 683 SyncSetupOverlay.showSuccessAndClose = function() { |
| 666 SyncSetupOverlay.getInstance().showSuccessAndClose_(); | 684 SyncSetupOverlay.getInstance().showSuccessAndClose_(); |
| 667 }; | 685 }; |
| 668 | 686 |
| 669 SyncSetupOverlay.showSuccessAndSettingUp = function() { | 687 SyncSetupOverlay.showSuccessAndSettingUp = function() { |
| 670 SyncSetupOverlay.getInstance().showSuccessAndSettingUp_(); | 688 SyncSetupOverlay.getInstance().showSuccessAndSettingUp_(); |
| 671 }; | 689 }; |
| 672 | 690 |
| 673 // Export | 691 // Export |
| 674 return { | 692 return { |
| 675 SyncSetupOverlay: SyncSetupOverlay | 693 SyncSetupOverlay: SyncSetupOverlay |
| 676 }; | 694 }; |
| 677 }); | 695 }); |
| OLD | NEW |