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

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

Issue 10200002: Sync UI: Use camelCase for variables sent to JS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. Created 8 years, 8 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 | « no previous file | chrome/browser/ui/webui/sync_setup_handler.cc » ('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) 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 // Don't allow the user to tweak the settings once we send the 215 // Don't allow the user to tweak the settings once we send the
216 // configuration to the backend. 216 // configuration to the backend.
217 this.setInputElementsDisabledState_(true); 217 this.setInputElementsDisabledState_(true);
218 this.animateDisableLink_($('use-default-link'), true, null); 218 this.animateDisableLink_($('use-default-link'), true, null);
219 219
220 // These values need to be kept in sync with where they are read in 220 // These values need to be kept in sync with where they are read in
221 // SyncSetupFlow::GetDataTypeChoiceData(). 221 // SyncSetupFlow::GetDataTypeChoiceData().
222 var result = JSON.stringify({ 222 var result = JSON.stringify({
223 'syncAllDataTypes': syncAll, 223 'syncAllDataTypes': syncAll,
224 'sync_bookmarks': syncAll || $('bookmarks-checkbox').checked, 224 'bookmarksSynced': syncAll || $('bookmarks-checkbox').checked,
225 'sync_preferences': syncAll || $('preferences-checkbox').checked, 225 'preferencesSynced': syncAll || $('preferences-checkbox').checked,
226 'sync_themes': syncAll || $('themes-checkbox').checked, 226 'themesSynced': syncAll || $('themes-checkbox').checked,
227 'sync_passwords': syncAll || $('passwords-checkbox').checked, 227 'passwordsSynced': syncAll || $('passwords-checkbox').checked,
228 'sync_autofill': syncAll || $('autofill-checkbox').checked, 228 'autofillSynced': syncAll || $('autofill-checkbox').checked,
229 'sync_extensions': syncAll || $('extensions-checkbox').checked, 229 'extensionsSynced': syncAll || $('extensions-checkbox').checked,
230 'sync_typed_urls': syncAll || $('typed-urls-checkbox').checked, 230 'typedUrlsSynced': syncAll || $('typed-urls-checkbox').checked,
231 'sync_apps': syncAll || $('apps-checkbox').checked, 231 'appsSynced': syncAll || $('apps-checkbox').checked,
232 'sync_sessions': syncAll || $('sessions-checkbox').checked, 232 'sessionsSynced': syncAll || $('sessions-checkbox').checked,
233 'encryptAllData': encryptAllData, 233 'encryptAllData': encryptAllData,
234 'usePassphrase': usePassphrase, 234 'usePassphrase': usePassphrase,
235 'isGooglePassphrase': googlePassphrase, 235 'isGooglePassphrase': googlePassphrase,
236 'passphrase': customPassphrase 236 'passphrase': customPassphrase
237 }); 237 });
238 chrome.send('SyncSetupConfigure', [result]); 238 chrome.send('SyncSetupConfigure', [result]);
239 }, 239 },
240 240
241 /** 241 /**
242 * Sets the disabled property of all input elements within the 'Customize 242 * Sets the disabled property of all input elements within the 'Customize
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 elt.removeEventListener('webkitTransitionEnd', f); 279 elt.removeEventListener('webkitTransitionEnd', f);
280 elt.classList.remove('transparent'); 280 elt.classList.remove('transparent');
281 elt.hidden = true; 281 elt.hidden = true;
282 }); 282 });
283 } else { 283 } else {
284 elt.hidden = false; 284 elt.hidden = false;
285 elt.onclick = enabledFunction; 285 elt.onclick = enabledFunction;
286 } 286 }
287 }, 287 },
288 288
289 /**
290 * Shows or hides the Sync data type checkboxes in the advanced
291 * configuration screen.
292 * @param {Object} args The configuration data used to show/hide UI.
293 * @private
294 */
289 setChooseDataTypesCheckboxes_: function(args) { 295 setChooseDataTypesCheckboxes_: function(args) {
290 var datatypeSelect = $('sync-select-datatypes'); 296 var datatypeSelect = $('sync-select-datatypes');
291 datatypeSelect.selectedIndex = args.syncAllDataTypes ? 0 : 1; 297 datatypeSelect.selectedIndex = args.syncAllDataTypes ? 0 : 1;
292 298
293 $('bookmarks-checkbox').checked = args.sync_bookmarks; 299 $('bookmarks-checkbox').checked = args.bookmarksSynced;
294 $('preferences-checkbox').checked = args.sync_preferences; 300 $('preferences-checkbox').checked = args.preferencesSynced;
295 $('themes-checkbox').checked = args.sync_themes; 301 $('themes-checkbox').checked = args.themesSynced;
296 302
297 if (args.passwords_registered) { 303 if (args.passwordsRegistered) {
298 $('passwords-checkbox').checked = args.sync_passwords; 304 $('passwords-checkbox').checked = args.passwordsSynced;
299 $('passwords-item').hidden = false; 305 $('passwords-item').hidden = false;
300 } else { 306 } else {
301 $('passwords-item').hidden = true; 307 $('passwords-item').hidden = true;
302 } 308 }
303 if (args.autofill_registered) { 309 if (args.autofillRegistered) {
304 $('autofill-checkbox').checked = args.sync_autofill; 310 $('autofill-checkbox').checked = args.autofillSynced;
305 $('autofill-item').hidden = false; 311 $('autofill-item').hidden = false;
306 } else { 312 } else {
307 $('autofill-item').hidden = true; 313 $('autofill-item').hidden = true;
308 } 314 }
309 if (args.extensions_registered) { 315 if (args.extensionsRegistered) {
310 $('extensions-checkbox').checked = args.sync_extensions; 316 $('extensions-checkbox').checked = args.extensionsSynced;
311 $('extensions-item').hidden = false; 317 $('extensions-item').hidden = false;
312 } else { 318 } else {
313 $('extensions-item').hidden = true; 319 $('extensions-item').hidden = true;
314 } 320 }
315 if (args.typed_urls_registered) { 321 if (args.typedUrlsRegistered) {
316 $('typed-urls-checkbox').checked = args.sync_typed_urls; 322 $('typed-urls-checkbox').checked = args.typedUrlsSynced;
317 $('omnibox-item').hidden = false; 323 $('omnibox-item').hidden = false;
318 } else { 324 } else {
319 $('omnibox-item').hidden = true; 325 $('omnibox-item').hidden = true;
320 } 326 }
321 if (args.apps_registered) { 327 if (args.appsRegistered) {
322 $('apps-checkbox').checked = args.sync_apps; 328 $('apps-checkbox').checked = args.appsSynced;
323 $('apps-item').hidden = false; 329 $('apps-item').hidden = false;
324 } else { 330 } else {
325 $('apps-item').hidden = true; 331 $('apps-item').hidden = true;
326 } 332 }
327 if (args.sessions_registered) { 333 if (args.sessionsRegistered) {
328 $('sessions-checkbox').checked = args.sync_sessions; 334 $('sessions-checkbox').checked = args.sessionsSynced;
329 $('sessions-item').hidden = false; 335 $('sessions-item').hidden = false;
330 } else { 336 } else {
331 $('sessions-item').hidden = true; 337 $('sessions-item').hidden = true;
332 } 338 }
333 339
334 this.setCheckboxesToKeepEverythingSynced_(args.syncAllDataTypes); 340 this.setCheckboxesToKeepEverythingSynced_(args.syncAllDataTypes);
335 }, 341 },
336 342
337 setEncryptionRadios_: function(args) { 343 setEncryptionRadios_: function(args) {
338 if (args['encryptAllData']) { 344 if (args.encryptAllData) {
339 $('encrypt-all-option').checked = true; 345 $('encrypt-all-option').checked = true;
340 this.disableEncryptionRadioGroup_(); 346 this.disableEncryptionRadioGroup_();
341 } else { 347 } else {
342 $('encrypt-sensitive-option').checked = true; 348 $('encrypt-sensitive-option').checked = true;
343 } 349 }
344 }, 350 },
345 351
346 setPassphraseRadios_: function(args) { 352 setPassphraseRadios_: function(args) {
347 if (args['usePassphrase']) { 353 if (args.usePassphrase) {
348 $('explicit-option').checked = true; 354 $('explicit-option').checked = true;
349 355
350 // The passphrase, once set, cannot be unset, but we show a reset link. 356 // The passphrase, once set, cannot be unset, but we show a reset link.
351 $('explicit-option').disabled = true; 357 $('explicit-option').disabled = true;
352 $('google-option').disabled = true; 358 $('google-option').disabled = true;
353 $('sync-custom-passphrase').hidden = true; 359 $('sync-custom-passphrase').hidden = true;
354 } else { 360 } else {
355 $('google-option').checked = true; 361 $('google-option').checked = true;
356 } 362 }
357 }, 363 },
(...skipping 18 matching lines...) Expand all
376 // onsubmit is changed when submitting a passphrase. Reset it to its 382 // onsubmit is changed when submitting a passphrase. Reset it to its
377 // default. 383 // default.
378 $('choose-data-types-form').onsubmit = function() { 384 $('choose-data-types-form').onsubmit = function() {
379 self.sendConfiguration_(); 385 self.sendConfiguration_();
380 return false; 386 return false;
381 }; 387 };
382 388
383 if (args) { 389 if (args) {
384 this.setCheckboxesAndErrors_(args); 390 this.setCheckboxesAndErrors_(args);
385 391
386 this.useEncryptEverything_ = args['encryptAllData']; 392 this.useEncryptEverything_ = args.encryptAllData;
387 393
388 // Whether to display the 'Sync everything' confirmation page or the 394 // Whether to display the 'Sync everything' confirmation page or the
389 // customize data types page. 395 // customize data types page.
390 var syncAllDataTypes = args['syncAllDataTypes']; 396 var syncAllDataTypes = args.syncAllDataTypes;
391 this.usePassphrase_ = args['usePassphrase']; 397 this.usePassphrase_ = args.usePassphrase;
392 if (args['showSyncEverythingPage'] == false || this.usePassphrase_ || 398 if (args.showSyncEverythingPage == false || this.usePassphrase_ ||
393 syncAllDataTypes == false || args['show_passphrase']) { 399 syncAllDataTypes == false || args.showPassphrase) {
394 this.showCustomizePage_(args, syncAllDataTypes); 400 this.showCustomizePage_(args, syncAllDataTypes);
395 } else { 401 } else {
396 this.showSyncEverythingPage_(); 402 this.showSyncEverythingPage_();
397 } 403 }
398 } 404 }
399 }, 405 },
400 406
401 showSpinner_: function() { 407 showSpinner_: function() {
402 this.resetPage_('sync-setup-spinner'); 408 this.resetPage_('sync-setup-spinner');
403 $('sync-setup-spinner').hidden = false; 409 $('sync-setup-spinner').hidden = false;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // Once we require a passphrase, we prevent the user from returning to 447 // Once we require a passphrase, we prevent the user from returning to
442 // the Sync Everything pane. 448 // the Sync Everything pane.
443 $('use-default-link').hidden = true; 449 $('use-default-link').hidden = true;
444 $('sync-custom-passphrase-container').hidden = true; 450 $('sync-custom-passphrase-container').hidden = true;
445 $('sync-existing-passphrase-container').hidden = false; 451 $('sync-existing-passphrase-container').hidden = false;
446 452
447 $('normal-body').hidden = true; 453 $('normal-body').hidden = true;
448 $('google-passphrase-needed-body').hidden = true; 454 $('google-passphrase-needed-body').hidden = true;
449 // Display the correct prompt to the user depending on what type of 455 // Display the correct prompt to the user depending on what type of
450 // passphrase is needed. 456 // passphrase is needed.
451 if (args['usePassphrase']) 457 if (args.usePassphrase)
452 $('normal-body').hidden = false; 458 $('normal-body').hidden = false;
453 else 459 else
454 $('google-passphrase-needed-body').hidden = false; 460 $('google-passphrase-needed-body').hidden = false;
455 461
456 $('passphrase-learn-more').hidden = false; 462 $('passphrase-learn-more').hidden = false;
457 // Warn the user about their incorrect passphrase if we need a passphrase 463 // Warn the user about their incorrect passphrase if we need a passphrase
458 // and the passphrase field is non-empty (meaning they tried to set it 464 // and the passphrase field is non-empty (meaning they tried to set it
459 // previously but failed). 465 // previously but failed).
460 $('incorrect-passphrase').hidden = 466 $('incorrect-passphrase').hidden =
461 !(args['usePassphrase'] && args['passphrase_failed']); 467 !(args.usePassphrase && args.passphraseFailed);
462 468
463 $('sync-passphrase-warning').hidden = false; 469 $('sync-passphrase-warning').hidden = false;
464 $('passphrase').focus(); 470 $('passphrase').focus();
465 }, 471 },
466 472
467 /** @private */ 473 /** @private */
468 showCustomizePage_: function(args, syncEverything) { 474 showCustomizePage_: function(args, syncEverything) {
469 $('confirm-sync-preferences').hidden = true; 475 $('confirm-sync-preferences').hidden = true;
470 $('customize-sync-preferences').hidden = false; 476 $('customize-sync-preferences').hidden = false;
471 477
472 $('sync-custom-passphrase-container').hidden = false; 478 $('sync-custom-passphrase-container').hidden = false;
473 $('sync-existing-passphrase-container').hidden = true; 479 $('sync-existing-passphrase-container').hidden = true;
474 480
475 // If the user has selected the 'Customize' page on initial set up, it's 481 // If the user has selected the 'Customize' page on initial set up, it's
476 // likely he intends to change the data types. Select the 482 // likely he intends to change the data types. Select the
477 // 'Choose data types' option in this case. 483 // 'Choose data types' option in this case.
478 var index = syncEverything ? 0 : 1; 484 var index = syncEverything ? 0 : 1;
479 $('sync-select-datatypes').selectedIndex = index; 485 $('sync-select-datatypes').selectedIndex = index;
480 this.setDataTypeCheckboxesEnabled_(!syncEverything); 486 this.setDataTypeCheckboxesEnabled_(!syncEverything);
481 487
482 // The passphrase input may need to take over focus from the OK button, so 488 // The passphrase input may need to take over focus from the OK button, so
483 // set focus before that logic. 489 // set focus before that logic.
484 $('choose-datatypes-ok').focus(); 490 $('choose-datatypes-ok').focus();
485 491
486 if (args && args['show_passphrase']) { 492 if (args && args.showPassphrase) {
487 this.showPassphraseContainer_(args); 493 this.showPassphraseContainer_(args);
488 } else { 494 } else {
489 // We only show the 'Use Default' link if we're not prompting for an 495 // We only show the 'Use Default' link if we're not prompting for an
490 // existing passphrase. 496 // existing passphrase.
491 var self = this; 497 var self = this;
492 this.animateDisableLink_($('use-default-link'), false, function() { 498 this.animateDisableLink_($('use-default-link'), false, function() {
493 self.showSyncEverythingPage_(); 499 self.showSyncEverythingPage_();
494 }); 500 });
495 } 501 }
496 }, 502 },
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 var f = $('gaia-login-form'); 656 var f = $('gaia-login-form');
651 var email = $('gaia-email'); 657 var email = $('gaia-email');
652 var passwd = $('gaia-passwd'); 658 var passwd = $('gaia-passwd');
653 if (f) { 659 if (f) {
654 if (args.user != undefined) { 660 if (args.user != undefined) {
655 if (email.value != args.user) 661 if (email.value != args.user)
656 passwd.value = ''; // Reset the password field 662 passwd.value = ''; // Reset the password field
657 email.value = args.user; 663 email.value = args.user;
658 } 664 }
659 665
660 if (!args.editable_user) { 666 if (!args.editableUser) {
661 $('email-row').hidden = true; 667 $('email-row').hidden = true;
662 var span = $('email-readonly'); 668 var span = $('email-readonly');
663 span.textContent = email.value; 669 span.textContent = email.value;
664 $('email-readonly-row').hidden = false; 670 $('email-readonly-row').hidden = false;
665 $('create-account-div').hidden = true; 671 $('create-account-div').hidden = true;
666 } 672 }
667 673
668 f.accessCode.disabled = true; 674 f.accessCode.disabled = true;
669 } 675 }
670 676
671 if (1 == args.error) { 677 if (1 == args.error) {
672 var access_code = $('access-code'); 678 var accessCode = $('access-code');
673 if (access_code.value) { 679 if (accessCode.value) {
674 $('errormsg-0-access-code').hidden = false; 680 $('errormsg-0-access-code').hidden = false;
675 this.showAccessCodeRequired_(); 681 this.showAccessCodeRequired_();
676 } else { 682 } else {
677 $('errormsg-1-password').hidden = false; 683 $('errormsg-1-password').hidden = false;
678 } 684 }
679 this.setBlurbError_(args.error_message); 685 this.setBlurbError_(args.errorMessage);
680 } else if (3 == args.error) { 686 } else if (3 == args.error) {
681 $('errormsg-0-connection').hidden = false; 687 $('errormsg-0-connection').hidden = false;
682 this.setBlurbError_(args.error_message); 688 this.setBlurbError_(args.errorMessage);
683 } else if (4 == args.error) { 689 } else if (4 == args.error) {
684 this.showCaptcha_(args); 690 this.showCaptcha_(args);
685 } else if (7 == args.error) { 691 } else if (7 == args.error) {
686 this.setBlurbError_(localStrings.getString('serviceUnavailableError')); 692 this.setBlurbError_(localStrings.getString('serviceUnavailableError'));
687 } else if (8 == args.error) { 693 } else if (8 == args.error) {
688 this.showAccessCodeRequired_(); 694 this.showAccessCodeRequired_();
689 } else if (args.error_message) { 695 } else if (args.errorMessage) {
690 this.setBlurbError_(args.error_message); 696 this.setBlurbError_(args.errorMessage);
691 } 697 }
692 698
693 if (args.fatalError) { 699 if (args.fatalError) {
694 $('errormsg-fatal').hidden = false; 700 $('errormsg-fatal').hidden = false;
695 $('sign-in').disabled = true; 701 $('sign-in').disabled = true;
696 return; 702 return;
697 } 703 }
698 704
699 $('sign-in').disabled = false; 705 $('sign-in').disabled = false;
700 $('sign-in').value = templateData['signin']; 706 $('sign-in').value = templateData['signin'];
701 this.loginSetFocus_(); 707 this.loginSetFocus_();
702 }, 708 },
703 709
704 resetErrorVisibility_: function() { 710 resetErrorVisibility_: function() {
705 $('errormsg-0-email').hidden = true; 711 $('errormsg-0-email').hidden = true;
706 $('errormsg-0-password').hidden = true; 712 $('errormsg-0-password').hidden = true;
707 $('errormsg-1-password').hidden = true; 713 $('errormsg-1-password').hidden = true;
708 $('errormsg-0-connection').hidden = true; 714 $('errormsg-0-connection').hidden = true;
709 $('errormsg-0-access-code').hidden = true; 715 $('errormsg-0-access-code').hidden = true;
710 }, 716 },
711 717
712 setBlurbError_: function(error_message) { 718 setBlurbError_: function(errorMessage) {
713 if (this.captchaChallengeActive_) 719 if (this.captchaChallengeActive_)
714 return; // No blurb in captcha challenge mode. 720 return; // No blurb in captcha challenge mode.
715 721
716 if (error_message) { 722 if (errorMessage) {
717 $('error-signing-in').hidden = true; 723 $('error-signing-in').hidden = true;
718 $('error-custom').hidden = false; 724 $('error-custom').hidden = false;
719 $('error-custom').textContent = error_message; 725 $('error-custom').textContent = errorMessage;
720 } else { 726 } else {
721 $('error-signing-in').hidden = false; 727 $('error-signing-in').hidden = false;
722 $('error-custom').hidden = true; 728 $('error-custom').hidden = true;
723 } 729 }
724 730
725 $('top-blurb-error').hidden = false; 731 $('top-blurb-error').hidden = false;
726 $('gaia-email').disabled = false; 732 $('gaia-email').disabled = false;
727 $('gaia-passwd').disabled = false; 733 $('gaia-passwd').disabled = false;
728 }, 734 },
729 735
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 $('access-code').disabled = true; 784 $('access-code').disabled = true;
779 785
780 this.setThrobbersVisible_(true); 786 this.setThrobbersVisible_(true);
781 787
782 var f = $('gaia-login-form'); 788 var f = $('gaia-login-form');
783 var email = $('gaia-email'); 789 var email = $('gaia-email');
784 var passwd = $('gaia-passwd'); 790 var passwd = $('gaia-passwd');
785 var result = JSON.stringify({'user' : email.value, 791 var result = JSON.stringify({'user' : email.value,
786 'pass' : passwd.value, 792 'pass' : passwd.value,
787 'captcha' : f.captchaValue.value, 793 'captcha' : f.captchaValue.value,
788 'access_code' : f.accessCode.value}); 794 'accessCode' : f.accessCode.value});
789 $('sign-in').disabled = true; 795 $('sign-in').disabled = true;
790 chrome.send('SyncSetupSubmitAuth', [result]); 796 chrome.send('SyncSetupSubmitAuth', [result]);
791 }, 797 },
792 798
793 showSuccessAndClose_: function() { 799 showSuccessAndClose_: function() {
794 $('sign-in').value = localStrings.getString('loginSuccess'); 800 $('sign-in').value = localStrings.getString('loginSuccess');
795 setTimeout(this.closeOverlay_, 1600); 801 setTimeout(this.closeOverlay_, 1600);
796 }, 802 },
797 803
798 showSuccessAndSettingUp_: function() { 804 showSuccessAndSettingUp_: function() {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 888
883 SyncSetupOverlay.showStopSyncingUI = function() { 889 SyncSetupOverlay.showStopSyncingUI = function() {
884 SyncSetupOverlay.getInstance().showStopSyncingUI_(); 890 SyncSetupOverlay.getInstance().showStopSyncingUI_();
885 }; 891 };
886 892
887 // Export 893 // Export
888 return { 894 return {
889 SyncSetupOverlay: SyncSetupOverlay 895 SyncSetupOverlay: SyncSetupOverlay
890 }; 896 };
891 }); 897 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/sync_setup_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698