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

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: Declarative way 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 OptionsPage.prototype.initializePage.call(this); 59 OptionsPage.prototype.initializePage.call(this);
60 var self = this; 60 var self = this;
61 61
62 window.addEventListener('message', this.handleWindowMessage_.bind(this)); 62 window.addEventListener('message', this.handleWindowMessage_.bind(this));
63 63
64 $('advanced-settings-expander').onclick = 64 $('advanced-settings-expander').onclick =
65 this.toggleAdvancedSettings_.bind(this); 65 this.toggleAdvancedSettings_.bind(this);
66 $('advanced-settings').addEventListener('webkitTransitionEnd', 66 $('advanced-settings').addEventListener('webkitTransitionEnd',
67 this.advancedSettingsTransitionEnded_.bind(this)); 67 this.advancedSettingsTransitionEnded_.bind(this));
68 68
69 AccountsOptions.applyGuestModeVisibility(document);
70
69 // Sync (Sign in) section. 71 // Sync (Sign in) section.
70 this.updateSyncState_(templateData.syncData); 72 this.updateSyncState_(templateData.syncData);
71 73
72 $('sync-action-link').onclick = function(event) { 74 $('sync-action-link').onclick = function(event) {
73 SyncSetupOverlay.showErrorUI(); 75 SyncSetupOverlay.showErrorUI();
74 }; 76 };
75 $('start-stop-sync').onclick = function(event) { 77 $('start-stop-sync').onclick = function(event) {
76 if (self.syncSetupCompleted) 78 if (self.syncSetupCompleted)
77 SyncSetupOverlay.showStopSyncingUI(); 79 SyncSetupOverlay.showStopSyncingUI();
78 else 80 else
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if (selectedProfile) 199 if (selectedProfile)
198 ManageProfileOverlay.showManageDialog(selectedProfile); 200 ManageProfileOverlay.showManageDialog(selectedProfile);
199 }; 201 };
200 $('profiles-delete').onclick = function(event) { 202 $('profiles-delete').onclick = function(event) {
201 var selectedProfile = self.getSelectedProfileItem_(); 203 var selectedProfile = self.getSelectedProfileItem_();
202 if (selectedProfile) 204 if (selectedProfile)
203 ManageProfileOverlay.showDeleteDialog(selectedProfile); 205 ManageProfileOverlay.showDeleteDialog(selectedProfile);
204 }; 206 };
205 207
206 if (cr.isChromeOS) { 208 if (cr.isChromeOS) {
209 if (!AccountsOptions.loggedInAsGuest()) {
210 $('account-picture-wrapper').onclick = function(event) {
211 OptionsPage.navigateToPage('changePicture');
212 };
213 }
214
207 // Username (canonical email) of the currently logged in user or 215 // Username (canonical email) of the currently logged in user or
208 // |kGuestUser| if a guest session is active. 216 // |kGuestUser| if a guest session is active.
209 this.username_ = localStrings.getString('username'); 217 this.username_ = localStrings.getString('username');
210 218
211 this.updateAccountPicture_(); 219 this.updateAccountPicture_();
212 220
213 if (cr.commandLine && cr.commandLine.options['--bwsi']) {
214 // Disable the screen lock checkbox in guest mode.
215 $('enable-screen-lock').disabled = true;
216
217 // Hide the startup section in Guest mode.
218 $('startup-section').hidden = true;
219 } else {
220 $('account-picture-wrapper').onclick = function(event) {
221 OptionsPage.navigateToPage('changePicture');
222 };
223 }
224
225 $('manage-accounts-button').onclick = function(event) { 221 $('manage-accounts-button').onclick = function(event) {
226 OptionsPage.navigateToPage('accounts'); 222 OptionsPage.navigateToPage('accounts');
227 chrome.send('coreOptionsUserMetricsAction', 223 chrome.send('coreOptionsUserMetricsAction',
228 ['Options_ManageAccounts']); 224 ['Options_ManageAccounts']);
229 }; 225 };
230 } else { 226 } else {
231 $('import-data').onclick = function(event) { 227 $('import-data').onclick = function(event) {
232 ImportDataOverlay.show(); 228 ImportDataOverlay.show();
233 chrome.send('coreOptionsUserMetricsAction', ['Import_ShowDlg']); 229 chrome.send('coreOptionsUserMetricsAction', ['Import_ShowDlg']);
234 }; 230 };
235 231
236 if ($('themes-GTK-button')) { 232 if ($('themes-GTK-button')) {
237 $('themes-GTK-button').onclick = function(event) { 233 $('themes-GTK-button').onclick = function(event) {
238 chrome.send('themesSetGTK'); 234 chrome.send('themesSetGTK');
239 }; 235 };
240 } 236 }
241 } 237 }
242 238
243 // Default browser section. 239 // Default browser section.
244 if (!cr.isChromeOS) { 240 if (!cr.isChromeOS) {
245 $('set-as-default-browser').onclick = function(event) { 241 $('set-as-default-browser').onclick = function(event) {
246 chrome.send('becomeDefaultBrowser'); 242 chrome.send('becomeDefaultBrowser');
247 }; 243 };
248 244
249 $('auto-launch').onclick = this.handleAutoLaunchChanged_; 245 $('auto-launch').onclick = this.handleAutoLaunchChanged_;
250 } 246 }
251 247
252 // Date and time section (CrOS only).
253 if (cr.isChromeOS && AccountsOptions.loggedInAsGuest()) {
254 // Disable time-related settings if we're not logged in as a real user.
255 $('timezone-select').disabled = true;
256 $('use-24hour-clock').disabled = true;
257 }
258
259 // Privacy section. 248 // Privacy section.
260 $('privacyContentSettingsButton').onclick = function(event) { 249 $('privacyContentSettingsButton').onclick = function(event) {
261 OptionsPage.navigateToPage('content'); 250 OptionsPage.navigateToPage('content');
262 OptionsPage.showTab($('cookies-nav-tab')); 251 OptionsPage.showTab($('cookies-nav-tab'));
263 chrome.send('coreOptionsUserMetricsAction', 252 chrome.send('coreOptionsUserMetricsAction',
264 ['Options_ContentSettings']); 253 ['Options_ContentSettings']);
265 }; 254 };
266 $('privacyClearDataButton').onclick = function(event) { 255 $('privacyClearDataButton').onclick = function(event) {
267 OptionsPage.navigateToPage('clearBrowserData'); 256 OptionsPage.navigateToPage('clearBrowserData');
268 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); 257 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 OptionsPage.navigateToPage('autofill'); 304 OptionsPage.navigateToPage('autofill');
316 chrome.send('coreOptionsUserMetricsAction', 305 chrome.send('coreOptionsUserMetricsAction',
317 ['Options_ShowAutofillSettings']); 306 ['Options_ShowAutofillSettings']);
318 }; 307 };
319 $('manage-passwords').onclick = function(event) { 308 $('manage-passwords').onclick = function(event) {
320 OptionsPage.navigateToPage('passwords'); 309 OptionsPage.navigateToPage('passwords');
321 OptionsPage.showTab($('passwords-nav-tab')); 310 OptionsPage.showTab($('passwords-nav-tab'));
322 chrome.send('coreOptionsUserMetricsAction', 311 chrome.send('coreOptionsUserMetricsAction',
323 ['Options_ShowPasswordManager']); 312 ['Options_ShowPasswordManager']);
324 }; 313 };
325 if (this.guestModeActive_()) { 314 if (cr.isChromeOS && AccountsOptions.loggedInAsGuest()) {
326 // Disable and turn off Autofill in guest mode. 315 // Disable and turn off Autofill in guest mode.
327 var autofillEnabled = $('autofill-enabled'); 316 var autofillEnabled = $('autofill-enabled');
328 autofillEnabled.disabled = true; 317 autofillEnabled.disabled = true;
329 autofillEnabled.checked = false; 318 autofillEnabled.checked = false;
330 cr.dispatchSimpleEvent(autofillEnabled, 'change'); 319 cr.dispatchSimpleEvent(autofillEnabled, 'change');
331 $('autofill-settings').disabled = true; 320 $('autofill-settings').disabled = true;
332 321
333 // Disable and turn off Password Manager in guest mode. 322 // Disable and turn off Password Manager in guest mode.
334 var passwordManagerEnabled = $('password-manager-enabled'); 323 var passwordManagerEnabled = $('password-manager-enabled');
335 passwordManagerEnabled.disabled = true; 324 passwordManagerEnabled.disabled = true;
336 passwordManagerEnabled.checked = false; 325 passwordManagerEnabled.checked = false;
337 cr.dispatchSimpleEvent(passwordManagerEnabled, 'change'); 326 cr.dispatchSimpleEvent(passwordManagerEnabled, 'change');
338 $('manage-passwords').disabled = true; 327 $('manage-passwords').disabled = true;
339
340 // Hide the entire section on ChromeOS
341 if (cr.isChromeOS)
342 $('passwords-and-autofill-section').hidden = true;
343 } 328 }
344 329
345 if (cr.isMac) { 330 if (cr.isMac) {
346 $('mac-passwords-warning').hidden = 331 $('mac-passwords-warning').hidden =
347 !(localStrings.getString('macPasswordsWarning')); 332 !(localStrings.getString('macPasswordsWarning'));
348 } 333 }
349 334
350 // Network section. 335 // Network section.
351 if (!cr.isChromeOS) { 336 if (!cr.isChromeOS) {
352 $('proxiesConfigureButton').onclick = function(event) { 337 $('proxiesConfigureButton').onclick = function(event) {
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 * @private 944 * @private
960 */ 945 */
961 setMetricsReportingSettingVisibility_: function(visible) { 946 setMetricsReportingSettingVisibility_: function(visible) {
962 if (visible) 947 if (visible)
963 $('metricsReportingSetting').style.display = 'block'; 948 $('metricsReportingSetting').style.display = 'block';
964 else 949 else
965 $('metricsReportingSetting').style.display = 'none'; 950 $('metricsReportingSetting').style.display = 'none';
966 }, 951 },
967 952
968 /** 953 /**
969 * Returns whether the browser in guest mode. Some features are disabled or
970 * hidden in guest mode.
971 * @return {boolean} True if guest mode is currently active.
972 * @private
973 */
974 guestModeActive_: function() {
975 return cr.commandLine && cr.commandLine.options['--bwsi'];
976 },
977
978 /**
979 * Set the font size selected item. 954 * Set the font size selected item.
980 * @private 955 * @private
981 */ 956 */
982 setFontSize_: function(font_size_value) { 957 setFontSize_: function(font_size_value) {
983 var selectCtl = $('defaultFontSize'); 958 var selectCtl = $('defaultFontSize');
984 for (var i = 0; i < selectCtl.options.length; i++) { 959 for (var i = 0; i < selectCtl.options.length; i++) {
985 if (selectCtl.options[i].value == font_size_value) { 960 if (selectCtl.options[i].value == font_size_value) {
986 selectCtl.selectedIndex = i; 961 selectCtl.selectedIndex = i;
987 if ($('Custom')) 962 if ($('Custom'))
988 selectCtl.remove($('Custom').index); 963 selectCtl.remove($('Custom').index);
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 if ('cookies' in dict && 'value' in dict['cookies']) 1197 if ('cookies' in dict && 'value' in dict['cookies'])
1223 this.sessionOnlyCookies_ = dict['cookies']['value'] == 'session'; 1198 this.sessionOnlyCookies_ = dict['cookies']['value'] == 'session';
1224 } 1199 }
1225 1200
1226 }; 1201 };
1227 1202
1228 //Forward public APIs to private implementations. 1203 //Forward public APIs to private implementations.
1229 [ 1204 [
1230 'addBluetoothDevice', 1205 'addBluetoothDevice',
1231 'getStartStopSyncButton', 1206 'getStartStopSyncButton',
1232 'guestModeActive',
1233 'hideBluetoothSettings', 1207 'hideBluetoothSettings',
1234 'removeCloudPrintConnectorSection', 1208 'removeCloudPrintConnectorSection',
1235 'removeBluetoothDevice', 1209 'removeBluetoothDevice',
1236 'setAutoOpenFileTypesDisabledAttribute', 1210 'setAutoOpenFileTypesDisabledAttribute',
1237 'setBackgroundModeCheckboxState', 1211 'setBackgroundModeCheckboxState',
1238 'setBluetoothState', 1212 'setBluetoothState',
1239 'setCheckRevocationCheckboxState', 1213 'setCheckRevocationCheckboxState',
1240 'setContentFilterSettingsValue', 1214 'setContentFilterSettingsValue',
1241 'setFontSize', 1215 'setFontSize',
1242 'setGtkThemeButtonEnabled', 1216 'setGtkThemeButtonEnabled',
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 BrowserOptions.getLoggedInUsername = function() { 1251 BrowserOptions.getLoggedInUsername = function() {
1278 return BrowserOptions.getInstance().username_; 1252 return BrowserOptions.getInstance().username_;
1279 }; 1253 };
1280 } 1254 }
1281 1255
1282 // Export 1256 // Export
1283 return { 1257 return {
1284 BrowserOptions: BrowserOptions 1258 BrowserOptions: BrowserOptions
1285 }; 1259 };
1286 }); 1260 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698