| 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 | 6 |
| 7 var OptionsPage = options.OptionsPage; | 7 var OptionsPage = options.OptionsPage; |
| 8 | 8 |
| 9 // | 9 // |
| 10 // AdvancedOptions class | 10 // AdvancedOptions class |
| 11 // Encapsulated handling of advanced options page. | 11 // Encapsulated handling of advanced options page. |
| 12 // | 12 // |
| 13 function AdvancedOptions() { | 13 function AdvancedOptions() { |
| 14 OptionsPage.call(this, 'advanced', templateData.advancedPageTabTitle, | 14 OptionsPage.call(this, 'advanced', templateData.advancedPageTabTitle, |
| 15 'advancedPage'); | 15 'advancedPage'); |
| 16 } | 16 } |
| 17 | 17 |
| 18 cr.addSingletonGetter(AdvancedOptions); | 18 cr.addSingletonGetter(AdvancedOptions); |
| 19 | 19 |
| 20 AdvancedOptions.prototype = { | 20 AdvancedOptions.prototype = { |
| 21 // Inherit AdvancedOptions from OptionsPage. | 21 // Inherit AdvancedOptions from OptionsPage. |
| 22 __proto__: options.OptionsPage.prototype, | 22 __proto__: options.OptionsPage.prototype, |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * Flag indicating if currently scanning for Bluetooth devices. |
| 26 * @type {boolean} |
| 27 */ |
| 28 isScanning_: false, |
| 29 |
| 30 /** |
| 25 * Initializes the page. | 31 * Initializes the page. |
| 26 */ | 32 */ |
| 27 initializePage: function() { | 33 initializePage: function() { |
| 28 // Call base class implementation to starts preference initialization. | 34 // Call base class implementation to starts preference initialization. |
| 29 OptionsPage.prototype.initializePage.call(this); | 35 OptionsPage.prototype.initializePage.call(this); |
| 30 | 36 |
| 31 // Set up click handlers for buttons. | 37 // Date and time section (CrOS only). |
| 38 if (cr.isChromeOS && AccountsOptions.loggedInAsGuest()) { |
| 39 // Disable time-related settings if we're not logged in as a real user. |
| 40 $('timezone-select').disabled = true; |
| 41 $('use-24hour-clock').disabled = true; |
| 42 } |
| 43 |
| 44 // Privacy section. |
| 32 $('privacyContentSettingsButton').onclick = function(event) { | 45 $('privacyContentSettingsButton').onclick = function(event) { |
| 33 OptionsPage.navigateToPage('content'); | 46 OptionsPage.navigateToPage('content'); |
| 34 OptionsPage.showTab($('cookies-nav-tab')); | 47 OptionsPage.showTab($('cookies-nav-tab')); |
| 35 chrome.send('coreOptionsUserMetricsAction', | 48 chrome.send('coreOptionsUserMetricsAction', |
| 36 ['Options_ContentSettings']); | 49 ['Options_ContentSettings']); |
| 37 }; | 50 }; |
| 38 $('privacyClearDataButton').onclick = function(event) { | 51 $('privacyClearDataButton').onclick = function(event) { |
| 39 OptionsPage.navigateToPage('clearBrowserData'); | 52 OptionsPage.navigateToPage('clearBrowserData'); |
| 40 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); | 53 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); |
| 41 }; | 54 }; |
| 42 | |
| 43 // 'metricsReportingEnabled' element is only present on Chrome branded | 55 // 'metricsReportingEnabled' element is only present on Chrome branded |
| 44 // builds. | 56 // builds. |
| 45 if ($('metricsReportingEnabled')) { | 57 if ($('metricsReportingEnabled')) { |
| 46 $('metricsReportingEnabled').onclick = function(event) { | 58 $('metricsReportingEnabled').onclick = function(event) { |
| 47 chrome.send('metricsReportingCheckboxAction', | 59 chrome.send('metricsReportingCheckboxAction', |
| 48 [String(event.target.checked)]); | 60 [String(event.target.checked)]); |
| 49 }; | 61 }; |
| 50 } | 62 } |
| 51 | 63 |
| 52 // Passwords and Forms. | 64 // Bluetooth (CrOS only). |
| 65 if (cr.isChromeOS) { |
| 66 options.system.bluetooth.BluetoothDeviceList.decorate( |
| 67 $('bluetooth-paired-devices-list')); |
| 68 |
| 69 $('bluetooth-add-device').onclick = function(event) { |
| 70 if (!this.isScanning_) |
| 71 findBluetoothDevices_(true); |
| 72 OptionsPage.navigateToPage('bluetooth'); |
| 73 }; |
| 74 $('enable-bluetooth').onclick = function(event) { |
| 75 chrome.send('bluetoothEnableChange', [Boolean(true)]); |
| 76 }; |
| 77 $('disable-bluetooth').onclick = function(event) { |
| 78 chrome.send('bluetoothEnableChange', [Boolean(false)]); |
| 79 }; |
| 80 } |
| 81 |
| 82 // Passwords and Forms section. |
| 53 $('autofill-settings').onclick = function(event) { | 83 $('autofill-settings').onclick = function(event) { |
| 54 OptionsPage.navigateToPage('autofill'); | 84 OptionsPage.navigateToPage('autofill'); |
| 55 chrome.send('coreOptionsUserMetricsAction', | 85 chrome.send('coreOptionsUserMetricsAction', |
| 56 ['Options_ShowAutofillSettings']); | 86 ['Options_ShowAutofillSettings']); |
| 57 }; | 87 }; |
| 58 $('manage-passwords').onclick = function(event) { | 88 $('manage-passwords').onclick = function(event) { |
| 59 OptionsPage.navigateToPage('passwords'); | 89 OptionsPage.navigateToPage('passwords'); |
| 60 OptionsPage.showTab($('passwords-nav-tab')); | 90 OptionsPage.showTab($('passwords-nav-tab')); |
| 61 chrome.send('coreOptionsUserMetricsAction', | 91 chrome.send('coreOptionsUserMetricsAction', |
| 62 ['Options_ShowPasswordManager']); | 92 ['Options_ShowPasswordManager']); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 76 cr.dispatchSimpleEvent(passwordManagerEnabled, 'change'); | 106 cr.dispatchSimpleEvent(passwordManagerEnabled, 'change'); |
| 77 $('manage-passwords').disabled = true; | 107 $('manage-passwords').disabled = true; |
| 78 | 108 |
| 79 // Hide the entire section on ChromeOS | 109 // Hide the entire section on ChromeOS |
| 80 if (cr.isChromeOS) | 110 if (cr.isChromeOS) |
| 81 $('passwords-and-autofill-section').hidden = true; | 111 $('passwords-and-autofill-section').hidden = true; |
| 82 } | 112 } |
| 83 $('mac-passwords-warning').hidden = | 113 $('mac-passwords-warning').hidden = |
| 84 !(localStrings.getString('macPasswordsWarning')); | 114 !(localStrings.getString('macPasswordsWarning')); |
| 85 | 115 |
| 116 // Network section. |
| 86 if (!cr.isChromeOS) { | 117 if (!cr.isChromeOS) { |
| 87 $('autoOpenFileTypesResetToDefault').onclick = function(event) { | 118 $('proxiesConfigureButton').onclick = function(event) { |
| 88 chrome.send('autoOpenFileTypesAction'); | 119 chrome.send('showNetworkProxySettings'); |
| 89 }; | 120 }; |
| 90 } | 121 } |
| 91 | 122 |
| 123 // Web Content section. |
| 92 $('fontSettingsCustomizeFontsButton').onclick = function(event) { | 124 $('fontSettingsCustomizeFontsButton').onclick = function(event) { |
| 93 OptionsPage.navigateToPage('fonts'); | 125 OptionsPage.navigateToPage('fonts'); |
| 94 chrome.send('coreOptionsUserMetricsAction', ['Options_FontSettings']); | 126 chrome.send('coreOptionsUserMetricsAction', ['Options_FontSettings']); |
| 95 }; | 127 }; |
| 96 $('defaultFontSize').onchange = function(event) { | 128 $('defaultFontSize').onchange = function(event) { |
| 97 chrome.send('defaultFontSizeAction', | 129 chrome.send('defaultFontSizeAction', |
| 98 [String(event.target.options[event.target.selectedIndex].value)]); | 130 [String(event.target.options[event.target.selectedIndex].value)]); |
| 99 }; | 131 }; |
| 100 $('defaultZoomFactor').onchange = function(event) { | 132 $('defaultZoomFactor').onchange = function(event) { |
| 101 chrome.send('defaultZoomFactorAction', | 133 chrome.send('defaultZoomFactorAction', |
| 102 [String(event.target.options[event.target.selectedIndex].value)]); | 134 [String(event.target.options[event.target.selectedIndex].value)]); |
| 103 }; | 135 }; |
| 104 | 136 |
| 137 // Languages section. |
| 105 $('language-button').onclick = function(event) { | 138 $('language-button').onclick = function(event) { |
| 106 OptionsPage.navigateToPage('languages'); | 139 OptionsPage.navigateToPage('languages'); |
| 107 chrome.send('coreOptionsUserMetricsAction', | 140 chrome.send('coreOptionsUserMetricsAction', |
| 108 ['Options_LanuageAndSpellCheckSettings']); | 141 ['Options_LanuageAndSpellCheckSettings']); |
| 109 }; | 142 }; |
| 110 | 143 |
| 144 // Downloads section. |
| 145 if (!cr.isChromeOS) { |
| 146 $('downloadLocationChangeButton').onclick = function(event) { |
| 147 chrome.send('selectDownloadLocation'); |
| 148 }; |
| 149 // This text field is always disabled. Setting ".disabled = true" isn't |
| 150 // enough, since a policy can disable it but shouldn't re-enable when |
| 151 // it is removed. |
| 152 $('downloadLocationPath').setDisabled('readonly', true); |
| 153 $('autoOpenFileTypesResetToDefault').onclick = function(event) { |
| 154 chrome.send('autoOpenFileTypesAction'); |
| 155 }; |
| 156 } |
| 157 |
| 158 // HTTPS/SSL section. |
| 111 if (cr.isWindows || cr.isMac) { | 159 if (cr.isWindows || cr.isMac) { |
| 112 $('certificatesManageButton').onclick = function(event) { | 160 $('certificatesManageButton').onclick = function(event) { |
| 113 chrome.send('showManageSSLCertificates'); | 161 chrome.send('showManageSSLCertificates'); |
| 114 }; | 162 }; |
| 115 } else { | 163 } else { |
| 116 $('certificatesManageButton').onclick = function(event) { | 164 $('certificatesManageButton').onclick = function(event) { |
| 117 OptionsPage.navigateToPage('certificates'); | 165 OptionsPage.navigateToPage('certificates'); |
| 118 chrome.send('coreOptionsUserMetricsAction', | 166 chrome.send('coreOptionsUserMetricsAction', |
| 119 ['Options_ManageSSLCertificates']); | 167 ['Options_ManageSSLCertificates']); |
| 120 }; | 168 }; |
| 121 } | 169 } |
| 122 | |
| 123 if (!cr.isChromeOS) { | |
| 124 $('proxiesConfigureButton').onclick = function(event) { | |
| 125 chrome.send('showNetworkProxySettings'); | |
| 126 }; | |
| 127 $('downloadLocationChangeButton').onclick = function(event) { | |
| 128 chrome.send('selectDownloadLocation'); | |
| 129 }; | |
| 130 // This text field is always disabled. Setting ".disabled = true" isn't | |
| 131 // enough, since a policy can disable it but shouldn't re-enable when | |
| 132 // it is removed. | |
| 133 $('downloadLocationPath').setDisabled('readonly', true); | |
| 134 } | |
| 135 | |
| 136 $('sslCheckRevocation').onclick = function(event) { | 170 $('sslCheckRevocation').onclick = function(event) { |
| 137 chrome.send('checkRevocationCheckboxAction', | 171 chrome.send('checkRevocationCheckboxAction', |
| 138 [String($('sslCheckRevocation').checked)]); | 172 [String($('sslCheckRevocation').checked)]); |
| 139 }; | 173 }; |
| 140 | 174 |
| 141 if ($('backgroundModeCheckbox')) { | 175 // Cloud Print section. |
| 142 $('backgroundModeCheckbox').onclick = function(event) { | |
| 143 chrome.send('backgroundModeAction', | |
| 144 [String($('backgroundModeCheckbox').checked)]); | |
| 145 }; | |
| 146 } | |
| 147 | |
| 148 // 'cloudPrintProxyEnabled' is true for Chrome branded builds on | 176 // 'cloudPrintProxyEnabled' is true for Chrome branded builds on |
| 149 // certain platforms, or could be enabled by a lab. | 177 // certain platforms, or could be enabled by a lab. |
| 150 if (!cr.isChromeOS) { | 178 if (!cr.isChromeOS) { |
| 151 $('cloudPrintConnectorSetupButton').onclick = function(event) { | 179 $('cloudPrintConnectorSetupButton').onclick = function(event) { |
| 152 if ($('cloudPrintManageButton').style.display == 'none') { | 180 if ($('cloudPrintManageButton').style.display == 'none') { |
| 153 // Disable the button, set it's text to the intermediate state. | 181 // Disable the button, set it's text to the intermediate state. |
| 154 $('cloudPrintConnectorSetupButton').textContent = | 182 $('cloudPrintConnectorSetupButton').textContent = |
| 155 localStrings.getString('cloudPrintConnectorEnablingButton'); | 183 localStrings.getString('cloudPrintConnectorEnablingButton'); |
| 156 $('cloudPrintConnectorSetupButton').disabled = true; | 184 $('cloudPrintConnectorSetupButton').disabled = true; |
| 157 chrome.send('showCloudPrintSetupDialog'); | 185 chrome.send('showCloudPrintSetupDialog'); |
| 158 } else { | 186 } else { |
| 159 chrome.send('disableCloudPrintConnector'); | 187 chrome.send('disableCloudPrintConnector'); |
| 160 } | 188 } |
| 161 }; | 189 }; |
| 162 } | 190 } |
| 163 $('cloudPrintManageButton').onclick = function(event) { | 191 $('cloudPrintManageButton').onclick = function(event) { |
| 164 chrome.send('showCloudPrintManagePage'); | 192 chrome.send('showCloudPrintManagePage'); |
| 165 }; | 193 }; |
| 166 | 194 |
| 195 // Accessibility section (CrOS only). |
| 196 if (cr.isChromeOS) { |
| 197 $('accessibility-spoken-feedback-check').onchange = function(event) { |
| 198 chrome.send('spokenFeedbackChange', |
| 199 [$('accessibility-spoken-feedback-check').checked]); |
| 200 }; |
| 201 $('accessibility-high-contrast-check').onchange = function(event) { |
| 202 chrome.send('highContrastChange', |
| 203 [$('accessibility-high-contrast-check').checked]); |
| 204 }; |
| 205 $('accessibility-screen-magnifier-check').onchange = function(event) { |
| 206 chrome.send('screenMagnifierChange', |
| 207 [$('accessibility-screen-magnifier-check').checked]); |
| 208 }; |
| 209 $('accessibility-virtual-keyboard-check').onchange = function(event) { |
| 210 chrome.send('virtualKeyboardChange', |
| 211 [$('accessibility-virtual-keyboard-check').checked]); |
| 212 }; |
| 213 } |
| 214 |
| 215 // Background mode section. |
| 216 if ($('backgroundModeCheckbox')) { |
| 217 $('backgroundModeCheckbox').onclick = function(event) { |
| 218 chrome.send('backgroundModeAction', |
| 219 [String($('backgroundModeCheckbox').checked)]); |
| 220 }; |
| 221 } |
| 222 } |
| 223 }; |
| 224 |
| 225 /** |
| 226 * Scan for bluetooth devices. |
| 227 * @param {boolean} reset Indicates if the list of unpaired devices should be |
| 228 * cleared. |
| 229 * @private |
| 230 */ |
| 231 function findBluetoothDevices_(reset) { |
| 232 this.isScanning_ = true; |
| 233 if (reset) |
| 234 $('bluetooth-unpaired-devices-list').clear(); |
| 235 chrome.send('findBluetoothDevices'); |
| 167 } | 236 } |
| 168 }; | |
| 169 | 237 |
| 170 // | 238 // |
| 171 // Chrome callbacks | 239 // Chrome callbacks |
| 172 // | 240 // |
| 173 | 241 |
| 174 // Set the checked state of the metrics reporting checkbox. | 242 // Set the checked state of the metrics reporting checkbox. |
| 175 AdvancedOptions.SetMetricsReportingCheckboxState = function( | 243 AdvancedOptions.SetMetricsReportingCheckboxState = function( |
| 176 checked, disabled) { | 244 checked, disabled) { |
| 177 $('metricsReportingEnabled').checked = checked; | 245 $('metricsReportingEnabled').checked = checked; |
| 178 $('metricsReportingEnabled').disabled = disabled; | 246 $('metricsReportingEnabled').disabled = disabled; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 }; | 362 }; |
| 295 | 363 |
| 296 AdvancedOptions.RemoveCloudPrintConnectorSection = function() { | 364 AdvancedOptions.RemoveCloudPrintConnectorSection = function() { |
| 297 if (!cr.isChromeOS) { | 365 if (!cr.isChromeOS) { |
| 298 var connectorSectionElm = $('cloud-print-connector-section'); | 366 var connectorSectionElm = $('cloud-print-connector-section'); |
| 299 if (connectorSectionElm) | 367 if (connectorSectionElm) |
| 300 connectorSectionElm.parentNode.removeChild(connectorSectionElm); | 368 connectorSectionElm.parentNode.removeChild(connectorSectionElm); |
| 301 } | 369 } |
| 302 }; | 370 }; |
| 303 | 371 |
| 372 /** |
| 373 * Set the initial state of the spoken feedback checkbox. |
| 374 */ |
| 375 AdvancedOptions.setSpokenFeedbackCheckboxState = function(checked) { |
| 376 $('accessibility-spoken-feedback-check').checked = checked; |
| 377 }; |
| 378 |
| 379 /** |
| 380 * Set the initial state of the high contrast checkbox. |
| 381 */ |
| 382 AdvancedOptions.setHighContrastCheckboxState = function(checked) { |
| 383 $('accessibility-high-contrast-check').checked = checked; |
| 384 }; |
| 385 |
| 386 /** |
| 387 * Set the initial state of the screen magnifier checkbox. |
| 388 */ |
| 389 AdvancedOptions.setScreenMagnifierCheckboxState = function(checked) { |
| 390 $('accessibility-screen-magnifier-check').checked = checked; |
| 391 }; |
| 392 |
| 393 /** |
| 394 * Set the initial state of the virtual keyboard checkbox. |
| 395 */ |
| 396 AdvancedOptions.setVirtualKeyboardCheckboxState = function(checked) { |
| 397 $('accessibility-virtual-keyboard-check').checked = checked; |
| 398 }; |
| 399 |
| 400 /** |
| 401 * Activate the bluetooth settings section on the System settings page. |
| 402 */ |
| 403 AdvancedOptions.showBluetoothSettings = function() { |
| 404 $('bluetooth-devices').hidden = false; |
| 405 }; |
| 406 |
| 407 /** |
| 408 * Sets the state of the checkbox indicating if bluetooth is turned on. The |
| 409 * state of the "Find devices" button and the list of discovered devices may |
| 410 * also be affected by a change to the state. |
| 411 * @param {boolean} checked Flag Indicating if Bluetooth is turned on. |
| 412 */ |
| 413 AdvancedOptions.setBluetoothState = function(checked) { |
| 414 $('disable-bluetooth').hidden = !checked; |
| 415 $('enable-bluetooth').hidden = checked; |
| 416 $('bluetooth-paired-devices-list').parentNode.hidden = !checked; |
| 417 $('bluetooth-add-device').hidden = !checked; |
| 418 // Flush list of previously discovered devices if bluetooth is turned off. |
| 419 if (!checked) { |
| 420 $('bluetooth-paired-devices-list').clear(); |
| 421 $('bluetooth-unpaired-devices-list').clear(); |
| 422 } |
| 423 if (checked && ! this.isScanning_) |
| 424 findBluetoothDevices_(true); |
| 425 } |
| 426 |
| 427 /** |
| 428 * Adds an element to the list of available bluetooth devices. If an element |
| 429 * with a matching address is found, the existing element is updated. |
| 430 * @param {{name: string, |
| 431 * address: string, |
| 432 * icon: string, |
| 433 * paired: boolean, |
| 434 * connected: boolean}} device |
| 435 * Decription of the bluetooth device. |
| 436 */ |
| 437 AdvancedOptions.addBluetoothDevice = function(device) { |
| 438 if (device.paired) { |
| 439 // Test to see if the device is currently in the unpaired list, in which |
| 440 // case it should be removed from that list. |
| 441 var index = $('bluetooth-unpaired-devices-list').find(device.address); |
| 442 if (index != undefined) |
| 443 $('bluetooth-unpaired-devices-list').deleteItemAtIndex(index); |
| 444 $('bluetooth-paired-devices-list').appendDevice(device); |
| 445 } else { |
| 446 $('bluetooth-unpaired-devices-list').appendDevice(device); |
| 447 } |
| 448 // One device can be in the process of pairing. If found, display |
| 449 // the Bluetooth pairing overlay. |
| 450 if (device.pairing) |
| 451 BluetoothPairing.showDialog(device); |
| 452 }; |
| 453 |
| 454 /** |
| 455 * Notification that a single pass of device discovery has completed. |
| 456 */ |
| 457 AdvancedOptions.notifyBluetoothSearchComplete = function() { |
| 458 // TODO(kevers): Determine the fate of this method once continuous |
| 459 // scanning is implemented in the Bluetooth code. |
| 460 this.isScanning_ = false; |
| 461 }; |
| 462 |
| 304 // Export | 463 // Export |
| 305 return { | 464 return { |
| 306 AdvancedOptions: AdvancedOptions | 465 AdvancedOptions: AdvancedOptions |
| 307 }; | 466 }; |
| 308 | 467 |
| 309 }); | 468 }); |
| OLD | NEW |