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

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: win/linux tweaks 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
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 "syncThemes": syncAll || $('themes-checkbox').checked, 250 "syncThemes": syncAll || $('themes-checkbox').checked,
247 "syncPasswords": syncAll || $('passwords-checkbox').checked, 251 "syncPasswords": syncAll || $('passwords-checkbox').checked,
248 "syncAutofill": syncAll || $('autofill-checkbox').checked, 252 "syncAutofill": syncAll || $('autofill-checkbox').checked,
249 "syncExtensions": syncAll || $('extensions-checkbox').checked, 253 "syncExtensions": syncAll || $('extensions-checkbox').checked,
250 "syncTypedUrls": syncAll || $('typed-urls-checkbox').checked, 254 "syncTypedUrls": syncAll || $('typed-urls-checkbox').checked,
251 "syncApps": syncAll || $('apps-checkbox').checked, 255 "syncApps": syncAll || $('apps-checkbox').checked,
252 "syncSessions": syncAll || $('sessions-checkbox').checked, 256 "syncSessions": syncAll || $('sessions-checkbox').checked,
253 "usePassphrase": (this.getRadioCheckedValue_() == 'explicit'), 257 "usePassphrase": (this.getRadioCheckedValue_() == 'explicit'),
254 "passphrase": $('custom-passphrase').value 258 "passphrase": $('custom-passphrase').value
255 }); 259 });
256 chrome.send("Configure", [result]); 260 chrome.send('SyncSetupConfigure', [result]);
257 }, 261 },
258 262
259 setChooseDataTypesCheckboxes_: function(args) { 263 setChooseDataTypesCheckboxes_: function(args) {
260 // If this frame is on top, the focus should be on it, so pressing enter 264 // If this frame is on top, the focus should be on it, so pressing enter
261 // submits this form. 265 // submits this form.
262 if (args.iframeToShow == 'configure') { 266 if (args.iframeToShow == 'configure') {
263 $('choose-datatypes-ok').focus(); 267 $('choose-datatypes-ok').focus();
264 } 268 }
265 269
266 var datatypeSelect = document.getElementById('sync-select-datatypes'); 270 var datatypeSelect = document.getElementById('sync-select-datatypes');
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 395
392 // If the user has selected the 'Customize' page on initial set up, it's 396 // If the user has selected the 'Customize' page on initial set up, it's
393 // likely he intends to change the data types. Select the 397 // likely he intends to change the data types. Select the
394 // 'Choose data types' option in this case. 398 // 'Choose data types' option in this case.
395 var index = syncEverything ? 0 : 1; 399 var index = syncEverything ? 0 : 1;
396 document.getElementById('sync-select-datatypes').selectedIndex = index; 400 document.getElementById('sync-select-datatypes').selectedIndex = index;
397 this.setDataTypeCheckboxesEnabled_(!syncEverything); 401 this.setDataTypeCheckboxesEnabled_(!syncEverything);
398 $('choose-datatypes-ok').focus(); 402 $('choose-datatypes-ok').focus();
399 }, 403 },
400 404
405 attach_: function() {
406 chrome.send('SyncSetupAttachHandler');
407 },
408
401 showSyncSetupPage_: function(page, args) { 409 showSyncSetupPage_: function(page, args) {
402 if (page == 'settingUp') { 410 if (page == 'settingUp') {
403 this.setThrobbersVisible_(true); 411 this.setThrobbersVisible_(true);
404 return; 412 return;
405 } else { 413 } else {
406 this.setThrobbersVisible_(false); 414 this.setThrobbersVisible_(false);
407 } 415 }
408 416
409 // Hide an existing visible overlay. 417 // Hide an existing visible overlay.
410 var overlay = $('sync-setup-overlay'); 418 var overlay = $('sync-setup-overlay');
411 for (var i = 0; i < overlay.children.length; i++) 419 for (var i = 0; i < overlay.children.length; i++)
412 overlay.children[i].classList.add('hidden'); 420 overlay.children[i].classList.add('hidden');
413 421
414 if (page == 'login') 422 if (page == 'login')
415 this.showGaiaLogin_(args); 423 this.showGaiaLogin_(args);
416 else if (page == 'configure') 424 else if (page == 'configure')
417 this.showConfigure_(args); 425 this.showConfigure_(args);
418 else if (page == 'passphrase') 426 else if (page == 'passphrase')
419 this.showPassphrase_(args); 427 this.showPassphrase_(args);
420 else if (page == 'done') 428
429 if (page == 'done')
421 this.closeOverlay_(); 430 this.closeOverlay_();
431 else
432 this.showOverlay_();
422 }, 433 },
423 434
424 setThrobbersVisible_: function(visible) { 435 setThrobbersVisible_: function(visible) {
425 var throbbers = document.getElementsByClassName("throbber"); 436 var throbbers = document.getElementsByClassName("throbber");
426 for (var i = 0; i < throbbers.length; i++) 437 for (var i = 0; i < throbbers.length; i++)
427 throbbers[i].style.visibility = visible ? "visible" : "hidden"; 438 throbbers[i].style.visibility = visible ? "visible" : "hidden";
428 }, 439 },
429 440
430 showPassphrase_: function(args) { 441 showPassphrase_: function(args) {
431 $('sync-setup-passphrase').classList.remove('hidden'); 442 $('sync-setup-passphrase').classList.remove('hidden');
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 $('logging-in-throbber').style.visibility = "visible"; 617 $('logging-in-throbber').style.visibility = "visible";
607 618
608 var f = $('gaia-login-form'); 619 var f = $('gaia-login-form');
609 var email = $('gaia-email'); 620 var email = $('gaia-email');
610 var passwd = $('gaia-passwd'); 621 var passwd = $('gaia-passwd');
611 var result = JSON.stringify({"user" : email.value, 622 var result = JSON.stringify({"user" : email.value,
612 "pass" : passwd.value, 623 "pass" : passwd.value,
613 "captcha" : f.captchaValue.value, 624 "captcha" : f.captchaValue.value,
614 "access_code" : f.accessCode.value}); 625 "access_code" : f.accessCode.value});
615 $('sign-in').disabled = true; 626 $('sign-in').disabled = true;
616 chrome.send("SubmitAuth", [result]); 627 chrome.send('SyncSetupSubmitAuth', [result]);
617 }, 628 },
618 629
619 showGaiaSuccessAndClose_: function() { 630 showGaiaSuccessAndClose_: function() {
620 $('sign-in').value = localStrings.getString('loginSuccess'); 631 $('sign-in').value = localStrings.getString('loginSuccess');
621 setTimeout(this.closeOverlay_, 1600); 632 setTimeout(this.closeOverlay_, 1600);
622 }, 633 },
623 634
624 showSuccessAndSettingUp_: function() { 635 showSuccessAndSettingUp_: function() {
625 $('sign-in').value = localStrings.getString('settingUp'); 636 $('sign-in').value = localStrings.getString('settingUp');
626 }, 637 },
627 638
628 /** @inheritDoc */ 639 /** @inheritDoc */
629 shouldClose: function() { 640 shouldClose: function() {
630 if (!$('cancel-warning-box').hidden) { 641 if (!$('cancel-warning-box').hidden) {
631 chrome.send('PassphraseCancel', ['']); 642 chrome.send('SyncSetupPassphraseCancel', ['']);
632 return true; 643 return true;
633 } else if (!$('sync-setup-passphrase').classList.contains('hidden')) { 644 } else if (!$('sync-setup-passphrase').classList.contains('hidden')) {
634 // The Passphrase page is showing, and the use has pressed escape. 645 // The Passphrase page is showing, and the use has pressed escape.
635 // Activate the cancel logic in this case. 646 // Activate the cancel logic in this case.
636 this.showCancelWarning_(); 647 this.showCancelWarning_();
637 return false; 648 return false;
638 } 649 }
639 650
640 return true; 651 return true;
641 }, 652 },
642 }; 653 };
643 654
655 SyncSetupOverlay.showSyncDialog = function() {
656 SyncSetupOverlay.getInstance().attach_();
657 };
658
644 SyncSetupOverlay.showSyncSetupPage = function(page, args) { 659 SyncSetupOverlay.showSyncSetupPage = function(page, args) {
645 SyncSetupOverlay.getInstance().showSyncSetupPage_(page, args); 660 SyncSetupOverlay.getInstance().showSyncSetupPage_(page, args);
646 }; 661 };
647 662
648 SyncSetupOverlay.showSuccessAndClose = function() { 663 SyncSetupOverlay.showSuccessAndClose = function() {
649 SyncSetupOverlay.getInstance().showSuccessAndClose_(); 664 SyncSetupOverlay.getInstance().showSuccessAndClose_();
650 }; 665 };
651 666
652 SyncSetupOverlay.showSuccessAndSettingUp = function() { 667 SyncSetupOverlay.showSuccessAndSettingUp = function() {
653 SyncSetupOverlay.getInstance().showSuccessAndSettingUp_(); 668 SyncSetupOverlay.getInstance().showSuccessAndSettingUp_();
654 }; 669 };
655 670
656 // Export 671 // Export
657 return { 672 return {
658 SyncSetupOverlay: SyncSetupOverlay 673 SyncSetupOverlay: SyncSetupOverlay
659 }; 674 };
660 }); 675 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698