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 // |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 self.toggleSectionWithAnimation_( | 70 self.toggleSectionWithAnimation_( |
71 $('advanced-settings'), | 71 $('advanced-settings'), |
72 $('advanced-settings-container')); | 72 $('advanced-settings-container')); |
73 } | 73 } |
74 $('advanced-settings').addEventListener('webkitTransitionEnd', | 74 $('advanced-settings').addEventListener('webkitTransitionEnd', |
75 function(event) { | 75 function(event) { |
76 self.onTransitionEnd_(event); | 76 self.onTransitionEnd_(event); |
77 self.updateAdvancedSettingsExpander_(); | 77 self.updateAdvancedSettingsExpander_(); |
78 }); | 78 }); |
79 | 79 |
| 80 if (cr.isChromeOS) |
| 81 AccountsOptions.applyGuestModeVisibility(document); |
| 82 |
80 // Sync (Sign in) section. | 83 // Sync (Sign in) section. |
81 this.updateSyncState_(templateData.syncData); | 84 this.updateSyncState_(templateData.syncData); |
82 | 85 |
83 $('sync-action-link').onclick = function(event) { | 86 $('sync-action-link').onclick = function(event) { |
84 SyncSetupOverlay.showErrorUI(); | 87 SyncSetupOverlay.showErrorUI(); |
85 }; | 88 }; |
86 $('start-stop-sync').onclick = function(event) { | 89 $('start-stop-sync').onclick = function(event) { |
87 if (self.syncSetupCompleted) | 90 if (self.syncSetupCompleted) |
88 SyncSetupOverlay.showStopSyncingUI(); | 91 SyncSetupOverlay.showStopSyncingUI(); |
89 else | 92 else |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 if (selectedProfile) | 220 if (selectedProfile) |
218 ManageProfileOverlay.showManageDialog(selectedProfile); | 221 ManageProfileOverlay.showManageDialog(selectedProfile); |
219 }; | 222 }; |
220 $('profiles-delete').onclick = function(event) { | 223 $('profiles-delete').onclick = function(event) { |
221 var selectedProfile = self.getSelectedProfileItem_(); | 224 var selectedProfile = self.getSelectedProfileItem_(); |
222 if (selectedProfile) | 225 if (selectedProfile) |
223 ManageProfileOverlay.showDeleteDialog(selectedProfile); | 226 ManageProfileOverlay.showDeleteDialog(selectedProfile); |
224 }; | 227 }; |
225 | 228 |
226 if (cr.isChromeOS) { | 229 if (cr.isChromeOS) { |
| 230 if (!AccountsOptions.loggedInAsGuest()) { |
| 231 $('account-picture-wrapper').onclick = function(event) { |
| 232 OptionsPage.navigateToPage('changePicture'); |
| 233 }; |
| 234 } |
| 235 |
227 // Username (canonical email) of the currently logged in user or | 236 // Username (canonical email) of the currently logged in user or |
228 // |kGuestUser| if a guest session is active. | 237 // |kGuestUser| if a guest session is active. |
229 this.username_ = localStrings.getString('username'); | 238 this.username_ = localStrings.getString('username'); |
230 | 239 |
231 this.updateAccountPicture_(); | 240 this.updateAccountPicture_(); |
232 | 241 |
233 if (cr.commandLine && cr.commandLine.options['--bwsi']) { | |
234 // Disable the screen lock checkbox in guest mode. | |
235 $('enable-screen-lock').disabled = true; | |
236 | |
237 // Hide the startup section in Guest mode. | |
238 $('startup-section').hidden = true; | |
239 } else { | |
240 $('account-picture-wrapper').onclick = function(event) { | |
241 OptionsPage.navigateToPage('changePicture'); | |
242 }; | |
243 } | |
244 | |
245 $('manage-accounts-button').onclick = function(event) { | 242 $('manage-accounts-button').onclick = function(event) { |
246 OptionsPage.navigateToPage('accounts'); | 243 OptionsPage.navigateToPage('accounts'); |
247 chrome.send('coreOptionsUserMetricsAction', | 244 chrome.send('coreOptionsUserMetricsAction', |
248 ['Options_ManageAccounts']); | 245 ['Options_ManageAccounts']); |
249 }; | 246 }; |
250 } else { | 247 } else { |
251 $('import-data').onclick = function(event) { | 248 $('import-data').onclick = function(event) { |
252 ImportDataOverlay.show(); | 249 ImportDataOverlay.show(); |
253 chrome.send('coreOptionsUserMetricsAction', ['Import_ShowDlg']); | 250 chrome.send('coreOptionsUserMetricsAction', ['Import_ShowDlg']); |
254 }; | 251 }; |
255 | 252 |
256 if ($('themes-GTK-button')) { | 253 if ($('themes-GTK-button')) { |
257 $('themes-GTK-button').onclick = function(event) { | 254 $('themes-GTK-button').onclick = function(event) { |
258 chrome.send('themesSetGTK'); | 255 chrome.send('themesSetGTK'); |
259 }; | 256 }; |
260 } | 257 } |
261 } | 258 } |
262 | 259 |
263 // Default browser section. | 260 // Default browser section. |
264 if (!cr.isChromeOS) { | 261 if (!cr.isChromeOS) { |
265 $('set-as-default-browser').onclick = function(event) { | 262 $('set-as-default-browser').onclick = function(event) { |
266 chrome.send('becomeDefaultBrowser'); | 263 chrome.send('becomeDefaultBrowser'); |
267 }; | 264 }; |
268 | 265 |
269 $('auto-launch').onclick = this.handleAutoLaunchChanged_; | 266 $('auto-launch').onclick = this.handleAutoLaunchChanged_; |
270 } | 267 } |
271 | 268 |
272 // Date and time section (CrOS only). | |
273 if (cr.isChromeOS && AccountsOptions.loggedInAsGuest()) { | |
274 // Disable time-related settings if we're not logged in as a real user. | |
275 $('timezone-select').disabled = true; | |
276 $('use-24hour-clock').disabled = true; | |
277 } | |
278 | |
279 // Privacy section. | 269 // Privacy section. |
280 $('privacyContentSettingsButton').onclick = function(event) { | 270 $('privacyContentSettingsButton').onclick = function(event) { |
281 OptionsPage.navigateToPage('content'); | 271 OptionsPage.navigateToPage('content'); |
282 OptionsPage.showTab($('cookies-nav-tab')); | 272 OptionsPage.showTab($('cookies-nav-tab')); |
283 chrome.send('coreOptionsUserMetricsAction', | 273 chrome.send('coreOptionsUserMetricsAction', |
284 ['Options_ContentSettings']); | 274 ['Options_ContentSettings']); |
285 }; | 275 }; |
286 $('privacyClearDataButton').onclick = function(event) { | 276 $('privacyClearDataButton').onclick = function(event) { |
287 OptionsPage.navigateToPage('clearBrowserData'); | 277 OptionsPage.navigateToPage('clearBrowserData'); |
288 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); | 278 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 OptionsPage.navigateToPage('autofill'); | 325 OptionsPage.navigateToPage('autofill'); |
336 chrome.send('coreOptionsUserMetricsAction', | 326 chrome.send('coreOptionsUserMetricsAction', |
337 ['Options_ShowAutofillSettings']); | 327 ['Options_ShowAutofillSettings']); |
338 }; | 328 }; |
339 $('manage-passwords').onclick = function(event) { | 329 $('manage-passwords').onclick = function(event) { |
340 OptionsPage.navigateToPage('passwords'); | 330 OptionsPage.navigateToPage('passwords'); |
341 OptionsPage.showTab($('passwords-nav-tab')); | 331 OptionsPage.showTab($('passwords-nav-tab')); |
342 chrome.send('coreOptionsUserMetricsAction', | 332 chrome.send('coreOptionsUserMetricsAction', |
343 ['Options_ShowPasswordManager']); | 333 ['Options_ShowPasswordManager']); |
344 }; | 334 }; |
345 if (this.guestModeActive_()) { | 335 if (cr.isChromeOS && AccountsOptions.loggedInAsGuest()) { |
346 // Disable and turn off Autofill in guest mode. | 336 // Disable and turn off Autofill in guest mode. |
347 var autofillEnabled = $('autofill-enabled'); | 337 var autofillEnabled = $('autofill-enabled'); |
348 autofillEnabled.disabled = true; | 338 autofillEnabled.disabled = true; |
349 autofillEnabled.checked = false; | 339 autofillEnabled.checked = false; |
350 cr.dispatchSimpleEvent(autofillEnabled, 'change'); | 340 cr.dispatchSimpleEvent(autofillEnabled, 'change'); |
351 $('autofill-settings').disabled = true; | 341 $('autofill-settings').disabled = true; |
352 | 342 |
353 // Disable and turn off Password Manager in guest mode. | 343 // Disable and turn off Password Manager in guest mode. |
354 var passwordManagerEnabled = $('password-manager-enabled'); | 344 var passwordManagerEnabled = $('password-manager-enabled'); |
355 passwordManagerEnabled.disabled = true; | 345 passwordManagerEnabled.disabled = true; |
356 passwordManagerEnabled.checked = false; | 346 passwordManagerEnabled.checked = false; |
357 cr.dispatchSimpleEvent(passwordManagerEnabled, 'change'); | 347 cr.dispatchSimpleEvent(passwordManagerEnabled, 'change'); |
358 $('manage-passwords').disabled = true; | 348 $('manage-passwords').disabled = true; |
359 | |
360 // Hide the entire section on ChromeOS | |
361 if (cr.isChromeOS) | |
362 $('passwords-and-autofill-section').hidden = true; | |
363 } | 349 } |
364 | 350 |
365 if (cr.isMac) | 351 if (cr.isMac) |
366 $('mac-passwords-warning').hidden = !templateData.multiple_profiles; | 352 $('mac-passwords-warning').hidden = !templateData.multiple_profiles; |
367 | 353 |
368 // Network section. | 354 // Network section. |
369 if (!cr.isChromeOS) { | 355 if (!cr.isChromeOS) { |
370 $('proxiesConfigureButton').onclick = function(event) { | 356 $('proxiesConfigureButton').onclick = function(event) { |
371 chrome.send('showNetworkProxySettings'); | 357 chrome.send('showNetworkProxySettings'); |
372 }; | 358 }; |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 * @private | 947 * @private |
962 */ | 948 */ |
963 setMetricsReportingSettingVisibility_: function(visible) { | 949 setMetricsReportingSettingVisibility_: function(visible) { |
964 if (visible) | 950 if (visible) |
965 $('metricsReportingSetting').style.display = 'block'; | 951 $('metricsReportingSetting').style.display = 'block'; |
966 else | 952 else |
967 $('metricsReportingSetting').style.display = 'none'; | 953 $('metricsReportingSetting').style.display = 'none'; |
968 }, | 954 }, |
969 | 955 |
970 /** | 956 /** |
971 * Returns whether the browser in guest mode. Some features are disabled or | |
972 * hidden in guest mode. | |
973 * @return {boolean} True if guest mode is currently active. | |
974 * @private | |
975 */ | |
976 guestModeActive_: function() { | |
977 return cr.commandLine && cr.commandLine.options['--bwsi']; | |
978 }, | |
979 | |
980 /** | |
981 * Set the font size selected item. | 957 * Set the font size selected item. |
982 * @private | 958 * @private |
983 */ | 959 */ |
984 setFontSize_: function(font_size_value) { | 960 setFontSize_: function(font_size_value) { |
985 var selectCtl = $('defaultFontSize'); | 961 var selectCtl = $('defaultFontSize'); |
986 for (var i = 0; i < selectCtl.options.length; i++) { | 962 for (var i = 0; i < selectCtl.options.length; i++) { |
987 if (selectCtl.options[i].value == font_size_value) { | 963 if (selectCtl.options[i].value == font_size_value) { |
988 selectCtl.selectedIndex = i; | 964 selectCtl.selectedIndex = i; |
989 if ($('Custom')) | 965 if ($('Custom')) |
990 selectCtl.remove($('Custom').index); | 966 selectCtl.remove($('Custom').index); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 if ('cookies' in dict && 'value' in dict['cookies']) | 1204 if ('cookies' in dict && 'value' in dict['cookies']) |
1229 this.sessionOnlyCookies_ = dict['cookies']['value'] == 'session'; | 1205 this.sessionOnlyCookies_ = dict['cookies']['value'] == 'session'; |
1230 } | 1206 } |
1231 | 1207 |
1232 }; | 1208 }; |
1233 | 1209 |
1234 //Forward public APIs to private implementations. | 1210 //Forward public APIs to private implementations. |
1235 [ | 1211 [ |
1236 'addBluetoothDevice', | 1212 'addBluetoothDevice', |
1237 'getStartStopSyncButton', | 1213 'getStartStopSyncButton', |
1238 'guestModeActive', | |
1239 'hideBluetoothSettings', | 1214 'hideBluetoothSettings', |
1240 'removeCloudPrintConnectorSection', | 1215 'removeCloudPrintConnectorSection', |
1241 'removeBluetoothDevice', | 1216 'removeBluetoothDevice', |
1242 'setAutoOpenFileTypesDisabledAttribute', | 1217 'setAutoOpenFileTypesDisabledAttribute', |
1243 'setBackgroundModeCheckboxState', | 1218 'setBackgroundModeCheckboxState', |
1244 'setBluetoothState', | 1219 'setBluetoothState', |
1245 'setCheckRevocationCheckboxState', | 1220 'setCheckRevocationCheckboxState', |
1246 'setContentFilterSettingsValue', | 1221 'setContentFilterSettingsValue', |
1247 'setFontSize', | 1222 'setFontSize', |
1248 'setGtkThemeButtonEnabled', | 1223 'setGtkThemeButtonEnabled', |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 BrowserOptions.getLoggedInUsername = function() { | 1258 BrowserOptions.getLoggedInUsername = function() { |
1284 return BrowserOptions.getInstance().username_; | 1259 return BrowserOptions.getInstance().username_; |
1285 }; | 1260 }; |
1286 } | 1261 } |
1287 | 1262 |
1288 // Export | 1263 // Export |
1289 return { | 1264 return { |
1290 BrowserOptions: BrowserOptions | 1265 BrowserOptions: BrowserOptions |
1291 }; | 1266 }; |
1292 }); | 1267 }); |
OLD | NEW |