| OLD | NEW |
| 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.exportPath('options'); | 5 cr.exportPath('options'); |
| 6 | 6 |
| 7 /** @typedef {{appsEnforced: boolean, | 7 /** @typedef {{appsEnforced: boolean, |
| 8 * appsRegistered: boolean, | 8 * appsRegistered: boolean, |
| 9 * appsSynced: boolean, | 9 * appsSynced: boolean, |
| 10 * autofillEnforced: boolean, | 10 * autofillEnforced: boolean, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 options.DataTypeSelection = { | 55 options.DataTypeSelection = { |
| 56 SYNC_EVERYTHING: 0, | 56 SYNC_EVERYTHING: 0, |
| 57 CHOOSE_WHAT_TO_SYNC: 1, | 57 CHOOSE_WHAT_TO_SYNC: 1, |
| 58 SYNC_NOTHING: 2 | 58 SYNC_NOTHING: 2 |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 cr.define('options', function() { | 61 cr.define('options', function() { |
| 62 /** @const */ var Page = cr.ui.pageManager.Page; | 62 /** @const */ var Page = cr.ui.pageManager.Page; |
| 63 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 63 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
| 64 | 64 |
| 65 // TODO(dbeam): none of these variables are used. This is not Java. |
| 66 |
| 65 // True if the synced account uses a custom passphrase. | 67 // True if the synced account uses a custom passphrase. |
| 66 var usePassphrase_ = false; | 68 var usePassphrase_ = false; |
| 67 | 69 |
| 68 // True if the synced account uses 'encrypt everything'. | 70 // True if the synced account uses 'encrypt everything'. |
| 69 var useEncryptEverything_ = false; | 71 var useEncryptEverything_ = false; |
| 70 | 72 |
| 71 // An object used as a cache of the arguments passed in while initially | 73 // An object used as a cache of the arguments passed in while initially |
| 72 // displaying the advanced sync settings dialog. Used to switch between the | 74 // displaying the advanced sync settings dialog. Used to switch between the |
| 73 // options in the main drop-down menu. Reset when the dialog is closed. | 75 // options in the main drop-down menu. Reset when the dialog is closed. |
| 74 var syncConfigureArgs_ = null; | 76 var syncConfigureArgs_ = null; |
| 75 | 77 |
| 76 // A dictionary that maps the sync data type checkbox names to their checked | 78 // A dictionary that maps the sync data type checkbox names to their checked |
| 77 // state. Initialized when the advanced settings dialog is first brought up, | 79 // state. Initialized when the advanced settings dialog is first brought up, |
| 78 // updated any time a box is checked / unchecked, and reset when the dialog is | 80 // updated any time a box is checked / unchecked, and reset when the dialog is |
| 79 // closed. Used to restore checkbox state while switching between the options | 81 // closed. Used to restore checkbox state while switching between the options |
| 80 // in the main drop-down menu. All checkboxes are checked and disabled when | 82 // in the main drop-down menu. All checkboxes are checked and disabled when |
| 81 // the "Sync everything" menu-item is selected, and unchecked and disabled | 83 // the "Sync everything" menu-item is selected, and unchecked and disabled |
| 82 // when "Sync nothing" is selected. When "Choose what to sync" is selected, | 84 // when "Sync nothing" is selected. When "Choose what to sync" is selected, |
| 83 // the boxes are restored to their most recent checked state from this cache. | 85 // the boxes are restored to their most recent checked state from this cache. |
| 84 var dataTypeBoxesChecked_ = {}; | 86 var dataTypeBoxesChecked_ = {}; |
| 85 | 87 |
| 86 // A dictionary that maps the sync data type checkbox names to their disabled | 88 // A dictionary that maps the sync data type checkbox names to their disabled |
| 87 // state (when a data type is enabled programmatically without user choice). | 89 // state (when a data type is enabled programmatically without user choice). |
| 88 // Initialized when the advanced settings dialog is first brought up, and | 90 // Initialized when the advanced settings dialog is first brought up, and |
| 89 // reset when the dialog is closed. | 91 // reset when the dialog is closed. |
| 90 var dataTypeBoxesDisabled_ = {}; | 92 var dataTypeBoxesDisabled_ = {}; |
| 91 | 93 |
| 92 // Used to determine whether to bring the OK button / passphrase field into | |
| 93 // focus. | |
| 94 var confirmPageVisible_ = false; | |
| 95 var customizePageVisible_ = false; | |
| 96 | |
| 97 /** | 94 /** |
| 98 * SyncSetupOverlay class | 95 * SyncSetupOverlay class |
| 99 * Encapsulated handling of the 'Sync Setup' overlay page. | 96 * Encapsulated handling of the 'Sync Setup' overlay page. |
| 100 * @class | 97 * @class |
| 101 */ | 98 */ |
| 102 function SyncSetupOverlay() { | 99 function SyncSetupOverlay() { |
| 103 Page.call(this, 'syncSetup', | 100 Page.call(this, 'syncSetup', |
| 104 loadTimeData.getString('syncSetupOverlayTabTitle'), | 101 loadTimeData.getString('syncSetupOverlayTabTitle'), |
| 105 'sync-setup-overlay'); | 102 'sync-setup-overlay'); |
| 106 } | 103 } |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 */ | 493 */ |
| 497 showConfigure_: function(args) { | 494 showConfigure_: function(args) { |
| 498 var datatypeSelect = $('sync-select-datatypes'); | 495 var datatypeSelect = $('sync-select-datatypes'); |
| 499 var self = this; | 496 var self = this; |
| 500 | 497 |
| 501 // Cache the sync config args so they can be reused when we transition | 498 // Cache the sync config args so they can be reused when we transition |
| 502 // between the drop-down menu items in the advanced settings dialog. | 499 // between the drop-down menu items in the advanced settings dialog. |
| 503 if (args) | 500 if (args) |
| 504 this.syncConfigureArgs_ = args; | 501 this.syncConfigureArgs_ = args; |
| 505 | 502 |
| 506 // Required in order to determine whether to give focus to the OK button | |
| 507 // or passphrase field. See crbug.com/310555 and crbug.com/306353. | |
| 508 this.confirmPageVisible_ = false; | |
| 509 this.customizePageVisible_ = false; | |
| 510 | |
| 511 // Once the advanced sync settings dialog is visible, we transition | 503 // Once the advanced sync settings dialog is visible, we transition |
| 512 // between its drop-down menu items as follows: | 504 // between its drop-down menu items as follows: |
| 513 // "Sync everything": Show encryption and passphrase sections, and disable | 505 // "Sync everything": Show encryption and passphrase sections, and disable |
| 514 // and check all data type checkboxes. | 506 // and check all data type checkboxes. |
| 515 // "Sync nothing": Hide encryption and passphrase sections, and disable | 507 // "Sync nothing": Hide encryption and passphrase sections, and disable |
| 516 // and uncheck all data type checkboxes. | 508 // and uncheck all data type checkboxes. |
| 517 // "Choose what to sync": Show encryption and passphrase sections, enable | 509 // "Choose what to sync": Show encryption and passphrase sections, enable |
| 518 // data type checkboxes, and restore their checked state to the last time | 510 // data type checkboxes, and restore their checked state to the last time |
| 519 // the "Choose what to sync" was selected while the dialog was still up. | 511 // the "Choose what to sync" was selected while the dialog was still up. |
| 520 datatypeSelect.onchange = function() { | 512 datatypeSelect.onchange = function() { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 | 559 |
| 568 showTimeoutPage_: function() { | 560 showTimeoutPage_: function() { |
| 569 this.resetPage_('sync-setup-timeout'); | 561 this.resetPage_('sync-setup-timeout'); |
| 570 $('sync-setup-timeout').hidden = false; | 562 $('sync-setup-timeout').hidden = false; |
| 571 }, | 563 }, |
| 572 | 564 |
| 573 showSyncEverythingPage_: function() { | 565 showSyncEverythingPage_: function() { |
| 574 chrome.send('coreOptionsUserMetricsAction', | 566 chrome.send('coreOptionsUserMetricsAction', |
| 575 ['Options_SyncSetDefault']); | 567 ['Options_SyncSetDefault']); |
| 576 | 568 |
| 577 // Determine whether to bring the OK button into focus. | |
| 578 var wasConfirmPageHidden = !this.confirmPageVisible_; | |
| 579 this.confirmPageVisible_ = true; | |
| 580 this.customizePageVisible_ = false; | |
| 581 | |
| 582 $('confirm-sync-preferences').hidden = false; | 569 $('confirm-sync-preferences').hidden = false; |
| 583 $('customize-sync-preferences').hidden = true; | 570 $('customize-sync-preferences').hidden = true; |
| 584 | 571 |
| 585 // Reset the selection to 'Sync everything'. | 572 // Reset the selection to 'Sync everything'. |
| 586 $('sync-select-datatypes').selectedIndex = 0; | 573 $('sync-select-datatypes').selectedIndex = 0; |
| 587 | 574 |
| 588 // The default state is to sync everything. | 575 // The default state is to sync everything. |
| 589 this.setDataTypeCheckboxes_(options.DataTypeSelection.SYNC_EVERYTHING); | 576 this.setDataTypeCheckboxes_(options.DataTypeSelection.SYNC_EVERYTHING); |
| 590 | 577 |
| 591 if (!this.usePassphrase_) | 578 if (!this.usePassphrase_) |
| 592 $('sync-custom-passphrase').hidden = true; | 579 $('sync-custom-passphrase').hidden = true; |
| 593 | 580 |
| 594 if (!this.useEncryptEverything_ && !this.usePassphrase_) | 581 if (!this.useEncryptEverything_ && !this.usePassphrase_) |
| 595 $('basic-encryption-option').checked = true; | 582 $('basic-encryption-option').checked = true; |
| 596 | |
| 597 // Give the OK button focus only when the dialog wasn't already visible. | |
| 598 if (wasConfirmPageHidden) | |
| 599 $('confirm-everything-ok').focus(); | |
| 600 }, | 583 }, |
| 601 | 584 |
| 602 /** | 585 /** |
| 603 * Reveals the UI for when the user chooses not to sync any data types. | 586 * Reveals the UI for when the user chooses not to sync any data types. |
| 604 * This happens when the user signs in and selects "Sync nothing" in the | 587 * This happens when the user signs in and selects "Sync nothing" in the |
| 605 * advanced sync settings dialog. | 588 * advanced sync settings dialog. |
| 606 * @private | 589 * @private |
| 607 */ | 590 */ |
| 608 showSyncNothingPage_: function() { | 591 showSyncNothingPage_: function() { |
| 609 // Reset the selection to 'Sync nothing'. | 592 // Reset the selection to 'Sync nothing'. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 }, | 649 }, |
| 667 | 650 |
| 668 /** | 651 /** |
| 669 * Displays the advanced sync setting dialog, and pre-selects either the | 652 * Displays the advanced sync setting dialog, and pre-selects either the |
| 670 * "Sync everything" or the "Choose what to sync" drop-down menu item. | 653 * "Sync everything" or the "Choose what to sync" drop-down menu item. |
| 671 * @param {SyncConfig} args | 654 * @param {SyncConfig} args |
| 672 * @param {options.DataTypeSelection} index Index of item to pre-select. | 655 * @param {options.DataTypeSelection} index Index of item to pre-select. |
| 673 * @private | 656 * @private |
| 674 */ | 657 */ |
| 675 showCustomizePage_: function(args, index) { | 658 showCustomizePage_: function(args, index) { |
| 676 // Determine whether to bring the OK button field into focus. | |
| 677 var wasCustomizePageHidden = !this.customizePageVisible_; | |
| 678 this.customizePageVisible_ = true; | |
| 679 this.confirmPageVisible_ = false; | |
| 680 | |
| 681 $('confirm-sync-preferences').hidden = true; | 659 $('confirm-sync-preferences').hidden = true; |
| 682 $('customize-sync-preferences').hidden = false; | 660 $('customize-sync-preferences').hidden = false; |
| 683 | 661 |
| 684 $('sync-custom-passphrase-container').hidden = false; | 662 $('sync-custom-passphrase-container').hidden = false; |
| 685 $('sync-new-encryption-section-container').hidden = false; | 663 $('sync-new-encryption-section-container').hidden = false; |
| 686 $('customize-sync-encryption-new').hidden = !args.encryptAllDataAllowed; | 664 $('customize-sync-encryption-new').hidden = !args.encryptAllDataAllowed; |
| 687 | 665 |
| 688 $('sync-existing-passphrase-container').hidden = true; | 666 $('sync-existing-passphrase-container').hidden = true; |
| 689 | 667 |
| 690 $('sync-select-datatypes').selectedIndex = index; | 668 $('sync-select-datatypes').selectedIndex = index; |
| 691 this.setDataTypeCheckboxesEnabled_( | 669 this.setDataTypeCheckboxesEnabled_( |
| 692 index == options.DataTypeSelection.CHOOSE_WHAT_TO_SYNC); | 670 index == options.DataTypeSelection.CHOOSE_WHAT_TO_SYNC); |
| 693 | 671 |
| 694 // Give the OK button focus only when the dialog wasn't already visible. | |
| 695 if (wasCustomizePageHidden) | |
| 696 $('choose-datatypes-ok').focus(); | |
| 697 | |
| 698 if (args.showPassphrase) { | 672 if (args.showPassphrase) { |
| 699 this.showPassphraseContainer_(args); | 673 this.showPassphraseContainer_(args); |
| 700 // Give the passphrase field focus only when the dialog wasn't already | |
| 701 // visible. | |
| 702 if (wasCustomizePageHidden) | |
| 703 $('passphrase').focus(); | |
| 704 } else { | 674 } else { |
| 705 // We only show the 'Use Default' link if we're not prompting for an | 675 // We only show the 'Use Default' link if we're not prompting for an |
| 706 // existing passphrase. | 676 // existing passphrase. |
| 707 $('use-default-link').hidden = false; | 677 $('use-default-link').hidden = false; |
| 708 $('use-default-link').disabled = false; | 678 $('use-default-link').disabled = false; |
| 709 $('use-default-link').onclick = function() { | 679 $('use-default-link').onclick = function() { |
| 710 SyncSetupOverlay.showSyncEverythingPage(); | 680 SyncSetupOverlay.showSyncEverythingPage(); |
| 711 return false; | 681 return false; |
| 712 }; | 682 }; |
| 713 } | 683 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 // Hide any visible children of the overlay. | 783 // Hide any visible children of the overlay. |
| 814 var overlay = $('sync-setup-overlay'); | 784 var overlay = $('sync-setup-overlay'); |
| 815 for (var i = 0; i < overlay.children.length; i++) | 785 for (var i = 0; i < overlay.children.length; i++) |
| 816 overlay.children[i].hidden = true; | 786 overlay.children[i].hidden = true; |
| 817 | 787 |
| 818 // Bypass PageManager.showPageByName because it will call didShowPage | 788 // Bypass PageManager.showPageByName because it will call didShowPage |
| 819 // which will set its own visible page, based on the flow state. | 789 // which will set its own visible page, based on the flow state. |
| 820 this.visible = true; | 790 this.visible = true; |
| 821 | 791 |
| 822 $('sync-setup-stop-syncing').hidden = false; | 792 $('sync-setup-stop-syncing').hidden = false; |
| 823 $('stop-syncing-cancel').focus(); | |
| 824 }, | 793 }, |
| 825 | 794 |
| 826 /** | 795 /** |
| 827 * Determines the appropriate page to show in the Sync Setup UI based on | 796 * Determines the appropriate page to show in the Sync Setup UI based on |
| 828 * the state of the Sync backend. Does nothing if the user is not signed in. | 797 * the state of the Sync backend. Does nothing if the user is not signed in. |
| 829 * @private | 798 * @private |
| 830 */ | 799 */ |
| 831 showSetupUI_: function() { | 800 showSetupUI_: function() { |
| 832 chrome.send('SyncSetupShowSetupUI'); | 801 chrome.send('SyncSetupShowSetupUI'); |
| 833 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowSyncAdvanced']); | 802 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowSyncAdvanced']); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 | 851 |
| 883 SyncSetupOverlay.showStopSyncingUI = function() { | 852 SyncSetupOverlay.showStopSyncingUI = function() { |
| 884 SyncSetupOverlay.getInstance().showStopSyncingUI_(); | 853 SyncSetupOverlay.getInstance().showStopSyncingUI_(); |
| 885 }; | 854 }; |
| 886 | 855 |
| 887 // Export | 856 // Export |
| 888 return { | 857 return { |
| 889 SyncSetupOverlay: SyncSetupOverlay | 858 SyncSetupOverlay: SyncSetupOverlay |
| 890 }; | 859 }; |
| 891 }); | 860 }); |
| OLD | NEW |