Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: chrome/browser/resources/options/sync_setup_overlay.js

Issue 7057038: dom-ui sync: Eliminate jank when customizing sync settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: comment tweak Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/sync/profile_sync_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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.
272 * @param disabled True if controls should be set to disabled.
267 * @private 273 * @private
268 */ 274 */
269 disableConfigureElements_: function() { 275 setInputElementsDisabledState_: function(disabled) {
270 var configureElements = 276 var configureElements =
271 $('customize-sync-preferences').querySelectorAll('input'); 277 $('customize-sync-preferences').querySelectorAll('input');
272 for (var i = 0; i < configureElements.length; i++) 278 for (var i = 0; i < configureElements.length; i++)
273 configureElements[i].disabled = true; 279 configureElements[i].disabled = disabled;
274 }, 280 },
275 281
276 setChooseDataTypesCheckboxes_: function(args) { 282 setChooseDataTypesCheckboxes_: function(args) {
277 // If this frame is on top, the focus should be on it, so pressing enter 283 // If this frame is on top, the focus should be on it, so pressing enter
278 // submits this form. 284 // submits this form.
279 if (args.iframeToShow == 'configure') { 285 if (args.iframeToShow == 'configure') {
280 $('choose-datatypes-ok').focus(); 286 $('choose-datatypes-ok').focus();
281 } 287 }
282 288
283 var datatypeSelect = document.getElementById('sync-select-datatypes'); 289 var datatypeSelect = document.getElementById('sync-select-datatypes');
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 414
409 // If the user has selected the 'Customize' page on initial set up, it's 415 // 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 416 // likely he intends to change the data types. Select the
411 // 'Choose data types' option in this case. 417 // 'Choose data types' option in this case.
412 var index = syncEverything ? 0 : 1; 418 var index = syncEverything ? 0 : 1;
413 document.getElementById('sync-select-datatypes').selectedIndex = index; 419 document.getElementById('sync-select-datatypes').selectedIndex = index;
414 this.setDataTypeCheckboxesEnabled_(!syncEverything); 420 this.setDataTypeCheckboxesEnabled_(!syncEverything);
415 $('choose-datatypes-ok').focus(); 421 $('choose-datatypes-ok').focus();
416 }, 422 },
417 423
424 attach_: function() {
425 chrome.send('SyncSetupAttachHandler');
426 },
427
418 showSyncSetupPage_: function(page, args) { 428 showSyncSetupPage_: function(page, args) {
419 if (page == 'settingUp') { 429 if (page == 'settingUp') {
420 this.setThrobbersVisible_(true); 430 this.setThrobbersVisible_(true);
421 return; 431 return;
422 } else { 432 } else {
423 this.setThrobbersVisible_(false); 433 this.setThrobbersVisible_(false);
424 } 434 }
425 435
426 // Hide an existing visible overlay. 436 // Hide an existing visible overlay.
427 var overlay = $('sync-setup-overlay'); 437 var overlay = $('sync-setup-overlay');
428 for (var i = 0; i < overlay.children.length; i++) 438 for (var i = 0; i < overlay.children.length; i++)
429 overlay.children[i].classList.add('hidden'); 439 overlay.children[i].classList.add('hidden');
430 440
441 this.setInputElementsDisabledState_(false);
442
431 if (page == 'login') 443 if (page == 'login')
432 this.showGaiaLogin_(args); 444 this.showGaiaLogin_(args);
433 else if (page == 'configure') 445 else if (page == 'configure')
434 this.showConfigure_(args); 446 this.showConfigure_(args);
435 else if (page == 'passphrase') 447 else if (page == 'passphrase')
436 this.showPassphrase_(args); 448 this.showPassphrase_(args);
437 else if (page == 'done') 449
450 if (page == 'done')
438 this.closeOverlay_(); 451 this.closeOverlay_();
452 else
453 this.showOverlay_();
439 }, 454 },
440 455
441 setThrobbersVisible_: function(visible) { 456 setThrobbersVisible_: function(visible) {
442 var throbbers = document.getElementsByClassName("throbber"); 457 var throbbers = document.getElementsByClassName("throbber");
443 for (var i = 0; i < throbbers.length; i++) 458 for (var i = 0; i < throbbers.length; i++)
444 throbbers[i].style.visibility = visible ? "visible" : "hidden"; 459 throbbers[i].style.visibility = visible ? "visible" : "hidden";
445 }, 460 },
446 461
447 showPassphrase_: function(args) { 462 showPassphrase_: function(args) {
448 $('sync-setup-passphrase').classList.remove('hidden'); 463 $('sync-setup-passphrase').classList.remove('hidden');
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 $('logging-in-throbber').style.visibility = "visible"; 638 $('logging-in-throbber').style.visibility = "visible";
624 639
625 var f = $('gaia-login-form'); 640 var f = $('gaia-login-form');
626 var email = $('gaia-email'); 641 var email = $('gaia-email');
627 var passwd = $('gaia-passwd'); 642 var passwd = $('gaia-passwd');
628 var result = JSON.stringify({"user" : email.value, 643 var result = JSON.stringify({"user" : email.value,
629 "pass" : passwd.value, 644 "pass" : passwd.value,
630 "captcha" : f.captchaValue.value, 645 "captcha" : f.captchaValue.value,
631 "access_code" : f.accessCode.value}); 646 "access_code" : f.accessCode.value});
632 $('sign-in').disabled = true; 647 $('sign-in').disabled = true;
633 chrome.send("SubmitAuth", [result]); 648 chrome.send('SyncSetupSubmitAuth', [result]);
634 }, 649 },
635 650
636 showGaiaSuccessAndClose_: function() { 651 showGaiaSuccessAndClose_: function() {
637 $('sign-in').value = localStrings.getString('loginSuccess'); 652 $('sign-in').value = localStrings.getString('loginSuccess');
638 setTimeout(this.closeOverlay_, 1600); 653 setTimeout(this.closeOverlay_, 1600);
639 }, 654 },
640 655
641 showSuccessAndSettingUp_: function() { 656 showSuccessAndSettingUp_: function() {
642 $('sign-in').value = localStrings.getString('settingUp'); 657 $('sign-in').value = localStrings.getString('settingUp');
643 }, 658 },
644 659
645 /** @inheritDoc */ 660 /** @inheritDoc */
646 shouldClose: function() { 661 shouldClose: function() {
647 if (!$('cancel-warning-box').hidden) { 662 if (!$('cancel-warning-box').hidden) {
648 chrome.send('PassphraseCancel', ['']); 663 chrome.send('SyncSetupPassphraseCancel', ['']);
649 return true; 664 return true;
650 } else if (!$('sync-setup-passphrase').classList.contains('hidden')) { 665 } else if (!$('sync-setup-passphrase').classList.contains('hidden')) {
651 // The Passphrase page is showing, and the use has pressed escape. 666 // The Passphrase page is showing, and the use has pressed escape.
652 // Activate the cancel logic in this case. 667 // Activate the cancel logic in this case.
653 this.showCancelWarning_(); 668 this.showCancelWarning_();
654 return false; 669 return false;
655 } 670 }
656 671
657 return true; 672 return true;
658 }, 673 },
659 }; 674 };
660 675
676 SyncSetupOverlay.showSyncDialog = function() {
677 SyncSetupOverlay.getInstance().attach_();
678 };
679
661 SyncSetupOverlay.showSyncSetupPage = function(page, args) { 680 SyncSetupOverlay.showSyncSetupPage = function(page, args) {
662 SyncSetupOverlay.getInstance().showSyncSetupPage_(page, args); 681 SyncSetupOverlay.getInstance().showSyncSetupPage_(page, args);
663 }; 682 };
664 683
665 SyncSetupOverlay.showSuccessAndClose = function() { 684 SyncSetupOverlay.showSuccessAndClose = function() {
666 SyncSetupOverlay.getInstance().showSuccessAndClose_(); 685 SyncSetupOverlay.getInstance().showSuccessAndClose_();
667 }; 686 };
668 687
669 SyncSetupOverlay.showSuccessAndSettingUp = function() { 688 SyncSetupOverlay.showSuccessAndSettingUp = function() {
670 SyncSetupOverlay.getInstance().showSuccessAndSettingUp_(); 689 SyncSetupOverlay.getInstance().showSuccessAndSettingUp_();
671 }; 690 };
672 691
673 // Export 692 // Export
674 return { 693 return {
675 SyncSetupOverlay: SyncSetupOverlay 694 SyncSetupOverlay: SyncSetupOverlay
676 }; 695 };
677 }); 696 });
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/sync/profile_sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698