| 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 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 updateAdvancedSettingsExpander_: function() { | 924 updateAdvancedSettingsExpander_: function() { |
| 906 var expander = $('advanced-settings-expander'); | 925 var expander = $('advanced-settings-expander'); |
| 907 if (BrowserOptions.shouldShowSection_($('advanced-settings'))) | 926 if (BrowserOptions.shouldShowSection_($('advanced-settings'))) |
| 908 expander.textContent = loadTimeData.getString('showAdvancedSettings'); | 927 expander.textContent = loadTimeData.getString('showAdvancedSettings'); |
| 909 else | 928 else |
| 910 expander.textContent = loadTimeData.getString('hideAdvancedSettings'); | 929 expander.textContent = loadTimeData.getString('hideAdvancedSettings'); |
| 911 }, | 930 }, |
| 912 | 931 |
| 913 /** | 932 /** |
| 914 * Updates the sync section with the given state. | 933 * Updates the sync section with the given state. |
| 915 * @param {Object} syncData A bunch of data records that describe the status | 934 * @param {options.SyncStatus} syncData A bunch of data records that |
| 916 * of the sync system. | 935 * describe the status of the sync system. |
| 917 * @private | 936 * @private |
| 918 */ | 937 */ |
| 919 updateSyncState_: function(syncData) { | 938 updateSyncState_: function(syncData) { |
| 920 if (!syncData.signinAllowed && | 939 if (!syncData.signinAllowed && |
| 921 (!syncData.supervisedUser || !cr.isChromeOS)) { | 940 (!syncData.supervisedUser || !cr.isChromeOS)) { |
| 922 $('sync-section').hidden = true; | 941 $('sync-section').hidden = true; |
| 923 this.maybeShowUserSection_(); | 942 this.maybeShowUserSection_(); |
| 924 return; | 943 return; |
| 925 } | 944 } |
| 926 | 945 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 946 // visible, say, due to a dashboard clear, close the dialog. | 965 // visible, say, due to a dashboard clear, close the dialog. |
| 947 // However, if the user gets signed out as a result of abandoning first | 966 // However, if the user gets signed out as a result of abandoning first |
| 948 // time sync setup, do not call closeOverlay as it will redirect the | 967 // time sync setup, do not call closeOverlay as it will redirect the |
| 949 // browser to the main settings page and override any in-progress | 968 // browser to the main settings page and override any in-progress |
| 950 // user-initiated navigation. See crbug.com/278030. | 969 // user-initiated navigation. See crbug.com/278030. |
| 951 // Note: SyncSetupOverlay.closeOverlay is a no-op if the overlay is | 970 // Note: SyncSetupOverlay.closeOverlay is a no-op if the overlay is |
| 952 // already hidden. | 971 // already hidden. |
| 953 if (this.signedIn_ && !syncData.signedIn && !syncData.setupInProgress) | 972 if (this.signedIn_ && !syncData.signedIn && !syncData.setupInProgress) |
| 954 SyncSetupOverlay.closeOverlay(); | 973 SyncSetupOverlay.closeOverlay(); |
| 955 | 974 |
| 956 this.signedIn_ = syncData.signedIn; | 975 this.signedIn_ = !!syncData.signedIn; |
| 957 | 976 |
| 958 // Display the "advanced settings" button if we're signed in and sync is | 977 // Display the "advanced settings" button if we're signed in and sync is |
| 959 // not managed/disabled. If the user is signed in, but sync is disabled, | 978 // not managed/disabled. If the user is signed in, but sync is disabled, |
| 960 // this button is used to re-enable sync. | 979 // this button is used to re-enable sync. |
| 961 var customizeSyncButton = $('customize-sync'); | 980 var customizeSyncButton = $('customize-sync'); |
| 962 customizeSyncButton.hidden = !this.signedIn_ || | 981 customizeSyncButton.hidden = !this.signedIn_ || |
| 963 syncData.managed || | 982 syncData.managed || |
| 964 !syncData.syncSystemEnabled; | 983 !syncData.syncSystemEnabled; |
| 965 | 984 |
| 966 // Only modify the customize button's text if the new text is different. | 985 // Only modify the customize button's text if the new text is different. |
| 967 // Otherwise, it can affect search-highlighting in the settings page. | 986 // Otherwise, it can affect search-highlighting in the settings page. |
| 968 // See http://crbug.com/268265. | 987 // See http://crbug.com/268265. |
| 969 var customizeSyncButtonNewText = syncData.setupCompleted ? | 988 var customizeSyncButtonNewText = syncData.setupCompleted ? |
| 970 loadTimeData.getString('customizeSync') : | 989 loadTimeData.getString('customizeSync') : |
| 971 loadTimeData.getString('syncButtonTextStart'); | 990 loadTimeData.getString('syncButtonTextStart'); |
| 972 if (customizeSyncButton.textContent != customizeSyncButtonNewText) | 991 if (customizeSyncButton.textContent != customizeSyncButtonNewText) |
| 973 customizeSyncButton.textContent = customizeSyncButtonNewText; | 992 customizeSyncButton.textContent = customizeSyncButtonNewText; |
| 974 | 993 |
| 975 // Disable the "sign in" button if we're currently signing in, or if we're | 994 // Disable the "sign in" button if we're currently signing in, or if we're |
| 976 // already signed in and signout is not allowed. | 995 // already signed in and signout is not allowed. |
| 977 var signInButton = $('start-stop-sync'); | 996 var signInButton = $('start-stop-sync'); |
| 978 signInButton.disabled = syncData.setupInProgress; | 997 signInButton.disabled = syncData.setupInProgress; |
| 979 this.signoutAllowed_ = syncData.signoutAllowed; | 998 this.signoutAllowed_ = !!syncData.signoutAllowed; |
| 980 if (!syncData.signoutAllowed) | 999 if (!syncData.signoutAllowed) |
| 981 $('start-stop-sync-indicator').setAttribute('controlled-by', 'policy'); | 1000 $('start-stop-sync-indicator').setAttribute('controlled-by', 'policy'); |
| 982 else | 1001 else |
| 983 $('start-stop-sync-indicator').removeAttribute('controlled-by'); | 1002 $('start-stop-sync-indicator').removeAttribute('controlled-by'); |
| 984 | 1003 |
| 985 // Hide the "sign in" button on Chrome OS, and show it on desktop Chrome | 1004 // Hide the "sign in" button on Chrome OS, and show it on desktop Chrome |
| 986 // (except for supervised users, which can't change their signed-in | 1005 // (except for supervised users, which can't change their signed-in |
| 987 // status). | 1006 // status). |
| 988 signInButton.hidden = cr.isChromeOS || syncData.supervisedUser; | 1007 signInButton.hidden = cr.isChromeOS || syncData.supervisedUser; |
| 989 | 1008 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 * @param {boolean} show True if the current profile manages any supervised | 1070 * @param {boolean} show True if the current profile manages any supervised |
| 1052 * users. | 1071 * users. |
| 1053 */ | 1072 */ |
| 1054 updateManagesSupervisedUsers_: function(show) { | 1073 updateManagesSupervisedUsers_: function(show) { |
| 1055 $('profiles-supervised-dashboard-tip').hidden = !show; | 1074 $('profiles-supervised-dashboard-tip').hidden = !show; |
| 1056 this.maybeShowUserSection_(); | 1075 this.maybeShowUserSection_(); |
| 1057 }, | 1076 }, |
| 1058 | 1077 |
| 1059 /** | 1078 /** |
| 1060 * Get the start/stop sync button DOM element. Used for testing. | 1079 * Get the start/stop sync button DOM element. Used for testing. |
| 1061 * @return {DOMElement} The start/stop sync button. | 1080 * @return {Element} The start/stop sync button. |
| 1062 * @private | 1081 * @private |
| 1063 */ | 1082 */ |
| 1064 getStartStopSyncButton_: function() { | 1083 getStartStopSyncButton_: function() { |
| 1065 return $('start-stop-sync'); | 1084 return $('start-stop-sync'); |
| 1066 }, | 1085 }, |
| 1067 | 1086 |
| 1068 /** | 1087 /** |
| 1069 * Event listener for the 'show home button' preference. Shows/hides the | 1088 * Event listener for the 'show home button' preference. Shows/hides the |
| 1070 * UI for changing the home page with animation, unless this is the first | 1089 * UI for changing the home page with animation, unless this is the first |
| 1071 * time this function is called, in which case there is no animation. | 1090 * 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... |
| 1205 /** | 1224 /** |
| 1206 * Updates the search engine popup with the given entries. | 1225 * Updates the search engine popup with the given entries. |
| 1207 * @param {Array} engines List of available search engines. | 1226 * @param {Array} engines List of available search engines. |
| 1208 * @param {number} defaultValue The value of the current default engine. | 1227 * @param {number} defaultValue The value of the current default engine. |
| 1209 * @param {boolean} defaultManaged Whether the default search provider is | 1228 * @param {boolean} defaultManaged Whether the default search provider is |
| 1210 * managed. If true, the default search provider can't be changed. | 1229 * managed. If true, the default search provider can't be changed. |
| 1211 * @private | 1230 * @private |
| 1212 */ | 1231 */ |
| 1213 updateSearchEngines_: function(engines, defaultValue, defaultManaged) { | 1232 updateSearchEngines_: function(engines, defaultValue, defaultManaged) { |
| 1214 this.clearSearchEngines_(); | 1233 this.clearSearchEngines_(); |
| 1215 engineSelect = $('default-search-engine'); | 1234 var engineSelect = $('default-search-engine'); |
| 1216 engineSelect.disabled = defaultManaged; | 1235 engineSelect.disabled = defaultManaged; |
| 1217 if (defaultManaged && defaultValue == -1) | 1236 if (defaultManaged && defaultValue == -1) |
| 1218 return; | 1237 return; |
| 1219 engineCount = engines.length; | 1238 var engineCount = engines.length; |
| 1220 var defaultIndex = -1; | 1239 var defaultIndex = -1; |
| 1221 for (var i = 0; i < engineCount; i++) { | 1240 for (var i = 0; i < engineCount; i++) { |
| 1222 var engine = engines[i]; | 1241 var engine = engines[i]; |
| 1223 var option = new Option(engine.name, engine.index); | 1242 var option = new Option(engine.name, engine.index); |
| 1224 if (defaultValue == option.value) | 1243 if (defaultValue == option.value) |
| 1225 defaultIndex = i; | 1244 defaultIndex = i; |
| 1226 engineSelect.appendChild(option); | 1245 engineSelect.appendChild(option); |
| 1227 } | 1246 } |
| 1228 if (defaultIndex >= 0) | 1247 if (defaultIndex >= 0) |
| 1229 engineSelect.selectedIndex = defaultIndex; | 1248 engineSelect.selectedIndex = defaultIndex; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 showSingleProfileView || OptionsPage.isSettingsApp(); | 1334 showSingleProfileView || OptionsPage.isSettingsApp(); |
| 1316 $('profiles-delete').textContent = showSingleProfileView ? | 1335 $('profiles-delete').textContent = showSingleProfileView ? |
| 1317 loadTimeData.getString('profilesDeleteSingle') : | 1336 loadTimeData.getString('profilesDeleteSingle') : |
| 1318 loadTimeData.getString('profilesDelete'); | 1337 loadTimeData.getString('profilesDelete'); |
| 1319 if (OptionsPage.isSettingsApp()) | 1338 if (OptionsPage.isSettingsApp()) |
| 1320 $('profiles-app-list-switch').hidden = showSingleProfileView; | 1339 $('profiles-app-list-switch').hidden = showSingleProfileView; |
| 1321 }, | 1340 }, |
| 1322 | 1341 |
| 1323 /** | 1342 /** |
| 1324 * Adds all |profiles| to the list. | 1343 * Adds all |profiles| to the list. |
| 1325 * @param {Array.<Object>} profiles An array of profile info objects. | 1344 * @param {Array.<{name: string, filePath: string, |
| 1326 * each object is of the form: | 1345 * isCurrentProfile: boolean, isSupervised: boolean}>} profiles An array |
| 1327 * profileInfo = { | 1346 * of profile info objects. |
| 1328 * name: "Profile Name", | |
| 1329 * iconURL: "chrome://path/to/icon/image", | |
| 1330 * filePath: "/path/to/profile/data/on/disk", | |
| 1331 * isCurrentProfile: false, | |
| 1332 * isSupervised: false | |
| 1333 * }; | |
| 1334 * @private | 1347 * @private |
| 1335 */ | 1348 */ |
| 1336 setProfilesInfo_: function(profiles) { | 1349 setProfilesInfo_: function(profiles) { |
| 1337 this.setProfileViewSingle_(profiles.length); | 1350 this.setProfileViewSingle_(profiles.length); |
| 1338 // add it to the list, even if the list is hidden so we can access it | 1351 // add it to the list, even if the list is hidden so we can access it |
| 1339 // later. | 1352 // later. |
| 1340 $('profiles-list').dataModel = new ArrayDataModel(profiles); | 1353 $('profiles-list').dataModel = new ArrayDataModel(profiles); |
| 1341 | 1354 |
| 1342 // Received new data. If showing the "manage" overlay, keep it up to | 1355 // Received new data. If showing the "manage" overlay, keep it up to |
| 1343 // date. If showing the "delete" overlay, close it. | 1356 // date. If showing the "delete" overlay, close it. |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 } | 2036 } |
| 2024 button.textContent = loadTimeData.getString(strId); | 2037 button.textContent = loadTimeData.getString(strId); |
| 2025 }; | 2038 }; |
| 2026 } | 2039 } |
| 2027 | 2040 |
| 2028 // Export | 2041 // Export |
| 2029 return { | 2042 return { |
| 2030 BrowserOptions: BrowserOptions | 2043 BrowserOptions: BrowserOptions |
| 2031 }; | 2044 }; |
| 2032 }); | 2045 }); |
| OLD | NEW |