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.define('options', function() { | 5 cr.define('options', function() { |
6 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
7 var ArrayDataModel = cr.ui.ArrayDataModel; | 7 var ArrayDataModel = cr.ui.ArrayDataModel; |
8 var RepeatingButton = cr.ui.RepeatingButton; | 8 var RepeatingButton = cr.ui.RepeatingButton; |
9 | 9 |
10 // | 10 // |
11 // BrowserOptions class | 11 // BrowserOptions class |
12 // Encapsulated handling of browser options page. | 12 // Encapsulated handling of browser options page. |
13 // | 13 // |
14 function BrowserOptions() { | 14 function BrowserOptions() { |
15 OptionsPage.call(this, 'settings', loadTimeData.getString('settingsTitle'), | 15 OptionsPage.call(this, 'settings', loadTimeData.getString('settingsTitle'), |
16 'settings'); | 16 'settings'); |
17 } | 17 } |
18 | 18 |
19 cr.addSingletonGetter(BrowserOptions); | 19 cr.addSingletonGetter(BrowserOptions); |
20 | 20 |
21 BrowserOptions.prototype = { | 21 BrowserOptions.prototype = { |
22 __proto__: options.OptionsPage.prototype, | 22 __proto__: options.OptionsPage.prototype, |
23 | 23 |
24 /** | 24 /** |
25 * Keeps track of the state of |start-stop-button|. On chrome, the value is | 25 * Keeps track of whether the user is signed in or not. |
26 * true when the user is signed in, and on chromeos, when sync setup has | |
27 * been completed. | |
28 * @type {boolean} | 26 * @type {boolean} |
29 * @private | 27 * @private |
30 */ | 28 */ |
31 signedIn_: false, | 29 signedIn_: false, |
32 | 30 |
33 /** | 31 /** |
34 * Keeps track of whether |onShowHomeButtonChanged_| has been called. See | 32 * Keeps track of whether |onShowHomeButtonChanged_| has been called. See |
35 * |onShowHomeButtonChanged_|. | 33 * |onShowHomeButtonChanged_|. |
36 * @type {boolean} | 34 * @type {boolean} |
37 * @private | 35 * @private |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 * @private | 702 * @private |
705 */ | 703 */ |
706 updateSyncState_: function(syncData) { | 704 updateSyncState_: function(syncData) { |
707 if (!syncData.signinAllowed) { | 705 if (!syncData.signinAllowed) { |
708 $('sync-section').hidden = true; | 706 $('sync-section').hidden = true; |
709 return; | 707 return; |
710 } | 708 } |
711 | 709 |
712 $('sync-section').hidden = false; | 710 $('sync-section').hidden = false; |
713 | 711 |
714 if (cr.isChromeOS) | 712 // If the user gets signed out while the advanced sync settings dialog is |
715 this.signedIn_ = syncData.setupCompleted; | 713 // visible, say, due to a dashboard clear, close the dialog. |
716 else | 714 if (this.signedIn_ && !syncData.signedIn) |
717 this.signedIn_ = syncData.signedIn; | 715 SyncSetupOverlay.closeOverlay(); |
718 | 716 |
719 // Display the "setup sync" button if we're signed in and sync is not | 717 this.signedIn_ = syncData.signedIn; |
720 // managed/disabled. | 718 |
721 $('customize-sync').hidden = !this.signedIn_ || | 719 // Display the "advanced settings" button if we're signed in and sync is |
| 720 // not managed/disabled. If the user is signed in, but sync is disabled, |
| 721 // this button is used to re-enable sync. |
| 722 var customizeSyncButton = $('customize-sync'); |
| 723 customizeSyncButton.hidden = !this.signedIn_ || |
722 syncData.managed || | 724 syncData.managed || |
723 !syncData.syncSystemEnabled; | 725 !syncData.syncSystemEnabled; |
| 726 customizeSyncButton.textContent = syncData.setupCompleted ? |
| 727 loadTimeData.getString('customizeSync') : |
| 728 loadTimeData.getString('syncButtonTextStart'); |
724 | 729 |
725 var startStopButton = $('start-stop-sync'); | 730 // Disable the "sign in" button if we're currently signing in, or if we're |
726 // Disable the "start/stop syncing" button if we're currently signing in, | 731 // already signed in and signout is not allowed. |
727 // or if we're already signed in and signout is not allowed. | 732 var signInButton = $('start-stop-sync'); |
728 startStopButton.disabled = syncData.setupInProgress || | 733 signInButton.disabled = syncData.setupInProgress || |
729 !syncData.signoutAllowed; | 734 !syncData.signoutAllowed; |
730 if (!syncData.signoutAllowed) | 735 if (!syncData.signoutAllowed) |
731 $('start-stop-sync-indicator').setAttribute('controlled-by', 'policy'); | 736 $('start-stop-sync-indicator').setAttribute('controlled-by', 'policy'); |
732 else | 737 else |
733 $('start-stop-sync-indicator').removeAttribute('controlled-by'); | 738 $('start-stop-sync-indicator').removeAttribute('controlled-by'); |
734 | 739 |
735 // Hide the "start/stop syncing" button on Chrome OS if sync has already | 740 // Hide the "sign in" button on Chrome OS, and show it on desktop Chrome. |
736 // been set up, or if it is managed or disabled. | 741 signInButton.hidden = cr.isChromeOS; |
737 startStopButton.hidden = cr.isChromeOS && (syncData.setupCompleted || | 742 |
738 syncData.isManaged || | 743 signInButton.textContent = |
739 !syncData.syncSystemEnabled); | |
740 startStopButton.textContent = | |
741 this.signedIn_ ? | 744 this.signedIn_ ? |
742 loadTimeData.getString('syncButtonTextStop') : | 745 loadTimeData.getString('syncButtonTextStop') : |
743 syncData.setupInProgress ? | 746 syncData.setupInProgress ? |
744 loadTimeData.getString('syncButtonTextInProgress') : | 747 loadTimeData.getString('syncButtonTextInProgress') : |
745 loadTimeData.getString('syncButtonTextStart'); | 748 loadTimeData.getString('syncButtonTextSignIn'); |
746 $('start-stop-sync-indicator').hidden = startStopButton.hidden; | 749 $('start-stop-sync-indicator').hidden = signInButton.hidden; |
747 | 750 |
748 // TODO(estade): can this just be textContent? | 751 // TODO(estade): can this just be textContent? |
749 $('sync-status-text').innerHTML = syncData.statusText; | 752 $('sync-status-text').innerHTML = syncData.statusText; |
750 var statusSet = syncData.statusText.length != 0; | 753 var statusSet = syncData.statusText.length != 0; |
751 $('sync-overview').hidden = statusSet; | 754 $('sync-overview').hidden = statusSet; |
752 $('sync-status').hidden = !statusSet; | 755 $('sync-status').hidden = !statusSet; |
753 | 756 |
754 $('sync-action-link').textContent = syncData.actionLinkText; | 757 $('sync-action-link').textContent = syncData.actionLinkText; |
755 // Don't show the action link if it is empty or undefined. | 758 // Don't show the action link if it is empty or undefined. |
756 $('sync-action-link').hidden = syncData.actionLinkText.length == 0; | 759 $('sync-action-link').hidden = syncData.actionLinkText.length == 0; |
757 $('sync-action-link').disabled = syncData.managed || | 760 $('sync-action-link').disabled = syncData.managed || |
758 !syncData.syncSystemEnabled; | 761 !syncData.syncSystemEnabled; |
759 | 762 |
760 // On Chrome OS, sign out the user and sign in again to get fresh | 763 // On Chrome OS, sign out the user and sign in again to get fresh |
761 // credentials on auth errors. | 764 // credentials on auth errors. |
762 $('sync-action-link').onclick = function(event) { | 765 $('sync-action-link').onclick = function(event) { |
763 if (cr.isChromeOS && syncData.hasError) | 766 if (cr.isChromeOS && syncData.hasError) |
764 SyncSetupOverlay.doSignOutOnAuthError(); | 767 SyncSetupOverlay.doSignOutOnAuthError(); |
765 else | 768 else |
766 SyncSetupOverlay.showErrorUI(); | 769 SyncSetupOverlay.showErrorUI(); |
767 }; | 770 }; |
768 | 771 |
769 if (syncData.hasError) | 772 if (syncData.hasError) |
770 $('sync-status').classList.add('sync-error'); | 773 $('sync-status').classList.add('sync-error'); |
771 else | 774 else |
772 $('sync-status').classList.remove('sync-error'); | 775 $('sync-status').classList.remove('sync-error'); |
773 | 776 |
774 $('customize-sync').disabled = syncData.hasUnrecoverableError; | 777 customizeSyncButton.disabled = syncData.hasUnrecoverableError; |
775 // Move #enable-auto-login-checkbox to a different location on CrOS. | 778 // Move #enable-auto-login-checkbox to a different location on CrOS. |
776 if (cr.isChromeOs) { | 779 if (cr.isChromeOs) { |
777 $('sync-general').insertBefore($('sync-status').nextSibling, | 780 $('sync-general').insertBefore($('sync-status').nextSibling, |
778 $('enable-auto-login-checkbox')); | 781 $('enable-auto-login-checkbox')); |
779 } | 782 } |
780 $('enable-auto-login-checkbox').hidden = !syncData.autoLoginVisible; | 783 $('enable-auto-login-checkbox').hidden = !syncData.autoLoginVisible; |
781 }, | 784 }, |
782 | 785 |
783 /** | 786 /** |
784 * Get the start/stop sync button DOM element. Used for testing. | 787 * Get the start/stop sync button DOM element. Used for testing. |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 BrowserOptions.getLoggedInUsername = function() { | 1446 BrowserOptions.getLoggedInUsername = function() { |
1444 return BrowserOptions.getInstance().username_; | 1447 return BrowserOptions.getInstance().username_; |
1445 }; | 1448 }; |
1446 } | 1449 } |
1447 | 1450 |
1448 // Export | 1451 // Export |
1449 return { | 1452 return { |
1450 BrowserOptions: BrowserOptions | 1453 BrowserOptions: BrowserOptions |
1451 }; | 1454 }; |
1452 }); | 1455 }); |
OLD | NEW |