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

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

Issue 9560005: [uber page] Merge advanced options page into browser options. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 | Annotate | Revision Log
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 29 matching lines...) Expand all
40 instantConfirmDialogShown_: false, 40 instantConfirmDialogShown_: false,
41 41
42 /** 42 /**
43 * @inheritDoc 43 * @inheritDoc
44 */ 44 */
45 initializePage: function() { 45 initializePage: function() {
46 OptionsPage.prototype.initializePage.call(this); 46 OptionsPage.prototype.initializePage.call(this);
47 47
48 window.addEventListener('message', this.handleWindowMessage_.bind(this)); 48 window.addEventListener('message', this.handleWindowMessage_.bind(this));
49 49
50 $('advanced-settings-expander').onclick =
51 this.toggleAdvancedSettings_.bind(this);
52
50 // Sync (Sign in) section. 53 // Sync (Sign in) section.
51 this.updateSyncState_(templateData.syncData); 54 this.updateSyncState_(templateData.syncData);
52 55
53 $('sync-action-link').onclick = function(event) { 56 $('sync-action-link').onclick = function(event) {
54 SyncSetupOverlay.showErrorUI(); 57 SyncSetupOverlay.showErrorUI();
55 }; 58 };
56 $('start-stop-sync').onclick = function(event) { 59 $('start-stop-sync').onclick = function(event) {
57 if (self.syncSetupCompleted) 60 if (self.syncSetupCompleted)
58 SyncSetupOverlay.showStopSyncingUI(); 61 SyncSetupOverlay.showStopSyncingUI();
59 else 62 else
(...skipping 10 matching lines...) Expand all
70 chrome.send('coreOptionsUserMetricsAction', 73 chrome.send('coreOptionsUserMetricsAction',
71 ['Options_InternetOptions']); 74 ['Options_InternetOptions']);
72 }; 75 };
73 } 76 }
74 77
75 // On Startup section. 78 // On Startup section.
76 $('startup-set-pages').onclick = function() { 79 $('startup-set-pages').onclick = function() {
77 OptionsPage.navigateToPage('startup'); 80 OptionsPage.navigateToPage('startup');
78 }; 81 };
79 82
83 this.sessionRestoreEnabled_ = templateData.enable_restore_session_state;
84 if (this.sessionRestoreEnabled_) {
85 $('old-startup-last-text').hidden = true;
86 $('new-startup-last-text').hidden = false;
87 }
88
80 // Appearance section. 89 // Appearance section.
81 $('change-home-page').onclick = function(event) { 90 $('change-home-page').onclick = function(event) {
82 OptionsPage.navigateToPage('homePageOverlay'); 91 OptionsPage.navigateToPage('homePageOverlay');
83 }; 92 };
84 $('themes-gallery').onclick = function(event) { 93 $('themes-gallery').onclick = function(event) {
85 window.open(localStrings.getString('themesGalleryURL')); 94 window.open(localStrings.getString('themesGalleryURL'));
86 }; 95 };
87 $('themes-reset').onclick = function(event) { 96 $('themes-reset').onclick = function(event) {
88 chrome.send('themesReset'); 97 chrome.send('themesReset');
89 }; 98 };
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 223
215 // Default browser section. 224 // Default browser section.
216 if (!cr.isChromeOS) { 225 if (!cr.isChromeOS) {
217 $('set-as-default-browser').onclick = function(event) { 226 $('set-as-default-browser').onclick = function(event) {
218 chrome.send('becomeDefaultBrowser'); 227 chrome.send('becomeDefaultBrowser');
219 }; 228 };
220 229
221 $('auto-launch').onclick = this.handleAutoLaunchChanged_; 230 $('auto-launch').onclick = this.handleAutoLaunchChanged_;
222 } 231 }
223 232
224 // Under the hood section. 233 // Date and time section (CrOS only).
225 $('advanced-settings').onclick = function(event) { 234 if (cr.isChromeOS && AccountsOptions.loggedInAsGuest()) {
226 OptionsPage.navigateToPage('advanced'); 235 // Disable time-related settings if we're not logged in as a real user.
227 chrome.send('coreOptionsUserMetricsAction', 236 $('timezone-select').disabled = true;
228 ['Options_OpenUnderTheHood']); 237 $('use-24hour-clock').disabled = true;
229 }; 238 }
230 239
231 this.sessionRestoreEnabled_ = templateData.enable_restore_session_state; 240 // Privacy section.
232 if (this.sessionRestoreEnabled_) { 241 $('privacyContentSettingsButton').onclick = function(event) {
233 $('old-startup-last-text').hidden = true; 242 OptionsPage.navigateToPage('content');
234 $('new-startup-last-text').hidden = false; 243 OptionsPage.showTab($('cookies-nav-tab'));
244 chrome.send('coreOptionsUserMetricsAction',
245 ['Options_ContentSettings']);
246 };
247 $('privacyClearDataButton').onclick = function(event) {
248 OptionsPage.navigateToPage('clearBrowserData');
249 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']);
250 };
251 // 'metricsReportingEnabled' element is only present on Chrome branded
252 // builds.
253 if ($('metricsReportingEnabled')) {
254 $('metricsReportingEnabled').onclick = function(event) {
255 chrome.send('metricsReportingCheckboxAction',
256 [String(event.target.checked)]);
257 };
258 }
259
260 // Bluetooth (CrOS only).
261 if (cr.isChromeOS) {
262 options.system.bluetooth.BluetoothDeviceList.decorate(
263 $('bluetooth-paired-devices-list'));
264
265 $('bluetooth-add-device').onclick = function(event) {
266 this.findBluetoothDevices_(true);
267 OptionsPage.navigateToPage('bluetooth');
268 };
269
270 $('enable-bluetooth').onchange = function(event) {
271 var state = $('enable-bluetooth').checked;
272 chrome.send('bluetoothEnableChange', [Boolean(state)]);
273 };
274
275 $('bluetooth-reconnect-device').onclick = function(event) {
276 var device = $('bluetooth-paired-devices-list').selectedItem;
277 var address = device.address;
278 chrome.send('updateBluetoothDevice', [address, 'connect']);
279 OptionsPage.closeOverlay();
280 };
281
282 $('bluetooth-reconnect-device').onmousedown = function(event) {
283 // Prevent 'blur' event, which would reset the list selection,
284 // thereby disabling the apply button.
285 event.preventDefault();
286 };
287
288 $('bluetooth-paired-devices-list').addEventListener('change',
289 function() {
290 var item = $('bluetooth-paired-devices-list').selectedItem;
291 var disabled = !item || !item.paired || item.connected;
292 $('bluetooth-reconnect-device').disabled = disabled;
293 });
294 }
295
296 // Passwords and Forms section.
297 $('autofill-settings').onclick = function(event) {
298 OptionsPage.navigateToPage('autofill');
299 chrome.send('coreOptionsUserMetricsAction',
300 ['Options_ShowAutofillSettings']);
301 };
302 $('manage-passwords').onclick = function(event) {
303 OptionsPage.navigateToPage('passwords');
304 OptionsPage.showTab($('passwords-nav-tab'));
305 chrome.send('coreOptionsUserMetricsAction',
306 ['Options_ShowPasswordManager']);
307 };
308 if (this.guestModeActive_()) {
309 // Disable and turn off Autofill in guest mode.
310 var autofillEnabled = $('autofill-enabled');
311 autofillEnabled.disabled = true;
312 autofillEnabled.checked = false;
313 cr.dispatchSimpleEvent(autofillEnabled, 'change');
314 $('autofill-settings').disabled = true;
315
316 // Disable and turn off Password Manager in guest mode.
317 var passwordManagerEnabled = $('password-manager-enabled');
318 passwordManagerEnabled.disabled = true;
319 passwordManagerEnabled.checked = false;
320 cr.dispatchSimpleEvent(passwordManagerEnabled, 'change');
321 $('manage-passwords').disabled = true;
322
323 // Hide the entire section on ChromeOS
324 if (cr.isChromeOS)
325 $('passwords-and-autofill-section').hidden = true;
326 }
327 $('mac-passwords-warning').hidden =
328 !(localStrings.getString('macPasswordsWarning'));
329
330 // Network section.
331 if (!cr.isChromeOS) {
332 $('proxiesConfigureButton').onclick = function(event) {
333 chrome.send('showNetworkProxySettings');
334 };
335 }
336
337 // Web Content section.
338 $('fontSettingsCustomizeFontsButton').onclick = function(event) {
339 OptionsPage.navigateToPage('fonts');
340 chrome.send('coreOptionsUserMetricsAction', ['Options_FontSettings']);
341 };
342 $('defaultFontSize').onchange = function(event) {
343 var value = event.target.options[event.target.selectedIndex].value;
344 Preferences.setIntegerPref(
345 'webkit.webprefs.global.default_fixed_font_size',
346 value - OptionsPage.SIZE_DIFFERENCE_FIXED_STANDARD, '');
347 chrome.send('defaultFontSizeAction', [String(value)]);
348 };
349 $('defaultZoomFactor').onchange = function(event) {
350 chrome.send('defaultZoomFactorAction',
351 [String(event.target.options[event.target.selectedIndex].value)]);
352 };
353
354 // Languages section.
355 $('language-button').onclick = function(event) {
356 OptionsPage.navigateToPage('languages');
357 chrome.send('coreOptionsUserMetricsAction',
358 ['Options_LanuageAndSpellCheckSettings']);
359 };
360
361 // Downloads section.
362 if (!cr.isChromeOS) {
363 $('downloadLocationChangeButton').onclick = function(event) {
364 chrome.send('selectDownloadLocation');
365 };
366 // This text field is always disabled. Setting ".disabled = true" isn't
367 // enough, since a policy can disable it but shouldn't re-enable when
368 // it is removed.
369 $('downloadLocationPath').setDisabled('readonly', true);
370 $('autoOpenFileTypesResetToDefault').onclick = function(event) {
371 chrome.send('autoOpenFileTypesAction');
372 };
373 }
374
375 // HTTPS/SSL section.
376 if (cr.isWindows || cr.isMac) {
377 $('certificatesManageButton').onclick = function(event) {
378 chrome.send('showManageSSLCertificates');
379 };
380 } else {
381 $('certificatesManageButton').onclick = function(event) {
382 OptionsPage.navigateToPage('certificates');
383 chrome.send('coreOptionsUserMetricsAction',
384 ['Options_ManageSSLCertificates']);
385 };
386 }
387 $('sslCheckRevocation').onclick = function(event) {
388 chrome.send('checkRevocationCheckboxAction',
389 [String($('sslCheckRevocation').checked)]);
390 };
391
392 // Cloud Print section.
393 // 'cloudPrintProxyEnabled' is true for Chrome branded builds on
394 // certain platforms, or could be enabled by a lab.
395 if (!cr.isChromeOS) {
396 $('cloudPrintConnectorSetupButton').onclick = function(event) {
397 if ($('cloudPrintManageButton').style.display == 'none') {
398 // Disable the button, set it's text to the intermediate state.
399 $('cloudPrintConnectorSetupButton').textContent =
400 localStrings.getString('cloudPrintConnectorEnablingButton');
401 $('cloudPrintConnectorSetupButton').disabled = true;
402 chrome.send('showCloudPrintSetupDialog');
403 } else {
404 chrome.send('disableCloudPrintConnector');
405 }
406 };
407 }
408 $('cloudPrintManageButton').onclick = function(event) {
409 chrome.send('showCloudPrintManagePage');
410 };
411
412 // Accessibility section (CrOS only).
413 if (cr.isChromeOS) {
414 $('accessibility-spoken-feedback-check').onchange = function(event) {
415 chrome.send('spokenFeedbackChange',
416 [$('accessibility-spoken-feedback-check').checked]);
417 };
418 }
419
420 // Background mode section.
421 if ($('backgroundModeCheckbox')) {
422 $('backgroundModeCheckbox').onclick = function(event) {
423 chrome.send('backgroundModeAction',
424 [String($('backgroundModeCheckbox').checked)]);
425 };
235 } 426 }
236 }, 427 },
237 428
238 /** 429 /**
239 * @inheritDoc 430 * @inheritDoc
240 */ 431 */
241 didShowPage: function() { 432 didShowPage: function() {
242 $('search-field').focus(); 433 $('search-field').focus();
243 }, 434 },
244 435
245 /** 436 /**
246 * Handler for messages sent from the main uber page. 437 * Handler for messages sent from the main uber page.
247 * @param {Event} e The 'message' event from the uber page. 438 * @param {Event} e The 'message' event from the uber page.
439 * @private
248 */ 440 */
249 handleWindowMessage_: function(e) { 441 handleWindowMessage_: function(e) {
250 if (e.data.method == 'frameSelected') 442 if (e.data.method == 'frameSelected')
251 $('search-field').focus(); 443 $('search-field').focus();
252 }, 444 },
253 445
254 /** 446 /**
447 * Toggle the visibility state of the Advanced section.
448 * @private
449 */
450 toggleAdvancedSettings_: function() {
451 if ($('advanced-settings').style.height == '0px')
452 this.showAdvancedSettings_();
453 else
454 this.hideAdvancedSettings_();
455 },
456
457 /**
458 * Show advanced settings.
459 * @private
460 */
461 showAdvancedSettings_: function() {
462 $('advanced-settings').style.height =
463 $('advanced-settings-container').offsetHeight + 20 + 'px';
464 $('advanced-settings-expander').innerHTML =
465 localStrings.getString('hideAdvancedSettings');
466 },
467
468 /**
469 * Hide advanced settings.
470 * @private
471 */
472 hideAdvancedSettings_: function() {
473 $('advanced-settings').style.height = '0px'
474 $('advanced-settings-expander').innerHTML =
475 localStrings.getString('showAdvancedSettings');
476 },
477
478 /**
255 * Updates managed banner visibility state. This function iterates over 479 * Updates managed banner visibility state. This function iterates over
256 * all input fields of all subpages and if any of these is marked as managed 480 * all input fields of all subpages and if any of these is marked as managed
257 * it triggers the managed banner to be visible. 481 * it triggers the managed banner to be visible.
258 * @private 482 * @private
259 */ 483 */
260 updateManagedBannerVisibility_: function() { 484 updateManagedBannerVisibility_: function() {
261 var bannerDiv = $('managed-prefs-banner'); 485 var bannerDiv = $('managed-prefs-banner');
262 486
263 var controlledByPolicy = false; 487 var controlledByPolicy = false;
264 var controlledByExtension = false; 488 var controlledByExtension = false;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 /** 673 /**
450 * Update the Default Browsers section based on the current state. 674 * Update the Default Browsers section based on the current state.
451 * @param {string} statusString Description of the current default state. 675 * @param {string} statusString Description of the current default state.
452 * @param {boolean} isDefault Whether or not the browser is currently 676 * @param {boolean} isDefault Whether or not the browser is currently
453 * default. 677 * default.
454 * @param {boolean} canBeDefault Whether or not the browser can be default. 678 * @param {boolean} canBeDefault Whether or not the browser can be default.
455 * @private 679 * @private
456 */ 680 */
457 updateDefaultBrowserState_: function(statusString, isDefault, 681 updateDefaultBrowserState_: function(statusString, isDefault,
458 canBeDefault) { 682 canBeDefault) {
459 var label = $('default-browser-state'); 683 if (!cr.isChromeOS) {
460 label.textContent = statusString; 684 var label = $('default-browser-state');
685 label.textContent = statusString;
461 686
462 $('set-as-default-browser').hidden = !canBeDefault || isDefault; 687 $('set-as-default-browser').hidden = !canBeDefault || isDefault;
688 }
463 }, 689 },
464 690
465 /** 691 /**
466 * Clears the search engine popup. 692 * Clears the search engine popup.
467 * @private 693 * @private
468 */ 694 */
469 clearSearchEngines_: function() { 695 clearSearchEngines_: function() {
470 $('default-search-engine').textContent = ''; 696 $('default-search-engine').textContent = '';
471 }, 697 },
472 698
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 * (Re)loads IMG element with current user account picture. 854 * (Re)loads IMG element with current user account picture.
629 * @private 855 * @private
630 */ 856 */
631 updateAccountPicture_: function() { 857 updateAccountPicture_: function() {
632 var picture = $('account-picture'); 858 var picture = $('account-picture');
633 if (picture) { 859 if (picture) {
634 picture.src = 'chrome://userimage/' + this.username_ + '?id=' + 860 picture.src = 'chrome://userimage/' + this.username_ + '?id=' +
635 Date.now(); 861 Date.now();
636 } 862 }
637 }, 863 },
864
865 /**
866 * Scan for bluetooth devices.
867 * @param {boolean} reset Indicates if the list of unpaired devices should
868 * be cleared.
869 * @private
870 */
871 findBluetoothDevices_: function(reset) {
872 $('bluetooth-unpaired-devices-list').clear();
873 chrome.send('findBluetoothDevices');
874 },
875
876 /**
877 * Set the checked state of the metrics reporting checkbox.
878 * @private
879 */
880 setMetricsReportingCheckboxState_: function(checked, disabled) {
881 $('metricsReportingEnabled').checked = checked;
882 $('metricsReportingEnabled').disabled = disabled;
883 if (disabled)
884 $('metricsReportingEnabledText').className = 'disable-services-span';
885 },
886
887 /**
888 * @private
889 */
890 setMetricsReportingSettingVisibility_: function(visible) {
891 if (visible)
892 $('metricsReportingSetting').style.display = 'block';
893 else
894 $('metricsReportingSetting').style.display = 'none';
895 },
896
897 /**
898 * Returns whether the browser in guest mode. Some features are disabled or
899 * hidden in guest mode.
900 * @return {boolean} True if guest mode is currently active.
901 * @private
902 */
903 guestModeActive_: function() {
904 return cr.commandLine && cr.commandLine.options['--bwsi'];
905 },
906
907 /**
908 * Set the font size selected item.
909 * @private
910 */
911 setFontSize_: function(font_size_value) {
912 var selectCtl = $('defaultFontSize');
913 for (var i = 0; i < selectCtl.options.length; i++) {
914 if (selectCtl.options[i].value == font_size_value) {
915 selectCtl.selectedIndex = i;
916 if ($('Custom'))
917 selectCtl.remove($('Custom').index);
918 return;
919 }
920 }
921
922 // Add/Select Custom Option in the font size label list.
923 if (!$('Custom')) {
924 var option = new Option(localStrings.getString('fontSizeLabelCustom'),
925 -1, false, true);
926 option.setAttribute('id', 'Custom');
927 selectCtl.add(option);
928 }
929 $('Custom').selected = true;
930 },
931
932 /**
933 * Populate the page zoom selector with values received from the caller.
934 * @param {Array} items An array of items to populate the selector.
935 * each object is an array with three elements as follows:
936 * 0: The title of the item (string).
937 * 1: The value of the item (number).
938 * 2: Whether the item should be selected (boolean).
939 * @private
940 */
941 setupPageZoomSelector_: function(items) {
942 var element = $('defaultZoomFactor');
943
944 // Remove any existing content.
945 element.textContent = '';
946
947 // Insert new child nodes into select element.
948 var value, title, selected;
949 for (var i = 0; i < items.length; i++) {
950 title = items[i][0];
951 value = items[i][1];
952 selected = items[i][2];
953 element.appendChild(new Option(title, value, false, selected));
954 }
955 },
956
957 /**
958 * Set the enabled state for the autoOpenFileTypesResetToDefault button.
959 * @private
960 */
961 setAutoOpenFileTypesDisabledAttribute_: function(disabled) {
962 if (!cr.isChromeOS) {
963 $('autoOpenFileTypesResetToDefault').disabled = disabled;
964 if (disabled)
965 $('auto-open-file-types-label').classList.add('disabled');
966 else
967 $('auto-open-file-types-label').classList.remove('disabled');
968 }
969 },
970
971 /**
972 * Set the enabled state for the proxy settings button.
973 * @private
974 */
975 setupProxySettingsSection_: function(disabled, label) {
976 if (!cr.isChromeOS) {
977 $('proxiesConfigureButton').disabled = disabled;
978 $('proxiesLabel').textContent = label;
979 }
980 },
981
982 /**
983 * Set the checked state for the sslCheckRevocation checkbox.
984 * @private
985 */
986 setCheckRevocationCheckboxState_: function(checked, disabled) {
987 $('sslCheckRevocation').checked = checked;
988 $('sslCheckRevocation').disabled = disabled;
989 },
990
991 /**
992 * Set the checked state for the backgroundModeCheckbox element.
993 * @private
994 */
995 setBackgroundModeCheckboxState_: function(checked) {
996 $('backgroundModeCheckbox').checked = checked;
997 },
998
999 /**
1000 * Set the Cloud Print proxy UI to enabled, disabled, or processing.
1001 * @private
1002 */
1003 setupCloudPrintConnectorSection_: function(disabled, label, allowed) {
1004 if (!cr.isChromeOS) {
1005 $('cloudPrintConnectorLabel').textContent = label;
1006 if (disabled || !allowed) {
1007 $('cloudPrintConnectorSetupButton').textContent =
1008 localStrings.getString('cloudPrintConnectorDisabledButton');
1009 $('cloudPrintManageButton').style.display = 'none';
1010 } else {
1011 $('cloudPrintConnectorSetupButton').textContent =
1012 localStrings.getString('cloudPrintConnectorEnabledButton');
1013 $('cloudPrintManageButton').style.display = 'inline';
1014 }
1015 $('cloudPrintConnectorSetupButton').disabled = !allowed;
1016 }
1017 },
1018
1019 /**
1020 * @private
1021 */
1022 removeCloudPrintConnectorSection_: function() {
1023 if (!cr.isChromeOS) {
1024 var connectorSectionElm = $('cloud-print-connector-section');
1025 if (connectorSectionElm)
1026 connectorSectionElm.parentNode.removeChild(connectorSectionElm);
1027 }
1028 },
1029
1030 /**
1031 * Set the initial state of the spoken feedback checkbox.
1032 * @private
1033 */
1034 setSpokenFeedbackCheckboxState_: function(checked) {
1035 $('accessibility-spoken-feedback-check').checked = checked;
1036 },
1037
1038 /**
1039 * Set the initial state of the high contrast checkbox.
1040 * @private
1041 */
1042 setHighContrastCheckboxState_: function(checked) {
1043 // TODO(zork): Update UI
1044 },
1045
1046 /**
1047 * Set the initial state of the screen magnifier checkbox.
1048 * @private
1049 */
1050 setScreenMagnifierCheckboxState_: function(checked) {
1051 // TODO(zork): Update UI
1052 },
1053
1054 /**
1055 * Set the initial state of the virtual keyboard checkbox.
1056 * @private
1057 */
1058 setVirtualKeyboardCheckboxState_: function(checked) {
1059 // TODO(zork): Update UI
1060 },
1061
1062 /**
1063 * Activate the bluetooth settings section on the System settings page.
1064 * @private
1065 */
1066 showBluetoothSettings_: function() {
1067 $('bluetooth-devices').hidden = false;
1068 },
1069
1070 /**
1071 * Sets the state of the checkbox indicating if bluetooth is turned on. The
1072 * state of the "Find devices" button and the list of discovered devices may
1073 * also be affected by a change to the state.
1074 * @param {boolean} checked Flag Indicating if Bluetooth is turned on.
1075 * @private
1076 */
1077 setBluetoothState_: function(checked) {
1078 $('enable-bluetooth').checked = checked;
1079 $('bluetooth-paired-devices-list').parentNode.hidden = !checked;
1080 $('bluetooth-add-device').hidden = !checked;
1081 $('bluetooth-reconnect-device').hidden = !checked;
1082 // Flush list of previously discovered devices if bluetooth is turned off.
1083 if (!checked) {
1084 $('bluetooth-paired-devices-list').clear();
1085 $('bluetooth-unpaired-devices-list').clear();
1086 } else {
1087 chrome.send('getPairedBluetoothDevices');
1088 }
1089 },
1090
1091 /**
1092 * Adds an element to the list of available bluetooth devices. If an element
1093 * with a matching address is found, the existing element is updated.
1094 * @param {{name: string,
1095 * address: string,
1096 * icon: string,
1097 * paired: boolean,
1098 * connected: boolean}} device
1099 * Decription of the bluetooth device.
1100 * @private
1101 */
1102 addBluetoothDevice_: function(device) {
1103 var list = $('bluetooth-unpaired-devices-list');
1104 if (device.paired) {
1105 // Test to see if the device is currently in the unpaired list, in which
1106 // case it should be removed from that list.
1107 var index = $('bluetooth-unpaired-devices-list').find(device.address);
1108 if (index != undefined)
1109 $('bluetooth-unpaired-devices-list').deleteItemAtIndex(index);
1110 list = $('bluetooth-paired-devices-list');
1111 }
1112 list.appendDevice(device);
1113
1114 // One device can be in the process of pairing. If found, display
1115 // the Bluetooth pairing overlay.
1116 if (device.pairing)
1117 BluetoothPairing.showDialog(device);
1118 },
638 }; 1119 };
639 1120
640 //Forward public APIs to private implementations. 1121 //Forward public APIs to private implementations.
641 [ 1122 [
1123 'addBluetoothDevice',
642 'getStartStopSyncButton', 1124 'getStartStopSyncButton',
1125 'guestModeActive',
1126 'removeCloudPrintConnectorSection',
1127 'setAutoOpenFileTypesDisabledAttribute',
1128 'setBackgroundModeCheckboxState',
1129 'setBluetoothState',
1130 'setCheckRevocationCheckboxState',
1131 'setFontSize',
643 'setGtkThemeButtonEnabled', 1132 'setGtkThemeButtonEnabled',
1133 'setHighContrastCheckboxState',
644 'setInstantFieldTrialStatus', 1134 'setInstantFieldTrialStatus',
1135 'setMetricsReportingCheckboxState',
1136 'setMetricsReportingSettingVisibility',
645 'setProfilesInfo', 1137 'setProfilesInfo',
646 'setProfilesSectionVisible', 1138 'setProfilesSectionVisible',
1139 'setScreenMagnifierCheckboxState',
1140 'setSpokenFeedbackCheckboxState',
647 'setThemesResetButtonEnabled', 1141 'setThemesResetButtonEnabled',
1142 'setupCloudPrintConnectorSection',
1143 'setupPageZoomSelector',
1144 'setupProxySettingsSection',
1145 'setVirtualKeyboardCheckboxState',
1146 'showBluetoothSettings',
648 'updateAccountPicture', 1147 'updateAccountPicture',
649 'updateAutocompleteSuggestions', 1148 'updateAutocompleteSuggestions',
650 'updateAutoLaunchState', 1149 'updateAutoLaunchState',
1150 'updateDefaultBrowserState',
651 'updateHomePageLabel', 1151 'updateHomePageLabel',
652 'updateManagedBannerVisibility', 1152 'updateManagedBannerVisibility',
653 'updateSearchEngines', 1153 'updateSearchEngines',
654 'updateSyncState', 1154 'updateSyncState',
655 'updateStartupPages', 1155 'updateStartupPages',
656 ].forEach(function(name) { 1156 ].forEach(function(name) {
657 BrowserOptions[name] = function() { 1157 BrowserOptions[name] = function() {
658 var instance = BrowserOptions.getInstance(); 1158 var instance = BrowserOptions.getInstance();
659 return instance[name + '_'].apply(instance, arguments); 1159 return instance[name + '_'].apply(instance, arguments);
660 }; 1160 };
661 }); 1161 });
662 1162
663 BrowserOptions.updateDefaultBrowserState = function(statusString, isDefault,
664 canBeDefault) {
665 if (!cr.isChromeOS) {
666 BrowserOptions.getInstance().updateDefaultBrowserState_(statusString,
667 isDefault,
668 canBeDefault);
669 }
670 };
671
672 if (cr.isChromeOS) { 1163 if (cr.isChromeOS) {
673 /** 1164 /**
674 * Returns username (canonical email) of the user logged in (ChromeOS only). 1165 * Returns username (canonical email) of the user logged in (ChromeOS only).
675 * @return {string} user email. 1166 * @return {string} user email.
676 */ 1167 */
677 // TODO(jhawkins): Investigate the use case for this method. 1168 // TODO(jhawkins): Investigate the use case for this method.
678 BrowserOptions.getLoggedInUsername = function() { 1169 BrowserOptions.getLoggedInUsername = function() {
679 return BrowserOptions.getInstance().username_; 1170 return BrowserOptions.getInstance().username_;
680 }; 1171 };
681 } 1172 }
682 1173
683 // Export 1174 // Export
684 return { 1175 return {
685 BrowserOptions: BrowserOptions 1176 BrowserOptions: BrowserOptions
686 }; 1177 };
687 }); 1178 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698