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'); |
| 6 |
| 7 /** |
| 8 * @typedef {{actionLinkText: (string|undefined), |
| 9 * hasError: (boolean|undefined), |
| 10 * hasUnrecoverableError: (boolean|undefined), |
| 11 * managed: (boolean|undefined), |
| 12 * setupCompleted: (boolean|undefined), |
| 13 * setupInProgress: (boolean|undefined), |
| 14 * signedIn: (boolean|undefined), |
| 15 * signinAllowed: (boolean|undefined), |
| 16 * signinAllowed: boolean, |
| 17 * signoutAllowed: (boolean|undefined), |
| 18 * statusText: (string|undefined), |
| 19 * syncSystemEnabled: (boolean|undefined)}} |
| 20 * @see chrome/browser/ui/webui/options/browser_options_handler.cc |
| 21 */ |
| 22 options.SyncStatus; |
| 23 |
5 cr.define('options', function() { | 24 cr.define('options', function() { |
6 var OptionsPage = options.OptionsPage; | 25 var OptionsPage = options.OptionsPage; |
7 var Page = cr.ui.pageManager.Page; | 26 var Page = cr.ui.pageManager.Page; |
8 var PageManager = cr.ui.pageManager.PageManager; | 27 var PageManager = cr.ui.pageManager.PageManager; |
9 var ArrayDataModel = cr.ui.ArrayDataModel; | 28 var ArrayDataModel = cr.ui.ArrayDataModel; |
10 var RepeatingButton = cr.ui.RepeatingButton; | 29 var RepeatingButton = cr.ui.RepeatingButton; |
11 var HotwordSearchSettingIndicator = options.HotwordSearchSettingIndicator; | 30 var HotwordSearchSettingIndicator = options.HotwordSearchSettingIndicator; |
12 var NetworkPredictionOptions = { | 31 var NetworkPredictionOptions = { |
13 ALWAYS: 0, | 32 ALWAYS: 0, |
14 WIFI_ONLY: 1, | 33 WIFI_ONLY: 1, |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 updateAdvancedSettingsExpander_: function() { | 913 updateAdvancedSettingsExpander_: function() { |
895 var expander = $('advanced-settings-expander'); | 914 var expander = $('advanced-settings-expander'); |
896 if (BrowserOptions.shouldShowSection_($('advanced-settings'))) | 915 if (BrowserOptions.shouldShowSection_($('advanced-settings'))) |
897 expander.textContent = loadTimeData.getString('showAdvancedSettings'); | 916 expander.textContent = loadTimeData.getString('showAdvancedSettings'); |
898 else | 917 else |
899 expander.textContent = loadTimeData.getString('hideAdvancedSettings'); | 918 expander.textContent = loadTimeData.getString('hideAdvancedSettings'); |
900 }, | 919 }, |
901 | 920 |
902 /** | 921 /** |
903 * Updates the sync section with the given state. | 922 * Updates the sync section with the given state. |
904 * @param {Object} syncData A bunch of data records that describe the status | 923 * @param {options.SyncStatus} syncData A bunch of data records that |
905 * of the sync system. | 924 * describe the status of the sync system. |
906 * @private | 925 * @private |
907 */ | 926 */ |
908 updateSyncState_: function(syncData) { | 927 updateSyncState_: function(syncData) { |
909 if (!syncData.signinAllowed && | 928 if (!syncData.signinAllowed && |
910 (!syncData.supervisedUser || !cr.isChromeOS)) { | 929 (!syncData.supervisedUser || !cr.isChromeOS)) { |
911 $('sync-section').hidden = true; | 930 $('sync-section').hidden = true; |
912 this.maybeShowUserSection_(); | 931 this.maybeShowUserSection_(); |
913 return; | 932 return; |
914 } | 933 } |
915 | 934 |
(...skipping 19 matching lines...) Expand all Loading... |
935 // visible, say, due to a dashboard clear, close the dialog. | 954 // visible, say, due to a dashboard clear, close the dialog. |
936 // However, if the user gets signed out as a result of abandoning first | 955 // However, if the user gets signed out as a result of abandoning first |
937 // time sync setup, do not call closeOverlay as it will redirect the | 956 // time sync setup, do not call closeOverlay as it will redirect the |
938 // browser to the main settings page and override any in-progress | 957 // browser to the main settings page and override any in-progress |
939 // user-initiated navigation. See crbug.com/278030. | 958 // user-initiated navigation. See crbug.com/278030. |
940 // Note: SyncSetupOverlay.closeOverlay is a no-op if the overlay is | 959 // Note: SyncSetupOverlay.closeOverlay is a no-op if the overlay is |
941 // already hidden. | 960 // already hidden. |
942 if (this.signedIn_ && !syncData.signedIn && !syncData.setupInProgress) | 961 if (this.signedIn_ && !syncData.signedIn && !syncData.setupInProgress) |
943 SyncSetupOverlay.closeOverlay(); | 962 SyncSetupOverlay.closeOverlay(); |
944 | 963 |
945 this.signedIn_ = syncData.signedIn; | 964 this.signedIn_ = !!syncData.signedIn; |
946 | 965 |
947 // Display the "advanced settings" button if we're signed in and sync is | 966 // Display the "advanced settings" button if we're signed in and sync is |
948 // not managed/disabled. If the user is signed in, but sync is disabled, | 967 // not managed/disabled. If the user is signed in, but sync is disabled, |
949 // this button is used to re-enable sync. | 968 // this button is used to re-enable sync. |
950 var customizeSyncButton = $('customize-sync'); | 969 var customizeSyncButton = $('customize-sync'); |
951 customizeSyncButton.hidden = !this.signedIn_ || | 970 customizeSyncButton.hidden = !this.signedIn_ || |
952 syncData.managed || | 971 syncData.managed || |
953 !syncData.syncSystemEnabled; | 972 !syncData.syncSystemEnabled; |
954 | 973 |
955 // Only modify the customize button's text if the new text is different. | 974 // Only modify the customize button's text if the new text is different. |
956 // Otherwise, it can affect search-highlighting in the settings page. | 975 // Otherwise, it can affect search-highlighting in the settings page. |
957 // See http://crbug.com/268265. | 976 // See http://crbug.com/268265. |
958 var customizeSyncButtonNewText = syncData.setupCompleted ? | 977 var customizeSyncButtonNewText = syncData.setupCompleted ? |
959 loadTimeData.getString('customizeSync') : | 978 loadTimeData.getString('customizeSync') : |
960 loadTimeData.getString('syncButtonTextStart'); | 979 loadTimeData.getString('syncButtonTextStart'); |
961 if (customizeSyncButton.textContent != customizeSyncButtonNewText) | 980 if (customizeSyncButton.textContent != customizeSyncButtonNewText) |
962 customizeSyncButton.textContent = customizeSyncButtonNewText; | 981 customizeSyncButton.textContent = customizeSyncButtonNewText; |
963 | 982 |
964 // Disable the "sign in" button if we're currently signing in, or if we're | 983 // Disable the "sign in" button if we're currently signing in, or if we're |
965 // already signed in and signout is not allowed. | 984 // already signed in and signout is not allowed. |
966 var signInButton = $('start-stop-sync'); | 985 var signInButton = $('start-stop-sync'); |
967 signInButton.disabled = syncData.setupInProgress; | 986 signInButton.disabled = syncData.setupInProgress; |
968 this.signoutAllowed_ = syncData.signoutAllowed; | 987 this.signoutAllowed_ = !!syncData.signoutAllowed; |
969 if (!syncData.signoutAllowed) | 988 if (!syncData.signoutAllowed) |
970 $('start-stop-sync-indicator').setAttribute('controlled-by', 'policy'); | 989 $('start-stop-sync-indicator').setAttribute('controlled-by', 'policy'); |
971 else | 990 else |
972 $('start-stop-sync-indicator').removeAttribute('controlled-by'); | 991 $('start-stop-sync-indicator').removeAttribute('controlled-by'); |
973 | 992 |
974 // Hide the "sign in" button on Chrome OS, and show it on desktop Chrome | 993 // Hide the "sign in" button on Chrome OS, and show it on desktop Chrome |
975 // (except for supervised users, which can't change their signed-in | 994 // (except for supervised users, which can't change their signed-in |
976 // status). | 995 // status). |
977 signInButton.hidden = cr.isChromeOS || syncData.supervisedUser; | 996 signInButton.hidden = cr.isChromeOS || syncData.supervisedUser; |
978 | 997 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 * @param {boolean} show True if the current profile manages any supervised | 1059 * @param {boolean} show True if the current profile manages any supervised |
1041 * users. | 1060 * users. |
1042 */ | 1061 */ |
1043 updateManagesSupervisedUsers_: function(show) { | 1062 updateManagesSupervisedUsers_: function(show) { |
1044 $('profiles-supervised-dashboard-tip').hidden = !show; | 1063 $('profiles-supervised-dashboard-tip').hidden = !show; |
1045 this.maybeShowUserSection_(); | 1064 this.maybeShowUserSection_(); |
1046 }, | 1065 }, |
1047 | 1066 |
1048 /** | 1067 /** |
1049 * Get the start/stop sync button DOM element. Used for testing. | 1068 * Get the start/stop sync button DOM element. Used for testing. |
1050 * @return {DOMElement} The start/stop sync button. | 1069 * @return {Element} The start/stop sync button. |
1051 * @private | 1070 * @private |
1052 */ | 1071 */ |
1053 getStartStopSyncButton_: function() { | 1072 getStartStopSyncButton_: function() { |
1054 return $('start-stop-sync'); | 1073 return $('start-stop-sync'); |
1055 }, | 1074 }, |
1056 | 1075 |
1057 /** | 1076 /** |
1058 * Event listener for the 'show home button' preference. Shows/hides the | 1077 * Event listener for the 'show home button' preference. Shows/hides the |
1059 * UI for changing the home page with animation, unless this is the first | 1078 * UI for changing the home page with animation, unless this is the first |
1060 * time this function is called, in which case there is no animation. | 1079 * time this function is called, in which case there is no animation. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 /** | 1213 /** |
1195 * Updates the search engine popup with the given entries. | 1214 * Updates the search engine popup with the given entries. |
1196 * @param {Array} engines List of available search engines. | 1215 * @param {Array} engines List of available search engines. |
1197 * @param {number} defaultValue The value of the current default engine. | 1216 * @param {number} defaultValue The value of the current default engine. |
1198 * @param {boolean} defaultManaged Whether the default search provider is | 1217 * @param {boolean} defaultManaged Whether the default search provider is |
1199 * managed. If true, the default search provider can't be changed. | 1218 * managed. If true, the default search provider can't be changed. |
1200 * @private | 1219 * @private |
1201 */ | 1220 */ |
1202 updateSearchEngines_: function(engines, defaultValue, defaultManaged) { | 1221 updateSearchEngines_: function(engines, defaultValue, defaultManaged) { |
1203 this.clearSearchEngines_(); | 1222 this.clearSearchEngines_(); |
1204 engineSelect = $('default-search-engine'); | 1223 var engineSelect = $('default-search-engine'); |
1205 engineSelect.disabled = defaultManaged; | 1224 engineSelect.disabled = defaultManaged; |
1206 if (defaultManaged && defaultValue == -1) | 1225 if (defaultManaged && defaultValue == -1) |
1207 return; | 1226 return; |
1208 engineCount = engines.length; | 1227 var engineCount = engines.length; |
1209 var defaultIndex = -1; | 1228 var defaultIndex = -1; |
1210 for (var i = 0; i < engineCount; i++) { | 1229 for (var i = 0; i < engineCount; i++) { |
1211 var engine = engines[i]; | 1230 var engine = engines[i]; |
1212 var option = new Option(engine.name, engine.index); | 1231 var option = new Option(engine.name, engine.index); |
1213 if (defaultValue == option.value) | 1232 if (defaultValue == option.value) |
1214 defaultIndex = i; | 1233 defaultIndex = i; |
1215 engineSelect.appendChild(option); | 1234 engineSelect.appendChild(option); |
1216 } | 1235 } |
1217 if (defaultIndex >= 0) | 1236 if (defaultIndex >= 0) |
1218 engineSelect.selectedIndex = defaultIndex; | 1237 engineSelect.selectedIndex = defaultIndex; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 showSingleProfileView || OptionsPage.isSettingsApp(); | 1323 showSingleProfileView || OptionsPage.isSettingsApp(); |
1305 $('profiles-delete').textContent = showSingleProfileView ? | 1324 $('profiles-delete').textContent = showSingleProfileView ? |
1306 loadTimeData.getString('profilesDeleteSingle') : | 1325 loadTimeData.getString('profilesDeleteSingle') : |
1307 loadTimeData.getString('profilesDelete'); | 1326 loadTimeData.getString('profilesDelete'); |
1308 if (OptionsPage.isSettingsApp()) | 1327 if (OptionsPage.isSettingsApp()) |
1309 $('profiles-app-list-switch').hidden = showSingleProfileView; | 1328 $('profiles-app-list-switch').hidden = showSingleProfileView; |
1310 }, | 1329 }, |
1311 | 1330 |
1312 /** | 1331 /** |
1313 * Adds all |profiles| to the list. | 1332 * Adds all |profiles| to the list. |
1314 * @param {Array.<Object>} profiles An array of profile info objects. | 1333 * @param {Array.<{name: string, filePath: string, |
1315 * each object is of the form: | 1334 * isCurrentProfile: boolean, isSupervised: boolean}>} profiles An array |
1316 * profileInfo = { | 1335 * of profile info objects. |
1317 * name: "Profile Name", | |
1318 * iconURL: "chrome://path/to/icon/image", | |
1319 * filePath: "/path/to/profile/data/on/disk", | |
1320 * isCurrentProfile: false, | |
1321 * isSupervised: false | |
1322 * }; | |
1323 * @private | 1336 * @private |
1324 */ | 1337 */ |
1325 setProfilesInfo_: function(profiles) { | 1338 setProfilesInfo_: function(profiles) { |
1326 this.setProfileViewSingle_(profiles.length); | 1339 this.setProfileViewSingle_(profiles.length); |
1327 // add it to the list, even if the list is hidden so we can access it | 1340 // add it to the list, even if the list is hidden so we can access it |
1328 // later. | 1341 // later. |
1329 $('profiles-list').dataModel = new ArrayDataModel(profiles); | 1342 $('profiles-list').dataModel = new ArrayDataModel(profiles); |
1330 | 1343 |
1331 // Received new data. If showing the "manage" overlay, keep it up to | 1344 // Received new data. If showing the "manage" overlay, keep it up to |
1332 // date. If showing the "delete" overlay, close it. | 1345 // date. If showing the "delete" overlay, close it. |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2014 } | 2027 } |
2015 button.textContent = loadTimeData.getString(strId); | 2028 button.textContent = loadTimeData.getString(strId); |
2016 }; | 2029 }; |
2017 } | 2030 } |
2018 | 2031 |
2019 // Export | 2032 // Export |
2020 return { | 2033 return { |
2021 BrowserOptions: BrowserOptions | 2034 BrowserOptions: BrowserOptions |
2022 }; | 2035 }; |
2023 }); | 2036 }); |
OLD | NEW |