| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 cr.define('options', function() { | |
| 6 | |
| 7 var OptionsPage = options.OptionsPage; | |
| 8 | |
| 9 // | |
| 10 // AdvancedOptions class | |
| 11 // Encapsulated handling of advanced options page. | |
| 12 // | |
| 13 function AdvancedOptions() { | |
| 14 OptionsPage.call(this, 'advanced', templateData.advancedPageTabTitle, | |
| 15 'advancedPage'); | |
| 16 } | |
| 17 | |
| 18 cr.addSingletonGetter(AdvancedOptions); | |
| 19 | |
| 20 AdvancedOptions.prototype = { | |
| 21 // Inherit AdvancedOptions from OptionsPage. | |
| 22 __proto__: options.OptionsPage.prototype, | |
| 23 | |
| 24 /** | |
| 25 * Initializes the page. | |
| 26 */ | |
| 27 initializePage: function() { | |
| 28 // Call base class implementation to starts preference initialization. | |
| 29 OptionsPage.prototype.initializePage.call(this); | |
| 30 | |
| 31 // Set up click handlers for buttons. | |
| 32 $('privacyContentSettingsButton').onclick = function(event) { | |
| 33 OptionsPage.navigateToPage('content'); | |
| 34 OptionsPage.showTab($('cookies-nav-tab')); | |
| 35 chrome.send('coreOptionsUserMetricsAction', | |
| 36 ['Options_ContentSettings']); | |
| 37 }; | |
| 38 $('privacyClearDataButton').onclick = function(event) { | |
| 39 OptionsPage.navigateToPage('clearBrowserData'); | |
| 40 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); | |
| 41 }; | |
| 42 | |
| 43 // 'metricsReportingEnabled' element is only present on Chrome branded | |
| 44 // builds. | |
| 45 if ($('metricsReportingEnabled')) { | |
| 46 $('metricsReportingEnabled').onclick = function(event) { | |
| 47 chrome.send('metricsReportingCheckboxAction', | |
| 48 [String(event.target.checked)]); | |
| 49 }; | |
| 50 } | |
| 51 | |
| 52 if (!cr.isChromeOS) { | |
| 53 $('autoOpenFileTypesResetToDefault').onclick = function(event) { | |
| 54 chrome.send('autoOpenFileTypesAction'); | |
| 55 }; | |
| 56 } | |
| 57 | |
| 58 $('fontSettingsCustomizeFontsButton').onclick = function(event) { | |
| 59 OptionsPage.navigateToPage('fonts'); | |
| 60 chrome.send('coreOptionsUserMetricsAction', ['Options_FontSettings']); | |
| 61 }; | |
| 62 $('defaultFontSize').onchange = function(event) { | |
| 63 chrome.send('defaultFontSizeAction', | |
| 64 [String(event.target.options[event.target.selectedIndex].value)]); | |
| 65 }; | |
| 66 $('language-button').onclick = function(event) { | |
| 67 OptionsPage.navigateToPage('languages'); | |
| 68 chrome.send('coreOptionsUserMetricsAction', | |
| 69 ['Options_LanuageAndSpellCheckSettings']); | |
| 70 }; | |
| 71 | |
| 72 if (cr.isWindows || cr.isMac) { | |
| 73 $('certificatesManageButton').onclick = function(event) { | |
| 74 chrome.send('showManageSSLCertificates'); | |
| 75 }; | |
| 76 } else { | |
| 77 $('certificatesManageButton').onclick = function(event) { | |
| 78 OptionsPage.navigateToPage('certificates'); | |
| 79 OptionsPage.showTab($('personal-certs-nav-tab')); | |
| 80 chrome.send('coreOptionsUserMetricsAction', | |
| 81 ['Options_ManageSSLCertificates']); | |
| 82 }; | |
| 83 } | |
| 84 | |
| 85 if (!cr.isChromeOS) { | |
| 86 $('proxiesConfigureButton').onclick = function(event) { | |
| 87 chrome.send('showNetworkProxySettings'); | |
| 88 }; | |
| 89 $('downloadLocationChangeButton').onclick = function(event) { | |
| 90 chrome.send('selectDownloadLocation'); | |
| 91 }; | |
| 92 $('promptForDownload').onclick = function(event) { | |
| 93 chrome.send('promptForDownloadAction', | |
| 94 [String($('promptForDownload').checked)]); | |
| 95 }; | |
| 96 } else { | |
| 97 $('proxiesConfigureButton').onclick = function(event) { | |
| 98 OptionsPage.navigateToPage('proxy'); | |
| 99 chrome.send('coreOptionsUserMetricsAction', | |
| 100 ['Options_ShowProxySettings']); | |
| 101 }; | |
| 102 } | |
| 103 | |
| 104 $('sslCheckRevocation').onclick = function(event) { | |
| 105 chrome.send('checkRevocationCheckboxAction', | |
| 106 [String($('sslCheckRevocation').checked)]); | |
| 107 }; | |
| 108 $('sslUseSSL3').onclick = function(event) { | |
| 109 chrome.send('useSSL3CheckboxAction', | |
| 110 [String($('sslUseSSL3').checked)]); | |
| 111 }; | |
| 112 $('sslUseTLS1').onclick = function(event) { | |
| 113 chrome.send('useTLS1CheckboxAction', | |
| 114 [String($('sslUseTLS1').checked)]); | |
| 115 }; | |
| 116 | |
| 117 // 'cloudPrintProxyEnabled' is true for Chrome branded builds on | |
| 118 // certain platforms, or could be enabled by a lab. | |
| 119 if (!cr.isChromeOS) { | |
| 120 $('cloudPrintProxySetupButton').onclick = function(event) { | |
| 121 if ($('cloudPrintProxyManageButton').style.display == 'none') { | |
| 122 // Disable the button, set it's text to the intermediate state. | |
| 123 $('cloudPrintProxySetupButton').textContent = | |
| 124 localStrings.getString('cloudPrintProxyEnablingButton'); | |
| 125 $('cloudPrintProxySetupButton').disabled = true; | |
| 126 chrome.send('showCloudPrintSetupDialog'); | |
| 127 } else { | |
| 128 chrome.send('disableCloudPrintProxy'); | |
| 129 } | |
| 130 }; | |
| 131 $('cloudPrintProxyManageButton').onclick = function(event) { | |
| 132 chrome.send('showCloudPrintManagePage'); | |
| 133 }; | |
| 134 } | |
| 135 | |
| 136 } | |
| 137 }; | |
| 138 | |
| 139 // | |
| 140 // Chrome callbacks | |
| 141 // | |
| 142 | |
| 143 // Set the checked state of the metrics reporting checkbox. | |
| 144 AdvancedOptions.SetMetricsReportingCheckboxState = function( | |
| 145 checked, disabled) { | |
| 146 $('metricsReportingEnabled').checked = checked; | |
| 147 $('metricsReportingEnabled').disabled = disabled; | |
| 148 if (disabled) | |
| 149 $('metricsReportingEnabledText').className = 'disable-services-span'; | |
| 150 } | |
| 151 | |
| 152 AdvancedOptions.SetMetricsReportingSettingVisibility = function(visible) { | |
| 153 if (visible) { | |
| 154 $('metricsReportingSetting').style.display = 'block'; | |
| 155 } else { | |
| 156 $('metricsReportingSetting').style.display = 'none'; | |
| 157 } | |
| 158 } | |
| 159 | |
| 160 // Set the font size selected item. | |
| 161 AdvancedOptions.SetFontSize = function(font_size_value) { | |
| 162 var selectCtl = $('defaultFontSize'); | |
| 163 for (var i = 0; i < selectCtl.options.length; i++) { | |
| 164 if (selectCtl.options[i].value == font_size_value) { | |
| 165 selectCtl.selectedIndex = i; | |
| 166 if ($('Custom')) | |
| 167 selectCtl.remove($('Custom').index); | |
| 168 return; | |
| 169 } | |
| 170 } | |
| 171 | |
| 172 // Add/Select Custom Option in the font size label list. | |
| 173 if (!$('Custom')) { | |
| 174 var option = new Option(localStrings.getString('fontSizeLabelCustom'), | |
| 175 -1, false, true); | |
| 176 option.setAttribute("id", "Custom"); | |
| 177 selectCtl.add(option); | |
| 178 } | |
| 179 $('Custom').selected = true; | |
| 180 }; | |
| 181 | |
| 182 // Set the download path. | |
| 183 AdvancedOptions.SetDownloadLocationPath = function(path, disabled) { | |
| 184 if (!cr.isChromeOS) { | |
| 185 $('downloadLocationPath').value = path; | |
| 186 $('downloadLocationChangeButton').disabled = disabled; | |
| 187 } | |
| 188 }; | |
| 189 | |
| 190 // Set the prompt for download checkbox. | |
| 191 AdvancedOptions.SetPromptForDownload = function(checked, disabled) { | |
| 192 if (!cr.isChromeOS) { | |
| 193 $('promptForDownload').checked = checked; | |
| 194 $('promptForDownload').disabled = disabled; | |
| 195 if (disabled) | |
| 196 $('promptForDownloadLabel').className = 'informational-text'; | |
| 197 else | |
| 198 $('promptForDownloadLabel').className = ''; | |
| 199 } | |
| 200 }; | |
| 201 | |
| 202 // Set the enabled state for the autoOpenFileTypesResetToDefault button. | |
| 203 AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute = function(disabled) { | |
| 204 if (!cr.isChromeOS) { | |
| 205 $('autoOpenFileTypesResetToDefault').disabled = disabled; | |
| 206 | |
| 207 if (disabled) | |
| 208 $('auto-open-file-types-label').classList.add('disabled'); | |
| 209 else | |
| 210 $('auto-open-file-types-label').classList.remove('disabled'); | |
| 211 } | |
| 212 }; | |
| 213 | |
| 214 // Set the enabled state for the proxy settings button. | |
| 215 AdvancedOptions.SetupProxySettingsSection = function(disabled, label) { | |
| 216 $('proxiesConfigureButton').disabled = disabled; | |
| 217 $('proxiesLabel').textContent = label; | |
| 218 }; | |
| 219 | |
| 220 // Set the checked state for the sslCheckRevocation checkbox. | |
| 221 AdvancedOptions.SetCheckRevocationCheckboxState = function( | |
| 222 checked, disabled) { | |
| 223 $('sslCheckRevocation').checked = checked; | |
| 224 $('sslCheckRevocation').disabled = disabled; | |
| 225 }; | |
| 226 | |
| 227 // Set the checked state for the sslUseSSL3 checkbox. | |
| 228 AdvancedOptions.SetUseSSL3CheckboxState = function(checked, disabled) { | |
| 229 $('sslUseSSL3').checked = checked; | |
| 230 $('sslUseSSL3').disabled = disabled; | |
| 231 }; | |
| 232 | |
| 233 // Set the checked state for the sslUseTLS1 checkbox. | |
| 234 AdvancedOptions.SetUseTLS1CheckboxState = function(checked, disabled) { | |
| 235 $('sslUseTLS1').checked = checked; | |
| 236 $('sslUseTLS1').disabled = disabled; | |
| 237 }; | |
| 238 | |
| 239 // Set the Cloud Print proxy UI to enabled, disabled, or processing. | |
| 240 AdvancedOptions.SetupCloudPrintProxySection = function( | |
| 241 disabled, label, allowed) { | |
| 242 if (!cr.isChromeOS) { | |
| 243 $('cloudPrintProxyLabel').textContent = label; | |
| 244 if (disabled || !allowed) { | |
| 245 $('cloudPrintProxySetupButton').textContent = | |
| 246 localStrings.getString('cloudPrintProxyDisabledButton'); | |
| 247 $('cloudPrintProxyManageButton').style.display = 'none'; | |
| 248 } else { | |
| 249 $('cloudPrintProxySetupButton').textContent = | |
| 250 localStrings.getString('cloudPrintProxyEnabledButton'); | |
| 251 $('cloudPrintProxyManageButton').style.display = 'inline'; | |
| 252 } | |
| 253 $('cloudPrintProxySetupButton').disabled = !allowed; | |
| 254 } | |
| 255 }; | |
| 256 | |
| 257 AdvancedOptions.RemoveCloudPrintProxySection = function() { | |
| 258 if (!cr.isChromeOS) { | |
| 259 var proxySectionElm = $('cloud-print-proxy-section'); | |
| 260 if (proxySectionElm) | |
| 261 proxySectionElm.parentNode.removeChild(proxySectionElm); | |
| 262 } | |
| 263 }; | |
| 264 | |
| 265 // Export | |
| 266 return { | |
| 267 AdvancedOptions: AdvancedOptions | |
| 268 }; | |
| 269 | |
| 270 }); | |
| OLD | NEW |