Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/browser/resources/options2/browser_options.js

Issue 9464053: Hide/Disable several (meaningless) options in Settings uber-page for Guest. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rename variable Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 pref, 110 pref,
111 self.onHomePagePrefChanged_.bind(self)); 111 self.onHomePagePrefChanged_.bind(self));
112 }); 112 });
113 113
114 $('themes-gallery').onclick = function(event) { 114 $('themes-gallery').onclick = function(event) {
115 window.open(localStrings.getString('themesGalleryURL')); 115 window.open(localStrings.getString('themesGalleryURL'));
116 }; 116 };
117 $('themes-reset').onclick = function(event) { 117 $('themes-reset').onclick = function(event) {
118 chrome.send('themesReset'); 118 chrome.send('themesReset');
119 }; 119 };
120 if (cr.isChromeOS) {
121 // Appearance section.
122 if (AccountsOptions.loggedInAsGuest()) {
James Hawkins 2012/03/05 17:07:12 Combine this if with if (cr.isChromeOS).
Denis Kuznetsov (DE-MUC) 2012/03/12 10:32:15 Done.
123 AccountsOptions.disableElementsForGuest(
124 $('home-page-select-container'));
125 AccountsOptions.disableElementsForGuest(
126 $('bookmarkbar-show-on-all-tabs-group'));
127 // Search section
128 AccountsOptions.disableElementsForGuest($('instant-setting'));
129 }
130 }
120 131
121 // Device section (ChromeOS only). 132 // Device section (ChromeOS only).
122 if (cr.isChromeOS) { 133 if (cr.isChromeOS) {
123 $('keyboard-settings-button').onclick = function(evt) { 134 $('keyboard-settings-button').onclick = function(evt) {
124 OptionsPage.navigateToPage('keyboard-overlay'); 135 OptionsPage.navigateToPage('keyboard-overlay');
125 }; 136 };
126 $('pointer-settings-button').onclick = function(evt) { 137 $('pointer-settings-button').onclick = function(evt) {
127 OptionsPage.navigateToPage('pointer-overlay'); 138 OptionsPage.navigateToPage('pointer-overlay');
128 }; 139 };
129 this.initBrightnessButton_('brightness-decrease-button', 140 this.initBrightnessButton_('brightness-decrease-button',
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (selectedProfile) 205 if (selectedProfile)
195 ManageProfileOverlay.showManageDialog(selectedProfile); 206 ManageProfileOverlay.showManageDialog(selectedProfile);
196 }; 207 };
197 $('profiles-delete').onclick = function(event) { 208 $('profiles-delete').onclick = function(event) {
198 var selectedProfile = self.getSelectedProfileItem_(); 209 var selectedProfile = self.getSelectedProfileItem_();
199 if (selectedProfile) 210 if (selectedProfile)
200 ManageProfileOverlay.showDeleteDialog(selectedProfile); 211 ManageProfileOverlay.showDeleteDialog(selectedProfile);
201 }; 212 };
202 213
203 if (cr.isChromeOS) { 214 if (cr.isChromeOS) {
215 if (AccountsOptions.loggedInAsGuest()) {
216 // Disable the screen lock checkbox in guest mode.
217 AccountsOptions.disableElementsForGuest($('enable-screen-lock'));
218
219 // Hide the startup and users sections in Guest mode.
220 $('startup-section').hidden = true;
221 $('users-section').hidden = true;
222 } else {
223 $('account-picture-wrapper').onclick = function(event) {
224 OptionsPage.navigateToPage('changePicture');
225 };
226 }
227
204 // Username (canonical email) of the currently logged in user or 228 // Username (canonical email) of the currently logged in user or
205 // |kGuestUser| if a guest session is active. 229 // |kGuestUser| if a guest session is active.
206 this.username_ = localStrings.getString('username'); 230 this.username_ = localStrings.getString('username');
207 231
208 this.updateAccountPicture_(); 232 this.updateAccountPicture_();
209 233
210 if (cr.commandLine && cr.commandLine.options['--bwsi']) {
211 // Disable the screen lock checkbox in guest mode.
212 $('enable-screen-lock').disabled = true;
213
214 // Hide the startup section in Guest mode.
215 $('startup-section').hidden = true;
216 } else {
217 $('account-picture-wrapper').onclick = function(event) {
218 OptionsPage.navigateToPage('changePicture');
219 };
220 }
221
222 $('manage-accounts-button').onclick = function(event) { 234 $('manage-accounts-button').onclick = function(event) {
223 OptionsPage.navigateToPage('accounts'); 235 OptionsPage.navigateToPage('accounts');
224 chrome.send('coreOptionsUserMetricsAction', 236 chrome.send('coreOptionsUserMetricsAction',
225 ['Options_ManageAccounts']); 237 ['Options_ManageAccounts']);
226 }; 238 };
227 } else { 239 } else {
228 $('import-data').onclick = function(event) { 240 $('import-data').onclick = function(event) {
229 // Make sure that any previous import success message is hidden, and 241 // Make sure that any previous import success message is hidden, and
230 // we're showing the UI to import further data. 242 // we're showing the UI to import further data.
231 $('import-data-configure').hidden = false; 243 $('import-data-configure').hidden = false;
(...skipping 14 matching lines...) Expand all
246 $('set-as-default-browser').onclick = function(event) { 258 $('set-as-default-browser').onclick = function(event) {
247 chrome.send('becomeDefaultBrowser'); 259 chrome.send('becomeDefaultBrowser');
248 }; 260 };
249 261
250 $('auto-launch').onclick = this.handleAutoLaunchChanged_; 262 $('auto-launch').onclick = this.handleAutoLaunchChanged_;
251 } 263 }
252 264
253 // Date and time section (CrOS only). 265 // Date and time section (CrOS only).
254 if (cr.isChromeOS && AccountsOptions.loggedInAsGuest()) { 266 if (cr.isChromeOS && AccountsOptions.loggedInAsGuest()) {
255 // Disable time-related settings if we're not logged in as a real user. 267 // Disable time-related settings if we're not logged in as a real user.
256 $('timezone-select').disabled = true; 268 AccountsOptions.disableElementsForGuest($('timezone-value-group'));
257 $('use-24hour-clock').disabled = true; 269 AccountsOptions.disableElementsForGuest($('use-24hour-clock'));
258 } 270 }
259 271
260 // Privacy section. 272 // Privacy section.
261 $('privacyContentSettingsButton').onclick = function(event) { 273 $('privacyContentSettingsButton').onclick = function(event) {
262 OptionsPage.navigateToPage('content'); 274 OptionsPage.navigateToPage('content');
263 OptionsPage.showTab($('cookies-nav-tab')); 275 OptionsPage.showTab($('cookies-nav-tab'));
264 chrome.send('coreOptionsUserMetricsAction', 276 chrome.send('coreOptionsUserMetricsAction',
265 ['Options_ContentSettings']); 277 ['Options_ContentSettings']);
266 }; 278 };
267 $('privacyClearDataButton').onclick = function(event) { 279 $('privacyClearDataButton').onclick = function(event) {
268 OptionsPage.navigateToPage('clearBrowserData'); 280 OptionsPage.navigateToPage('clearBrowserData');
269 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); 281 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']);
270 }; 282 };
271 // 'metricsReportingEnabled' element is only present on Chrome branded 283 // 'metricsReportingEnabled' element is only present on Chrome branded
272 // builds. 284 // builds.
273 if ($('metricsReportingEnabled')) { 285 if ($('metricsReportingEnabled')) {
274 $('metricsReportingEnabled').onclick = function(event) { 286 $('metricsReportingEnabled').onclick = function(event) {
275 chrome.send('metricsReportingCheckboxAction', 287 chrome.send('metricsReportingCheckboxAction',
276 [String(event.target.checked)]); 288 [String(event.target.checked)]);
277 }; 289 };
278 } 290 }
279 291
292 if (cr.isChromeOS && AccountsOptions.loggedInAsGuest()) {
293 AccountsOptions.disableElementsForGuest(
294 $('search-suggest-enabled-group'));
295 AccountsOptions.disableElementsForGuest(
296 $('dns-prefetching-enabled-group'));
297 }
298
299
280 // Bluetooth (CrOS only). 300 // Bluetooth (CrOS only).
281 if (cr.isChromeOS) { 301 if (cr.isChromeOS) {
282 options.system.bluetooth.BluetoothDeviceList.decorate( 302 options.system.bluetooth.BluetoothDeviceList.decorate(
283 $('bluetooth-paired-devices-list')); 303 $('bluetooth-paired-devices-list'));
284 304
285 $('bluetooth-add-device').onclick = 305 $('bluetooth-add-device').onclick =
286 this.handleAddBluetoothDevice_.bind(this); 306 this.handleAddBluetoothDevice_.bind(this);
287 307
288 $('enable-bluetooth').onchange = function(event) { 308 $('enable-bluetooth').onchange = function(event) {
289 var state = $('enable-bluetooth').checked; 309 var state = $('enable-bluetooth').checked;
(...skipping 26 matching lines...) Expand all
316 OptionsPage.navigateToPage('autofill'); 336 OptionsPage.navigateToPage('autofill');
317 chrome.send('coreOptionsUserMetricsAction', 337 chrome.send('coreOptionsUserMetricsAction',
318 ['Options_ShowAutofillSettings']); 338 ['Options_ShowAutofillSettings']);
319 }; 339 };
320 $('manage-passwords').onclick = function(event) { 340 $('manage-passwords').onclick = function(event) {
321 OptionsPage.navigateToPage('passwords'); 341 OptionsPage.navigateToPage('passwords');
322 OptionsPage.showTab($('passwords-nav-tab')); 342 OptionsPage.showTab($('passwords-nav-tab'));
323 chrome.send('coreOptionsUserMetricsAction', 343 chrome.send('coreOptionsUserMetricsAction',
324 ['Options_ShowPasswordManager']); 344 ['Options_ShowPasswordManager']);
325 }; 345 };
326 if (this.guestModeActive_()) { 346 if (cr.isChromeOS && AccountsOptions.loggedInAsGuest()) {
327 // Disable and turn off Autofill in guest mode. 347 // Disable and turn off Autofill in guest mode.
328 var autofillEnabled = $('autofill-enabled'); 348 var autofillEnabled = $('autofill-enabled');
329 autofillEnabled.disabled = true; 349 autofillEnabled.disabled = true;
330 autofillEnabled.checked = false; 350 autofillEnabled.checked = false;
331 cr.dispatchSimpleEvent(autofillEnabled, 'change'); 351 cr.dispatchSimpleEvent(autofillEnabled, 'change');
332 $('autofill-settings').disabled = true; 352 $('autofill-settings').disabled = true;
333 353
334 // Disable and turn off Password Manager in guest mode. 354 // Disable and turn off Password Manager in guest mode.
335 var passwordManagerEnabled = $('password-manager-enabled'); 355 var passwordManagerEnabled = $('password-manager-enabled');
336 passwordManagerEnabled.disabled = true; 356 passwordManagerEnabled.disabled = true;
337 passwordManagerEnabled.checked = false; 357 passwordManagerEnabled.checked = false;
338 cr.dispatchSimpleEvent(passwordManagerEnabled, 'change'); 358 cr.dispatchSimpleEvent(passwordManagerEnabled, 'change');
339 $('manage-passwords').disabled = true; 359 $('manage-passwords').disabled = true;
340 360
341 // Hide the entire section on ChromeOS 361 // Hide the entire section on ChromeOS
342 if (cr.isChromeOS) 362 AccountsOptions.disableElementsForGuest(
343 $('passwords-and-autofill-section').hidden = true; 363 $('passwords-and-autofill-section'));
344 } 364 }
345 $('mac-passwords-warning').hidden = 365 $('mac-passwords-warning').hidden =
346 !(localStrings.getString('macPasswordsWarning')); 366 !(localStrings.getString('macPasswordsWarning'));
347 367
348 // Network section. 368 // Network section.
349 if (!cr.isChromeOS) { 369 if (!cr.isChromeOS) {
350 $('proxiesConfigureButton').onclick = function(event) { 370 $('proxiesConfigureButton').onclick = function(event) {
351 chrome.send('showNetworkProxySettings'); 371 chrome.send('showNetworkProxySettings');
352 }; 372 };
353 } 373 }
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 * @private 965 * @private
946 */ 966 */
947 setMetricsReportingSettingVisibility_: function(visible) { 967 setMetricsReportingSettingVisibility_: function(visible) {
948 if (visible) 968 if (visible)
949 $('metricsReportingSetting').style.display = 'block'; 969 $('metricsReportingSetting').style.display = 'block';
950 else 970 else
951 $('metricsReportingSetting').style.display = 'none'; 971 $('metricsReportingSetting').style.display = 'none';
952 }, 972 },
953 973
954 /** 974 /**
955 * Returns whether the browser in guest mode. Some features are disabled or
956 * hidden in guest mode.
957 * @return {boolean} True if guest mode is currently active.
958 * @private
959 */
960 guestModeActive_: function() {
961 return cr.commandLine && cr.commandLine.options['--bwsi'];
962 },
963
964 /**
965 * Set the font size selected item. 975 * Set the font size selected item.
966 * @private 976 * @private
967 */ 977 */
968 setFontSize_: function(font_size_value) { 978 setFontSize_: function(font_size_value) {
969 var selectCtl = $('defaultFontSize'); 979 var selectCtl = $('defaultFontSize');
970 for (var i = 0; i < selectCtl.options.length; i++) { 980 for (var i = 0; i < selectCtl.options.length; i++) {
971 if (selectCtl.options[i].value == font_size_value) { 981 if (selectCtl.options[i].value == font_size_value) {
972 selectCtl.selectedIndex = i; 982 selectCtl.selectedIndex = i;
973 if ($('Custom')) 983 if ($('Custom'))
974 selectCtl.remove($('Custom').index); 984 selectCtl.remove($('Custom').index);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 // the Bluetooth pairing overlay. 1190 // the Bluetooth pairing overlay.
1181 if (device.pairing) 1191 if (device.pairing)
1182 BluetoothPairing.showDialog(device); 1192 BluetoothPairing.showDialog(device);
1183 }, 1193 },
1184 }; 1194 };
1185 1195
1186 //Forward public APIs to private implementations. 1196 //Forward public APIs to private implementations.
1187 [ 1197 [
1188 'addBluetoothDevice', 1198 'addBluetoothDevice',
1189 'getStartStopSyncButton', 1199 'getStartStopSyncButton',
1190 'guestModeActive',
1191 'hideBluetoothSettings', 1200 'hideBluetoothSettings',
1192 'removeCloudPrintConnectorSection', 1201 'removeCloudPrintConnectorSection',
1193 'setAutoOpenFileTypesDisabledAttribute', 1202 'setAutoOpenFileTypesDisabledAttribute',
1194 'setBackgroundModeCheckboxState', 1203 'setBackgroundModeCheckboxState',
1195 'setBluetoothState', 1204 'setBluetoothState',
1196 'setCheckRevocationCheckboxState', 1205 'setCheckRevocationCheckboxState',
1197 'setFontSize', 1206 'setFontSize',
1198 'setGtkThemeButtonEnabled', 1207 'setGtkThemeButtonEnabled',
1199 'setHighContrastCheckboxState', 1208 'setHighContrastCheckboxState',
1200 'setInstantFieldTrialStatus', 1209 'setInstantFieldTrialStatus',
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 BrowserOptions.getLoggedInUsername = function() { 1243 BrowserOptions.getLoggedInUsername = function() {
1235 return BrowserOptions.getInstance().username_; 1244 return BrowserOptions.getInstance().username_;
1236 }; 1245 };
1237 } 1246 }
1238 1247
1239 // Export 1248 // Export
1240 return { 1249 return {
1241 BrowserOptions: BrowserOptions 1250 BrowserOptions: BrowserOptions
1242 }; 1251 };
1243 }); 1252 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698