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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 /** | 45 /** |
46 * @inheritDoc | 46 * @inheritDoc |
47 */ | 47 */ |
48 initializePage: function() { | 48 initializePage: function() { |
49 OptionsPage.prototype.initializePage.call(this); | 49 OptionsPage.prototype.initializePage.call(this); |
50 var self = this; | 50 var self = this; |
51 | 51 |
52 window.addEventListener('message', this.handleWindowMessage_.bind(this)); | 52 window.addEventListener('message', this.handleWindowMessage_.bind(this)); |
53 | 53 |
| 54 $('advanced-settings-expander').onclick = |
| 55 this.toggleAdvancedSettings_.bind(this); |
| 56 |
54 // Sync (Sign in) section. | 57 // Sync (Sign in) section. |
55 this.updateSyncState_(templateData.syncData); | 58 this.updateSyncState_(templateData.syncData); |
56 | 59 |
57 $('sync-action-link').onclick = function(event) { | 60 $('sync-action-link').onclick = function(event) { |
58 SyncSetupOverlay.showErrorUI(); | 61 SyncSetupOverlay.showErrorUI(); |
59 }; | 62 }; |
60 $('start-stop-sync').onclick = function(event) { | 63 $('start-stop-sync').onclick = function(event) { |
61 if (self.syncSetupCompleted) | 64 if (self.syncSetupCompleted) |
62 SyncSetupOverlay.showStopSyncingUI(); | 65 SyncSetupOverlay.showStopSyncingUI(); |
63 else | 66 else |
(...skipping 10 matching lines...) Expand all Loading... |
74 chrome.send('coreOptionsUserMetricsAction', | 77 chrome.send('coreOptionsUserMetricsAction', |
75 ['Options_InternetOptions']); | 78 ['Options_InternetOptions']); |
76 }; | 79 }; |
77 } | 80 } |
78 | 81 |
79 // On Startup section. | 82 // On Startup section. |
80 $('startup-set-pages').onclick = function() { | 83 $('startup-set-pages').onclick = function() { |
81 OptionsPage.navigateToPage('startup'); | 84 OptionsPage.navigateToPage('startup'); |
82 }; | 85 }; |
83 | 86 |
| 87 this.sessionRestoreEnabled_ = templateData.enable_restore_session_state; |
| 88 if (this.sessionRestoreEnabled_) { |
| 89 $('old-startup-last-text').hidden = true; |
| 90 $('new-startup-last-text').hidden = false; |
| 91 } |
| 92 |
84 // Appearance section. | 93 // Appearance section. |
85 $('home-page-select').addEventListener( | 94 $('home-page-select').addEventListener( |
86 'change', this.onHomePageSelectChange_.bind(this)); | 95 'change', this.onHomePageSelectChange_.bind(this)); |
87 | 96 |
88 ['browser.show_home_button', | 97 ['browser.show_home_button', |
89 'homepage', | 98 'homepage', |
90 'homepage_is_newtabpage'].forEach(function(pref) { | 99 'homepage_is_newtabpage'].forEach(function(pref) { |
91 Preferences.getInstance().addEventListener( | 100 Preferences.getInstance().addEventListener( |
92 pref, | 101 pref, |
93 self.onHomePagePrefChanged_.bind(self)); | 102 self.onHomePagePrefChanged_.bind(self)); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 234 |
226 // Default browser section. | 235 // Default browser section. |
227 if (!cr.isChromeOS) { | 236 if (!cr.isChromeOS) { |
228 $('set-as-default-browser').onclick = function(event) { | 237 $('set-as-default-browser').onclick = function(event) { |
229 chrome.send('becomeDefaultBrowser'); | 238 chrome.send('becomeDefaultBrowser'); |
230 }; | 239 }; |
231 | 240 |
232 $('auto-launch').onclick = this.handleAutoLaunchChanged_; | 241 $('auto-launch').onclick = this.handleAutoLaunchChanged_; |
233 } | 242 } |
234 | 243 |
235 // Under the hood section. | 244 // Date and time section (CrOS only). |
236 $('advanced-settings').onclick = function(event) { | 245 if (cr.isChromeOS && AccountsOptions.loggedInAsGuest()) { |
237 OptionsPage.navigateToPage('advanced'); | 246 // Disable time-related settings if we're not logged in as a real user. |
238 chrome.send('coreOptionsUserMetricsAction', | 247 $('timezone-select').disabled = true; |
239 ['Options_OpenUnderTheHood']); | 248 $('use-24hour-clock').disabled = true; |
240 }; | 249 } |
241 | 250 |
242 this.sessionRestoreEnabled_ = templateData.enable_restore_session_state; | 251 // Privacy section. |
243 if (this.sessionRestoreEnabled_) { | 252 $('privacyContentSettingsButton').onclick = function(event) { |
244 $('old-startup-last-text').hidden = true; | 253 OptionsPage.navigateToPage('content'); |
245 $('new-startup-last-text').hidden = false; | 254 OptionsPage.showTab($('cookies-nav-tab')); |
| 255 chrome.send('coreOptionsUserMetricsAction', |
| 256 ['Options_ContentSettings']); |
| 257 }; |
| 258 $('privacyClearDataButton').onclick = function(event) { |
| 259 OptionsPage.navigateToPage('clearBrowserData'); |
| 260 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); |
| 261 }; |
| 262 // 'metricsReportingEnabled' element is only present on Chrome branded |
| 263 // builds. |
| 264 if ($('metricsReportingEnabled')) { |
| 265 $('metricsReportingEnabled').onclick = function(event) { |
| 266 chrome.send('metricsReportingCheckboxAction', |
| 267 [String(event.target.checked)]); |
| 268 }; |
| 269 } |
| 270 |
| 271 // Bluetooth (CrOS only). |
| 272 if (cr.isChromeOS) { |
| 273 options.system.bluetooth.BluetoothDeviceList.decorate( |
| 274 $('bluetooth-paired-devices-list')); |
| 275 |
| 276 $('bluetooth-add-device').onclick = function(event) { |
| 277 this.findBluetoothDevices_(true); |
| 278 OptionsPage.navigateToPage('bluetooth'); |
| 279 }; |
| 280 |
| 281 $('enable-bluetooth').onchange = function(event) { |
| 282 var state = $('enable-bluetooth').checked; |
| 283 chrome.send('bluetoothEnableChange', [Boolean(state)]); |
| 284 }; |
| 285 |
| 286 $('bluetooth-reconnect-device').onclick = function(event) { |
| 287 var device = $('bluetooth-paired-devices-list').selectedItem; |
| 288 var address = device.address; |
| 289 chrome.send('updateBluetoothDevice', [address, 'connect']); |
| 290 OptionsPage.closeOverlay(); |
| 291 }; |
| 292 |
| 293 $('bluetooth-reconnect-device').onmousedown = function(event) { |
| 294 // Prevent 'blur' event, which would reset the list selection, |
| 295 // thereby disabling the apply button. |
| 296 event.preventDefault(); |
| 297 }; |
| 298 |
| 299 $('bluetooth-paired-devices-list').addEventListener('change', |
| 300 function() { |
| 301 var item = $('bluetooth-paired-devices-list').selectedItem; |
| 302 var disabled = !item || !item.paired || item.connected; |
| 303 $('bluetooth-reconnect-device').disabled = disabled; |
| 304 }); |
| 305 } |
| 306 |
| 307 // Passwords and Forms section. |
| 308 $('autofill-settings').onclick = function(event) { |
| 309 OptionsPage.navigateToPage('autofill'); |
| 310 chrome.send('coreOptionsUserMetricsAction', |
| 311 ['Options_ShowAutofillSettings']); |
| 312 }; |
| 313 $('manage-passwords').onclick = function(event) { |
| 314 OptionsPage.navigateToPage('passwords'); |
| 315 OptionsPage.showTab($('passwords-nav-tab')); |
| 316 chrome.send('coreOptionsUserMetricsAction', |
| 317 ['Options_ShowPasswordManager']); |
| 318 }; |
| 319 if (this.guestModeActive_()) { |
| 320 // Disable and turn off Autofill in guest mode. |
| 321 var autofillEnabled = $('autofill-enabled'); |
| 322 autofillEnabled.disabled = true; |
| 323 autofillEnabled.checked = false; |
| 324 cr.dispatchSimpleEvent(autofillEnabled, 'change'); |
| 325 $('autofill-settings').disabled = true; |
| 326 |
| 327 // Disable and turn off Password Manager in guest mode. |
| 328 var passwordManagerEnabled = $('password-manager-enabled'); |
| 329 passwordManagerEnabled.disabled = true; |
| 330 passwordManagerEnabled.checked = false; |
| 331 cr.dispatchSimpleEvent(passwordManagerEnabled, 'change'); |
| 332 $('manage-passwords').disabled = true; |
| 333 |
| 334 // Hide the entire section on ChromeOS |
| 335 if (cr.isChromeOS) |
| 336 $('passwords-and-autofill-section').hidden = true; |
| 337 } |
| 338 $('mac-passwords-warning').hidden = |
| 339 !(localStrings.getString('macPasswordsWarning')); |
| 340 |
| 341 // Network section. |
| 342 if (!cr.isChromeOS) { |
| 343 $('proxiesConfigureButton').onclick = function(event) { |
| 344 chrome.send('showNetworkProxySettings'); |
| 345 }; |
| 346 } |
| 347 |
| 348 // Web Content section. |
| 349 $('fontSettingsCustomizeFontsButton').onclick = function(event) { |
| 350 OptionsPage.navigateToPage('fonts'); |
| 351 chrome.send('coreOptionsUserMetricsAction', ['Options_FontSettings']); |
| 352 }; |
| 353 $('defaultFontSize').onchange = function(event) { |
| 354 var value = event.target.options[event.target.selectedIndex].value; |
| 355 Preferences.setIntegerPref( |
| 356 'webkit.webprefs.global.default_fixed_font_size', |
| 357 value - OptionsPage.SIZE_DIFFERENCE_FIXED_STANDARD, ''); |
| 358 chrome.send('defaultFontSizeAction', [String(value)]); |
| 359 }; |
| 360 $('defaultZoomFactor').onchange = function(event) { |
| 361 chrome.send('defaultZoomFactorAction', |
| 362 [String(event.target.options[event.target.selectedIndex].value)]); |
| 363 }; |
| 364 |
| 365 // Languages section. |
| 366 $('language-button').onclick = function(event) { |
| 367 OptionsPage.navigateToPage('languages'); |
| 368 chrome.send('coreOptionsUserMetricsAction', |
| 369 ['Options_LanuageAndSpellCheckSettings']); |
| 370 }; |
| 371 |
| 372 // Downloads section. |
| 373 if (!cr.isChromeOS) { |
| 374 $('downloadLocationChangeButton').onclick = function(event) { |
| 375 chrome.send('selectDownloadLocation'); |
| 376 }; |
| 377 // This text field is always disabled. Setting ".disabled = true" isn't |
| 378 // enough, since a policy can disable it but shouldn't re-enable when |
| 379 // it is removed. |
| 380 $('downloadLocationPath').setDisabled('readonly', true); |
| 381 $('autoOpenFileTypesResetToDefault').onclick = function(event) { |
| 382 chrome.send('autoOpenFileTypesAction'); |
| 383 }; |
| 384 } |
| 385 |
| 386 // HTTPS/SSL section. |
| 387 if (cr.isWindows || cr.isMac) { |
| 388 $('certificatesManageButton').onclick = function(event) { |
| 389 chrome.send('showManageSSLCertificates'); |
| 390 }; |
| 391 } else { |
| 392 $('certificatesManageButton').onclick = function(event) { |
| 393 OptionsPage.navigateToPage('certificates'); |
| 394 chrome.send('coreOptionsUserMetricsAction', |
| 395 ['Options_ManageSSLCertificates']); |
| 396 }; |
| 397 } |
| 398 $('sslCheckRevocation').onclick = function(event) { |
| 399 chrome.send('checkRevocationCheckboxAction', |
| 400 [String($('sslCheckRevocation').checked)]); |
| 401 }; |
| 402 |
| 403 // Cloud Print section. |
| 404 // 'cloudPrintProxyEnabled' is true for Chrome branded builds on |
| 405 // certain platforms, or could be enabled by a lab. |
| 406 if (!cr.isChromeOS) { |
| 407 $('cloudPrintConnectorSetupButton').onclick = function(event) { |
| 408 if ($('cloudPrintManageButton').style.display == 'none') { |
| 409 // Disable the button, set it's text to the intermediate state. |
| 410 $('cloudPrintConnectorSetupButton').textContent = |
| 411 localStrings.getString('cloudPrintConnectorEnablingButton'); |
| 412 $('cloudPrintConnectorSetupButton').disabled = true; |
| 413 chrome.send('showCloudPrintSetupDialog'); |
| 414 } else { |
| 415 chrome.send('disableCloudPrintConnector'); |
| 416 } |
| 417 }; |
| 418 } |
| 419 $('cloudPrintManageButton').onclick = function(event) { |
| 420 chrome.send('showCloudPrintManagePage'); |
| 421 }; |
| 422 |
| 423 // Accessibility section (CrOS only). |
| 424 if (cr.isChromeOS) { |
| 425 $('accessibility-spoken-feedback-check').onchange = function(event) { |
| 426 chrome.send('spokenFeedbackChange', |
| 427 [$('accessibility-spoken-feedback-check').checked]); |
| 428 }; |
| 429 } |
| 430 |
| 431 // Background mode section. |
| 432 if ($('backgroundModeCheckbox')) { |
| 433 $('backgroundModeCheckbox').onclick = function(event) { |
| 434 chrome.send('backgroundModeAction', |
| 435 [String($('backgroundModeCheckbox').checked)]); |
| 436 }; |
246 } | 437 } |
247 }, | 438 }, |
248 | 439 |
249 /** | 440 /** |
250 * @inheritDoc | 441 * @inheritDoc |
251 */ | 442 */ |
252 didShowPage: function() { | 443 didShowPage: function() { |
253 $('search-field').focus(); | 444 $('search-field').focus(); |
254 }, | 445 }, |
255 | 446 |
256 /** | 447 /** |
257 * Handler for messages sent from the main uber page. | 448 * Handler for messages sent from the main uber page. |
258 * @param {Event} e The 'message' event from the uber page. | 449 * @param {Event} e The 'message' event from the uber page. |
| 450 * @private |
259 */ | 451 */ |
260 handleWindowMessage_: function(e) { | 452 handleWindowMessage_: function(e) { |
261 if (e.data.method == 'frameSelected') | 453 if (e.data.method == 'frameSelected') |
262 $('search-field').focus(); | 454 $('search-field').focus(); |
263 }, | 455 }, |
264 | 456 |
265 /** | 457 /** |
| 458 * Toggle the visibility state of the Advanced section. |
| 459 * @private |
| 460 */ |
| 461 toggleAdvancedSettings_: function() { |
| 462 if ($('advanced-settings').style.height == '0px') |
| 463 this.showAdvancedSettings_(); |
| 464 else |
| 465 this.hideAdvancedSettings_(); |
| 466 }, |
| 467 |
| 468 /** |
| 469 * Show advanced settings. |
| 470 * @private |
| 471 */ |
| 472 showAdvancedSettings_: function() { |
| 473 $('advanced-settings').style.height = |
| 474 $('advanced-settings-container').offsetHeight + 20 + 'px'; |
| 475 $('advanced-settings-expander').innerHTML = |
| 476 localStrings.getString('hideAdvancedSettings'); |
| 477 }, |
| 478 |
| 479 /** |
| 480 * Hide advanced settings. |
| 481 * @private |
| 482 */ |
| 483 hideAdvancedSettings_: function() { |
| 484 $('advanced-settings').style.height = '0px' |
| 485 $('advanced-settings-expander').innerHTML = |
| 486 localStrings.getString('showAdvancedSettings'); |
| 487 }, |
| 488 |
| 489 /** |
266 * Updates managed banner visibility state. This function iterates over | 490 * Updates managed banner visibility state. This function iterates over |
267 * all input fields of all subpages and if any of these is marked as managed | 491 * all input fields of all subpages and if any of these is marked as managed |
268 * it triggers the managed banner to be visible. | 492 * it triggers the managed banner to be visible. |
269 * @private | 493 * @private |
270 */ | 494 */ |
271 updateManagedBannerVisibility_: function() { | 495 updateManagedBannerVisibility_: function() { |
272 var bannerDiv = $('managed-prefs-banner'); | 496 var bannerDiv = $('managed-prefs-banner'); |
273 | 497 |
274 var controlledByPolicy = false; | 498 var controlledByPolicy = false; |
275 var controlledByExtension = false; | 499 var controlledByExtension = false; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 /** | 760 /** |
537 * Update the Default Browsers section based on the current state. | 761 * Update the Default Browsers section based on the current state. |
538 * @param {string} statusString Description of the current default state. | 762 * @param {string} statusString Description of the current default state. |
539 * @param {boolean} isDefault Whether or not the browser is currently | 763 * @param {boolean} isDefault Whether or not the browser is currently |
540 * default. | 764 * default. |
541 * @param {boolean} canBeDefault Whether or not the browser can be default. | 765 * @param {boolean} canBeDefault Whether or not the browser can be default. |
542 * @private | 766 * @private |
543 */ | 767 */ |
544 updateDefaultBrowserState_: function(statusString, isDefault, | 768 updateDefaultBrowserState_: function(statusString, isDefault, |
545 canBeDefault) { | 769 canBeDefault) { |
546 var label = $('default-browser-state'); | 770 if (!cr.isChromeOS) { |
547 label.textContent = statusString; | 771 var label = $('default-browser-state'); |
| 772 label.textContent = statusString; |
548 | 773 |
549 $('set-as-default-browser').hidden = !canBeDefault || isDefault; | 774 $('set-as-default-browser').hidden = !canBeDefault || isDefault; |
| 775 } |
550 }, | 776 }, |
551 | 777 |
552 /** | 778 /** |
553 * Clears the search engine popup. | 779 * Clears the search engine popup. |
554 * @private | 780 * @private |
555 */ | 781 */ |
556 clearSearchEngines_: function() { | 782 clearSearchEngines_: function() { |
557 $('default-search-engine').textContent = ''; | 783 $('default-search-engine').textContent = ''; |
558 }, | 784 }, |
559 | 785 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 * (Re)loads IMG element with current user account picture. | 946 * (Re)loads IMG element with current user account picture. |
721 * @private | 947 * @private |
722 */ | 948 */ |
723 updateAccountPicture_: function() { | 949 updateAccountPicture_: function() { |
724 var picture = $('account-picture'); | 950 var picture = $('account-picture'); |
725 if (picture) { | 951 if (picture) { |
726 picture.src = 'chrome://userimage/' + this.username_ + '?id=' + | 952 picture.src = 'chrome://userimage/' + this.username_ + '?id=' + |
727 Date.now(); | 953 Date.now(); |
728 } | 954 } |
729 }, | 955 }, |
| 956 |
| 957 /** |
| 958 * Scan for bluetooth devices. |
| 959 * @param {boolean} reset Indicates if the list of unpaired devices should |
| 960 * be cleared. |
| 961 * @private |
| 962 */ |
| 963 findBluetoothDevices_: function(reset) { |
| 964 $('bluetooth-unpaired-devices-list').clear(); |
| 965 chrome.send('findBluetoothDevices'); |
| 966 }, |
| 967 |
| 968 /** |
| 969 * Set the checked state of the metrics reporting checkbox. |
| 970 * @private |
| 971 */ |
| 972 setMetricsReportingCheckboxState_: function(checked, disabled) { |
| 973 $('metricsReportingEnabled').checked = checked; |
| 974 $('metricsReportingEnabled').disabled = disabled; |
| 975 if (disabled) |
| 976 $('metricsReportingEnabledText').className = 'disable-services-span'; |
| 977 }, |
| 978 |
| 979 /** |
| 980 * @private |
| 981 */ |
| 982 setMetricsReportingSettingVisibility_: function(visible) { |
| 983 if (visible) |
| 984 $('metricsReportingSetting').style.display = 'block'; |
| 985 else |
| 986 $('metricsReportingSetting').style.display = 'none'; |
| 987 }, |
| 988 |
| 989 /** |
| 990 * Returns whether the browser in guest mode. Some features are disabled or |
| 991 * hidden in guest mode. |
| 992 * @return {boolean} True if guest mode is currently active. |
| 993 * @private |
| 994 */ |
| 995 guestModeActive_: function() { |
| 996 return cr.commandLine && cr.commandLine.options['--bwsi']; |
| 997 }, |
| 998 |
| 999 /** |
| 1000 * Set the font size selected item. |
| 1001 * @private |
| 1002 */ |
| 1003 setFontSize_: function(font_size_value) { |
| 1004 var selectCtl = $('defaultFontSize'); |
| 1005 for (var i = 0; i < selectCtl.options.length; i++) { |
| 1006 if (selectCtl.options[i].value == font_size_value) { |
| 1007 selectCtl.selectedIndex = i; |
| 1008 if ($('Custom')) |
| 1009 selectCtl.remove($('Custom').index); |
| 1010 return; |
| 1011 } |
| 1012 } |
| 1013 |
| 1014 // Add/Select Custom Option in the font size label list. |
| 1015 if (!$('Custom')) { |
| 1016 var option = new Option(localStrings.getString('fontSizeLabelCustom'), |
| 1017 -1, false, true); |
| 1018 option.setAttribute('id', 'Custom'); |
| 1019 selectCtl.add(option); |
| 1020 } |
| 1021 $('Custom').selected = true; |
| 1022 }, |
| 1023 |
| 1024 /** |
| 1025 * Populate the page zoom selector with values received from the caller. |
| 1026 * @param {Array} items An array of items to populate the selector. |
| 1027 * each object is an array with three elements as follows: |
| 1028 * 0: The title of the item (string). |
| 1029 * 1: The value of the item (number). |
| 1030 * 2: Whether the item should be selected (boolean). |
| 1031 * @private |
| 1032 */ |
| 1033 setupPageZoomSelector_: function(items) { |
| 1034 var element = $('defaultZoomFactor'); |
| 1035 |
| 1036 // Remove any existing content. |
| 1037 element.textContent = ''; |
| 1038 |
| 1039 // Insert new child nodes into select element. |
| 1040 var value, title, selected; |
| 1041 for (var i = 0; i < items.length; i++) { |
| 1042 title = items[i][0]; |
| 1043 value = items[i][1]; |
| 1044 selected = items[i][2]; |
| 1045 element.appendChild(new Option(title, value, false, selected)); |
| 1046 } |
| 1047 }, |
| 1048 |
| 1049 /** |
| 1050 * Set the enabled state for the autoOpenFileTypesResetToDefault button. |
| 1051 * @private |
| 1052 */ |
| 1053 setAutoOpenFileTypesDisabledAttribute_: function(disabled) { |
| 1054 if (!cr.isChromeOS) { |
| 1055 $('autoOpenFileTypesResetToDefault').disabled = disabled; |
| 1056 if (disabled) |
| 1057 $('auto-open-file-types-label').classList.add('disabled'); |
| 1058 else |
| 1059 $('auto-open-file-types-label').classList.remove('disabled'); |
| 1060 } |
| 1061 }, |
| 1062 |
| 1063 /** |
| 1064 * Set the enabled state for the proxy settings button. |
| 1065 * @private |
| 1066 */ |
| 1067 setupProxySettingsSection_: function(disabled, label) { |
| 1068 if (!cr.isChromeOS) { |
| 1069 $('proxiesConfigureButton').disabled = disabled; |
| 1070 $('proxiesLabel').textContent = label; |
| 1071 } |
| 1072 }, |
| 1073 |
| 1074 /** |
| 1075 * Set the checked state for the sslCheckRevocation checkbox. |
| 1076 * @private |
| 1077 */ |
| 1078 setCheckRevocationCheckboxState_: function(checked, disabled) { |
| 1079 $('sslCheckRevocation').checked = checked; |
| 1080 $('sslCheckRevocation').disabled = disabled; |
| 1081 }, |
| 1082 |
| 1083 /** |
| 1084 * Set the checked state for the backgroundModeCheckbox element. |
| 1085 * @private |
| 1086 */ |
| 1087 setBackgroundModeCheckboxState_: function(checked) { |
| 1088 $('backgroundModeCheckbox').checked = checked; |
| 1089 }, |
| 1090 |
| 1091 /** |
| 1092 * Set the Cloud Print proxy UI to enabled, disabled, or processing. |
| 1093 * @private |
| 1094 */ |
| 1095 setupCloudPrintConnectorSection_: function(disabled, label, allowed) { |
| 1096 if (!cr.isChromeOS) { |
| 1097 $('cloudPrintConnectorLabel').textContent = label; |
| 1098 if (disabled || !allowed) { |
| 1099 $('cloudPrintConnectorSetupButton').textContent = |
| 1100 localStrings.getString('cloudPrintConnectorDisabledButton'); |
| 1101 $('cloudPrintManageButton').style.display = 'none'; |
| 1102 } else { |
| 1103 $('cloudPrintConnectorSetupButton').textContent = |
| 1104 localStrings.getString('cloudPrintConnectorEnabledButton'); |
| 1105 $('cloudPrintManageButton').style.display = 'inline'; |
| 1106 } |
| 1107 $('cloudPrintConnectorSetupButton').disabled = !allowed; |
| 1108 } |
| 1109 }, |
| 1110 |
| 1111 /** |
| 1112 * @private |
| 1113 */ |
| 1114 removeCloudPrintConnectorSection_: function() { |
| 1115 if (!cr.isChromeOS) { |
| 1116 var connectorSectionElm = $('cloud-print-connector-section'); |
| 1117 if (connectorSectionElm) |
| 1118 connectorSectionElm.parentNode.removeChild(connectorSectionElm); |
| 1119 } |
| 1120 }, |
| 1121 |
| 1122 /** |
| 1123 * Set the initial state of the spoken feedback checkbox. |
| 1124 * @private |
| 1125 */ |
| 1126 setSpokenFeedbackCheckboxState_: function(checked) { |
| 1127 $('accessibility-spoken-feedback-check').checked = checked; |
| 1128 }, |
| 1129 |
| 1130 /** |
| 1131 * Set the initial state of the high contrast checkbox. |
| 1132 * @private |
| 1133 */ |
| 1134 setHighContrastCheckboxState_: function(checked) { |
| 1135 // TODO(zork): Update UI |
| 1136 }, |
| 1137 |
| 1138 /** |
| 1139 * Set the initial state of the screen magnifier checkbox. |
| 1140 * @private |
| 1141 */ |
| 1142 setScreenMagnifierCheckboxState_: function(checked) { |
| 1143 // TODO(zork): Update UI |
| 1144 }, |
| 1145 |
| 1146 /** |
| 1147 * Set the initial state of the virtual keyboard checkbox. |
| 1148 * @private |
| 1149 */ |
| 1150 setVirtualKeyboardCheckboxState_: function(checked) { |
| 1151 // TODO(zork): Update UI |
| 1152 }, |
| 1153 |
| 1154 /** |
| 1155 * Activate the bluetooth settings section on the System settings page. |
| 1156 * @private |
| 1157 */ |
| 1158 showBluetoothSettings_: function() { |
| 1159 $('bluetooth-devices').hidden = false; |
| 1160 }, |
| 1161 |
| 1162 /** |
| 1163 * Sets the state of the checkbox indicating if bluetooth is turned on. The |
| 1164 * state of the "Find devices" button and the list of discovered devices may |
| 1165 * also be affected by a change to the state. |
| 1166 * @param {boolean} checked Flag Indicating if Bluetooth is turned on. |
| 1167 * @private |
| 1168 */ |
| 1169 setBluetoothState_: function(checked) { |
| 1170 $('enable-bluetooth').checked = checked; |
| 1171 $('bluetooth-paired-devices-list').parentNode.hidden = !checked; |
| 1172 $('bluetooth-add-device').hidden = !checked; |
| 1173 $('bluetooth-reconnect-device').hidden = !checked; |
| 1174 // Flush list of previously discovered devices if bluetooth is turned off. |
| 1175 if (!checked) { |
| 1176 $('bluetooth-paired-devices-list').clear(); |
| 1177 $('bluetooth-unpaired-devices-list').clear(); |
| 1178 } else { |
| 1179 chrome.send('getPairedBluetoothDevices'); |
| 1180 } |
| 1181 }, |
| 1182 |
| 1183 /** |
| 1184 * Adds an element to the list of available bluetooth devices. If an element |
| 1185 * with a matching address is found, the existing element is updated. |
| 1186 * @param {{name: string, |
| 1187 * address: string, |
| 1188 * icon: string, |
| 1189 * paired: boolean, |
| 1190 * connected: boolean}} device |
| 1191 * Decription of the bluetooth device. |
| 1192 * @private |
| 1193 */ |
| 1194 addBluetoothDevice_: function(device) { |
| 1195 var list = $('bluetooth-unpaired-devices-list'); |
| 1196 if (device.paired) { |
| 1197 // Test to see if the device is currently in the unpaired list, in which |
| 1198 // case it should be removed from that list. |
| 1199 var index = $('bluetooth-unpaired-devices-list').find(device.address); |
| 1200 if (index != undefined) |
| 1201 $('bluetooth-unpaired-devices-list').deleteItemAtIndex(index); |
| 1202 list = $('bluetooth-paired-devices-list'); |
| 1203 } |
| 1204 list.appendDevice(device); |
| 1205 |
| 1206 // One device can be in the process of pairing. If found, display |
| 1207 // the Bluetooth pairing overlay. |
| 1208 if (device.pairing) |
| 1209 BluetoothPairing.showDialog(device); |
| 1210 }, |
730 }; | 1211 }; |
731 | 1212 |
732 //Forward public APIs to private implementations. | 1213 //Forward public APIs to private implementations. |
733 [ | 1214 [ |
| 1215 'addBluetoothDevice', |
734 'getStartStopSyncButton', | 1216 'getStartStopSyncButton', |
| 1217 'guestModeActive', |
| 1218 'removeCloudPrintConnectorSection', |
| 1219 'setAutoOpenFileTypesDisabledAttribute', |
| 1220 'setBackgroundModeCheckboxState', |
| 1221 'setBluetoothState', |
| 1222 'setCheckRevocationCheckboxState', |
| 1223 'setFontSize', |
735 'setGtkThemeButtonEnabled', | 1224 'setGtkThemeButtonEnabled', |
| 1225 'setHighContrastCheckboxState', |
736 'setInstantFieldTrialStatus', | 1226 'setInstantFieldTrialStatus', |
| 1227 'setMetricsReportingCheckboxState', |
| 1228 'setMetricsReportingSettingVisibility', |
737 'setProfilesInfo', | 1229 'setProfilesInfo', |
738 'setProfilesSectionVisible', | 1230 'setProfilesSectionVisible', |
| 1231 'setScreenMagnifierCheckboxState', |
| 1232 'setSpokenFeedbackCheckboxState', |
739 'setThemesResetButtonEnabled', | 1233 'setThemesResetButtonEnabled', |
| 1234 'setupCloudPrintConnectorSection', |
| 1235 'setupPageZoomSelector', |
| 1236 'setupProxySettingsSection', |
| 1237 'setVirtualKeyboardCheckboxState', |
| 1238 'showBluetoothSettings', |
740 'updateAccountPicture', | 1239 'updateAccountPicture', |
741 'updateAutocompleteSuggestions', | 1240 'updateAutocompleteSuggestions', |
742 'updateAutoLaunchState', | 1241 'updateAutoLaunchState', |
| 1242 'updateDefaultBrowserState', |
743 'updateManagedBannerVisibility', | 1243 'updateManagedBannerVisibility', |
744 'updateSearchEngines', | 1244 'updateSearchEngines', |
745 'updateSyncState', | 1245 'updateSyncState', |
746 'updateStartupPages', | 1246 'updateStartupPages', |
747 ].forEach(function(name) { | 1247 ].forEach(function(name) { |
748 BrowserOptions[name] = function() { | 1248 BrowserOptions[name] = function() { |
749 var instance = BrowserOptions.getInstance(); | 1249 var instance = BrowserOptions.getInstance(); |
750 return instance[name + '_'].apply(instance, arguments); | 1250 return instance[name + '_'].apply(instance, arguments); |
751 }; | 1251 }; |
752 }); | 1252 }); |
753 | 1253 |
754 BrowserOptions.updateDefaultBrowserState = function(statusString, isDefault, | |
755 canBeDefault) { | |
756 if (!cr.isChromeOS) { | |
757 BrowserOptions.getInstance().updateDefaultBrowserState_(statusString, | |
758 isDefault, | |
759 canBeDefault); | |
760 } | |
761 }; | |
762 | |
763 if (cr.isChromeOS) { | 1254 if (cr.isChromeOS) { |
764 /** | 1255 /** |
765 * Returns username (canonical email) of the user logged in (ChromeOS only). | 1256 * Returns username (canonical email) of the user logged in (ChromeOS only). |
766 * @return {string} user email. | 1257 * @return {string} user email. |
767 */ | 1258 */ |
768 // TODO(jhawkins): Investigate the use case for this method. | 1259 // TODO(jhawkins): Investigate the use case for this method. |
769 BrowserOptions.getLoggedInUsername = function() { | 1260 BrowserOptions.getLoggedInUsername = function() { |
770 return BrowserOptions.getInstance().username_; | 1261 return BrowserOptions.getInstance().username_; |
771 }; | 1262 }; |
772 } | 1263 } |
773 | 1264 |
774 // Export | 1265 // Export |
775 return { | 1266 return { |
776 BrowserOptions: BrowserOptions | 1267 BrowserOptions: BrowserOptions |
777 }; | 1268 }; |
778 }); | 1269 }); |
OLD | NEW |