| 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.exportPath('options'); | 5 cr.exportPath('options'); |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @typedef {{actionLinkText: (string|undefined), | 8 * @typedef {{actionLinkText: (string|undefined), |
| 9 * childUser: (boolean|undefined), | 9 * childUser: (boolean|undefined), |
| 10 * hasError: (boolean|undefined), | 10 * hasError: (boolean|undefined), |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 ['Options_ContentSettings']); | 428 ['Options_ContentSettings']); |
| 429 }; | 429 }; |
| 430 $('privacyClearDataButton').onclick = function(event) { | 430 $('privacyClearDataButton').onclick = function(event) { |
| 431 PageManager.showPageByName('clearBrowserData'); | 431 PageManager.showPageByName('clearBrowserData'); |
| 432 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); | 432 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); |
| 433 }; | 433 }; |
| 434 $('privacyClearDataButton').hidden = OptionsPage.isSettingsApp(); | 434 $('privacyClearDataButton').hidden = OptionsPage.isSettingsApp(); |
| 435 // 'metricsReportingEnabled' element is only present on Chrome branded | 435 // 'metricsReportingEnabled' element is only present on Chrome branded |
| 436 // builds, and the 'metricsReportingCheckboxAction' message is only | 436 // builds, and the 'metricsReportingCheckboxAction' message is only |
| 437 // handled on ChromeOS. | 437 // handled on ChromeOS. |
| 438 if ($('metricsReportingEnabled') && cr.isChromeOS) { | 438 if ($('metrics-reporting-enabled') && cr.isChromeOS) { |
| 439 $('metricsReportingEnabled').onclick = function(event) { | 439 $('metrics-reporting-enabled').onclick = function(event) { |
| 440 chrome.send('metricsReportingCheckboxAction', | 440 chrome.send('metricsReportingCheckboxAction', |
| 441 [String(event.currentTarget.checked)]); | 441 [String(event.currentTarget.checked)]); |
| 442 }; | 442 }; |
| 443 } | 443 } |
| 444 if ($('metricsReportingEnabled') && !cr.isChromeOS) { | 444 if ($('metrics-reporting-enabled') && !cr.isChromeOS) { |
| 445 // The localized string has the | symbol on each side of the text that | 445 // The localized string has the | symbol on each side of the text that |
| 446 // needs to be made into a button to restart Chrome. We parse the text | 446 // needs to be made into a button to restart Chrome. We parse the text |
| 447 // and build the button from that. | 447 // and build the button from that. |
| 448 var restartTextFragments = | 448 var restartTextFragments = |
| 449 loadTimeData.getString('metricsReportingResetRestart').split('|'); | 449 loadTimeData.getString('metricsReportingResetRestart').split('|'); |
| 450 // Assume structure is something like "starting text |link text| ending | 450 // Assume structure is something like "starting text |link text| ending |
| 451 // text" where both starting text and ending text may or may not be | 451 // text" where both starting text and ending text may or may not be |
| 452 // present, but the split should always be in three pieces. | 452 // present, but the split should always be in three pieces. |
| 453 var restartElements = | 453 var restartElements = |
| 454 $('metrics-reporting-reset-restart').querySelectorAll('*'); | 454 $('metrics-reporting-reset-restart').querySelectorAll('*'); |
| 455 for (var i = 0; i < restartTextFragments.length; i++) { | 455 for (var i = 0; i < restartTextFragments.length; i++) { |
| 456 restartElements[i].textContent = restartTextFragments[i]; | 456 restartElements[i].textContent = restartTextFragments[i]; |
| 457 } | 457 } |
| 458 restartElements[1].onclick = function(event) { | 458 restartElements[1].onclick = function(event) { |
| 459 chrome.send('restartBrowser'); | 459 chrome.send('restartBrowser'); |
| 460 }; | 460 }; |
| 461 // Attach the listener for updating the checkbox and restart button. | 461 // Attach the listener for updating the checkbox and restart button. |
| 462 var updateMetricsRestartButton = function() { | 462 var updateMetricsRestartButton = function() { |
| 463 $('metrics-reporting-reset-restart').hidden = | 463 $('metrics-reporting-reset-restart').hidden = |
| 464 loadTimeData.getBoolean('metricsReportingEnabledAtStart') == | 464 loadTimeData.getBoolean('metricsReportingEnabledAtStart') == |
| 465 $('metricsReportingEnabled').checked; | 465 $('metrics-reporting-enabled').checked; |
| 466 }; | 466 }; |
| 467 $('metricsReportingEnabled').onclick = function(event) { | 467 $('metrics-reporting-enabled').onclick = function(event) { |
| 468 chrome.send('metricsReportingCheckboxChanged', | 468 chrome.send('metricsReportingCheckboxChanged', |
| 469 [Boolean(event.currentTarget.checked)]); | 469 [Boolean(event.currentTarget.checked)]); |
| 470 updateMetricsRestartButton(); | 470 updateMetricsRestartButton(); |
| 471 }; | 471 }; |
| 472 $('metricsReportingEnabled').checked = | 472 $('metrics-reporting-enabled').checked = |
| 473 loadTimeData.getBoolean('metricsReportingEnabledAtStart'); | 473 loadTimeData.getBoolean('metricsReportingEnabledAtStart'); |
| 474 updateMetricsRestartButton(); | 474 updateMetricsRestartButton(); |
| 475 } | 475 } |
| 476 // 'rapporDiv' element is only present on Chrome branded builds. | 476 // 'rappor-setting' element is only present on Chrome branded builds. |
| 477 if ($('rapporDiv')) { | 477 if ($('rappor-setting')) { |
| 478 $('rapporDiv').hidden = !loadTimeData.getBoolean('hasRapporOption'); | 478 $('rappor-setting').hidden = |
| 479 !loadTimeData.getBoolean('hasRapporOption'); |
| 479 } | 480 } |
| 480 $('networkPredictionOptions').onchange = function(event) { | 481 $('networkPredictionOptions').onchange = function(event) { |
| 481 var value = (event.target.checked ? | 482 var value = (event.target.checked ? |
| 482 NetworkPredictionOptions.WIFI_ONLY : | 483 NetworkPredictionOptions.WIFI_ONLY : |
| 483 NetworkPredictionOptions.NEVER); | 484 NetworkPredictionOptions.NEVER); |
| 484 var metric = event.target.metric; | 485 var metric = event.target.metric; |
| 485 Preferences.setIntegerPref( | 486 Preferences.setIntegerPref( |
| 486 'net.network_prediction_options', | 487 'net.network_prediction_options', |
| 487 value, | 488 value, |
| 488 true, | 489 true, |
| (...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 */ | 1696 */ |
| 1696 enableFactoryResetSection_: function() { | 1697 enableFactoryResetSection_: function() { |
| 1697 $('factory-reset-section').hidden = false; | 1698 $('factory-reset-section').hidden = false; |
| 1698 }, | 1699 }, |
| 1699 | 1700 |
| 1700 /** | 1701 /** |
| 1701 * Set the checked state of the metrics reporting checkbox. | 1702 * Set the checked state of the metrics reporting checkbox. |
| 1702 * @private | 1703 * @private |
| 1703 */ | 1704 */ |
| 1704 setMetricsReportingCheckboxState_: function(checked, disabled) { | 1705 setMetricsReportingCheckboxState_: function(checked, disabled) { |
| 1705 $('metricsReportingEnabled').checked = checked; | 1706 $('metrics-reporting-enabled').checked = checked; |
| 1706 $('metricsReportingEnabled').disabled = disabled; | 1707 $('metrics-reporting-enabled').disabled = disabled; |
| 1707 | 1708 |
| 1708 // If checkbox gets disabled then add an attribute for displaying the | 1709 // If checkbox gets disabled then add an attribute for displaying the |
| 1709 // special icon. Otherwise remove the indicator attribute. | 1710 // special icon. Otherwise remove the indicator attribute. |
| 1710 if (disabled) { | 1711 if (disabled) { |
| 1711 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', | 1712 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', |
| 1712 'policy'); | 1713 'policy'); |
| 1713 } else { | 1714 } else { |
| 1714 $('metrics-reporting-disabled-icon').removeAttribute('controlled-by'); | 1715 $('metrics-reporting-disabled-icon').removeAttribute('controlled-by'); |
| 1715 } | 1716 } |
| 1716 }, | 1717 }, |
| 1717 | 1718 |
| 1718 /** | 1719 /** |
| 1719 * @private | 1720 * @private |
| 1720 */ | 1721 */ |
| 1721 setMetricsReportingSettingVisibility_: function(visible) { | 1722 setMetricsReportingSettingVisibility_: function(visible) { |
| 1722 if (visible) | 1723 if (visible) |
| 1723 $('metricsReportingSetting').style.display = 'block'; | 1724 $('metrics-reporting-setting').style.display = 'block'; |
| 1724 else | 1725 else |
| 1725 $('metricsReportingSetting').style.display = 'none'; | 1726 $('metrics-reporting-setting').style.display = 'none'; |
| 1726 }, | 1727 }, |
| 1727 | 1728 |
| 1728 /** | 1729 /** |
| 1729 * Set network prediction checkbox value. | 1730 * Set network prediction checkbox value. |
| 1730 * | 1731 * |
| 1731 * @param {{value: number, disabled: boolean}} pref Information about | 1732 * @param {{value: number, disabled: boolean}} pref Information about |
| 1732 * network prediction options. |pref.value| is the value of network | 1733 * network prediction options. |pref.value| is the value of network |
| 1733 * prediction options. |pref.disabled| shows if the pref is not user | 1734 * prediction options. |pref.disabled| shows if the pref is not user |
| 1734 * modifiable. | 1735 * modifiable. |
| 1735 * @private | 1736 * @private |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2251 } | 2252 } |
| 2252 button.textContent = loadTimeData.getString(strId); | 2253 button.textContent = loadTimeData.getString(strId); |
| 2253 }; | 2254 }; |
| 2254 } | 2255 } |
| 2255 | 2256 |
| 2256 // Export | 2257 // Export |
| 2257 return { | 2258 return { |
| 2258 BrowserOptions: BrowserOptions | 2259 BrowserOptions: BrowserOptions |
| 2259 }; | 2260 }; |
| 2260 }); | 2261 }); |
| OLD | NEW |