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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 * @private | 699 * @private |
702 */ | 700 */ |
703 updateSyncState_: function(syncData) { | 701 updateSyncState_: function(syncData) { |
704 if (!syncData.signinAllowed) { | 702 if (!syncData.signinAllowed) { |
705 $('sync-section').hidden = true; | 703 $('sync-section').hidden = true; |
706 return; | 704 return; |
707 } | 705 } |
708 | 706 |
709 $('sync-section').hidden = false; | 707 $('sync-section').hidden = false; |
710 | 708 |
711 if (cr.isChromeOS) | 709 // If the user gets signed out while the advanced sync settings dialog is |
712 this.signedIn_ = syncData.setupCompleted; | 710 // visible, say, due to a dashboard clear, close the dialog. |
713 else | 711 if (this.signedIn_ && !syncData.signedIn) |
714 this.signedIn_ = syncData.signedIn; | 712 SyncSetupOverlay.closeOverlay(); |
715 | 713 |
716 // Display the "setup sync" button if we're signed in and sync is not | 714 this.signedIn_ = syncData.signedIn; |
717 // managed/disabled. | 715 |
718 $('customize-sync').hidden = !this.signedIn_ || | 716 // Display the "advanced settings" button if we're signed in and sync is |
| 717 // not managed/disabled. If the user is signed in, but sync is disabled, |
| 718 // this button is used to re-enable sync. |
| 719 var customizeSyncButton = $('customize-sync'); |
| 720 customizeSyncButton.hidden = !this.signedIn_ || |
719 syncData.managed || | 721 syncData.managed || |
720 !syncData.syncSystemEnabled; | 722 !syncData.syncSystemEnabled; |
| 723 customizeSyncButton.textContent = syncData.setupCompleted ? |
| 724 loadTimeData.getString('customizeSync') : |
| 725 loadTimeData.getString('syncButtonTextStart'); |
721 | 726 |
722 var startStopButton = $('start-stop-sync'); | 727 // Disable the "sign in" button if we're currently signing in, or if we're |
723 // Disable the "start/stop syncing" button if we're currently signing in, | 728 // already signed in and signout is not allowed. |
724 // or if we're already signed in and signout is not allowed. | 729 var signInButton = $('start-stop-sync'); |
725 startStopButton.disabled = syncData.setupInProgress || | 730 signInButton.disabled = syncData.setupInProgress || |
726 !syncData.signoutAllowed; | 731 !syncData.signoutAllowed; |
727 if (!syncData.signoutAllowed) | 732 if (!syncData.signoutAllowed) |
728 $('start-stop-sync-indicator').setAttribute('controlled-by', 'policy'); | 733 $('start-stop-sync-indicator').setAttribute('controlled-by', 'policy'); |
729 else | 734 else |
730 $('start-stop-sync-indicator').removeAttribute('controlled-by'); | 735 $('start-stop-sync-indicator').removeAttribute('controlled-by'); |
731 | 736 |
732 // Hide the "start/stop syncing" button on Chrome OS if sync has already | 737 // Hide the "sign in" button on Chrome OS, and show it on desktop Chrome. |
733 // been set up, or if it is managed or disabled. | 738 signInButton.hidden = cr.isChromeOS; |
734 startStopButton.hidden = cr.isChromeOS && (syncData.setupCompleted || | 739 |
735 syncData.isManaged || | 740 signInButton.textContent = |
736 !syncData.syncSystemEnabled); | |
737 startStopButton.textContent = | |
738 this.signedIn_ ? | 741 this.signedIn_ ? |
739 loadTimeData.getString('syncButtonTextStop') : | 742 loadTimeData.getString('syncButtonTextStop') : |
740 syncData.setupInProgress ? | 743 syncData.setupInProgress ? |
741 loadTimeData.getString('syncButtonTextInProgress') : | 744 loadTimeData.getString('syncButtonTextInProgress') : |
742 loadTimeData.getString('syncButtonTextStart'); | 745 loadTimeData.getString('syncButtonTextSignIn'); |
743 $('start-stop-sync-indicator').hidden = startStopButton.hidden; | 746 $('start-stop-sync-indicator').hidden = signInButton.hidden; |
744 | 747 |
745 // TODO(estade): can this just be textContent? | 748 // TODO(estade): can this just be textContent? |
746 $('sync-status-text').innerHTML = syncData.statusText; | 749 $('sync-status-text').innerHTML = syncData.statusText; |
747 var statusSet = syncData.statusText.length != 0; | 750 var statusSet = syncData.statusText.length != 0; |
748 $('sync-overview').hidden = statusSet; | 751 $('sync-overview').hidden = statusSet; |
749 $('sync-status').hidden = !statusSet; | 752 $('sync-status').hidden = !statusSet; |
750 | 753 |
751 $('sync-action-link').textContent = syncData.actionLinkText; | 754 $('sync-action-link').textContent = syncData.actionLinkText; |
752 // Don't show the action link if it is empty or undefined. | 755 // Don't show the action link if it is empty or undefined. |
753 $('sync-action-link').hidden = syncData.actionLinkText.length == 0; | 756 $('sync-action-link').hidden = syncData.actionLinkText.length == 0; |
754 $('sync-action-link').disabled = syncData.managed || | 757 $('sync-action-link').disabled = syncData.managed || |
755 !syncData.syncSystemEnabled; | 758 !syncData.syncSystemEnabled; |
756 | 759 |
757 // On Chrome OS, sign out the user and sign in again to get fresh | 760 // On Chrome OS, sign out the user and sign in again to get fresh |
758 // credentials on auth errors. | 761 // credentials on auth errors. |
759 $('sync-action-link').onclick = function(event) { | 762 $('sync-action-link').onclick = function(event) { |
760 if (cr.isChromeOS && syncData.hasError) | 763 if (cr.isChromeOS && syncData.hasError) |
761 SyncSetupOverlay.doSignOutOnAuthError(); | 764 SyncSetupOverlay.doSignOutOnAuthError(); |
762 else | 765 else |
763 SyncSetupOverlay.showErrorUI(); | 766 SyncSetupOverlay.showErrorUI(); |
764 }; | 767 }; |
765 | 768 |
766 if (syncData.hasError) | 769 if (syncData.hasError) |
767 $('sync-status').classList.add('sync-error'); | 770 $('sync-status').classList.add('sync-error'); |
768 else | 771 else |
769 $('sync-status').classList.remove('sync-error'); | 772 $('sync-status').classList.remove('sync-error'); |
770 | 773 |
771 $('customize-sync').disabled = syncData.hasUnrecoverableError; | 774 customizeSyncButton.disabled = syncData.hasUnrecoverableError; |
772 // Move #enable-auto-login-checkbox to a different location on CrOS. | 775 // Move #enable-auto-login-checkbox to a different location on CrOS. |
773 if (cr.isChromeOs) { | 776 if (cr.isChromeOs) { |
774 $('sync-general').insertBefore($('sync-status').nextSibling, | 777 $('sync-general').insertBefore($('sync-status').nextSibling, |
775 $('enable-auto-login-checkbox')); | 778 $('enable-auto-login-checkbox')); |
776 } | 779 } |
777 $('enable-auto-login-checkbox').hidden = !syncData.autoLoginVisible; | 780 $('enable-auto-login-checkbox').hidden = !syncData.autoLoginVisible; |
778 }, | 781 }, |
779 | 782 |
780 /** | 783 /** |
781 * Get the start/stop sync button DOM element. Used for testing. | 784 * Get the start/stop sync button DOM element. Used for testing. |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 BrowserOptions.getLoggedInUsername = function() { | 1443 BrowserOptions.getLoggedInUsername = function() { |
1441 return BrowserOptions.getInstance().username_; | 1444 return BrowserOptions.getInstance().username_; |
1442 }; | 1445 }; |
1443 } | 1446 } |
1444 | 1447 |
1445 // Export | 1448 // Export |
1446 return { | 1449 return { |
1447 BrowserOptions: BrowserOptions | 1450 BrowserOptions: BrowserOptions |
1448 }; | 1451 }; |
1449 }); | 1452 }); |
OLD | NEW |