| 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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 PageManager.showPageByName('content'); | 445 PageManager.showPageByName('content'); |
| 446 OptionsPage.showTab($('cookies-nav-tab')); | 446 OptionsPage.showTab($('cookies-nav-tab')); |
| 447 chrome.send('coreOptionsUserMetricsAction', | 447 chrome.send('coreOptionsUserMetricsAction', |
| 448 ['Options_ContentSettings']); | 448 ['Options_ContentSettings']); |
| 449 }; | 449 }; |
| 450 $('privacyClearDataButton').onclick = function(event) { | 450 $('privacyClearDataButton').onclick = function(event) { |
| 451 PageManager.showPageByName('clearBrowserData'); | 451 PageManager.showPageByName('clearBrowserData'); |
| 452 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); | 452 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); |
| 453 }; | 453 }; |
| 454 $('privacyClearDataButton').hidden = OptionsPage.isSettingsApp(); | 454 $('privacyClearDataButton').hidden = OptionsPage.isSettingsApp(); |
| 455 // 'metricsReportingEnabled' element is only present on Chrome branded | 455 |
| 456 // builds, and the 'metricsReportingCheckboxAction' message is only | 456 if ($('metrics-reporting-enabled')) { |
| 457 // handled on ChromeOS. | 457 $('metrics-reporting-enabled').checked = |
| 458 if ($('metrics-reporting-enabled') && cr.isChromeOS) { | 458 loadTimeData.getBoolean('metricsReportingEnabledAtStart'); |
| 459 $('metrics-reporting-enabled').onclick = function(event) { | 459 |
| 460 chrome.send('metricsReportingCheckboxAction', | 460 // A browser restart is never needed to toggle metrics reporting, |
| 461 [String(event.currentTarget.checked)]); | 461 // and is only needed to toggle crash reporting when using Breakpad. |
| 462 }; | 462 // Crashpad, used on Mac, does not require a browser restart. |
| 463 } | 463 var togglingMetricsRequiresRestart = !cr.isMac && !cr.isChromeOS; |
| 464 if ($('metrics-reporting-enabled') && !cr.isChromeOS) { | |
| 465 // The localized string has the | symbol on each side of the text that | |
| 466 // needs to be made into a button to restart Chrome. We parse the text | |
| 467 // and build the button from that. | |
| 468 var restartTextFragments = | |
| 469 loadTimeData.getString('metricsReportingResetRestart').split('|'); | |
| 470 // Assume structure is something like "starting text |link text| ending | |
| 471 // text" where both starting text and ending text may or may not be | |
| 472 // present, but the split should always be in three pieces. | |
| 473 var restartElements = | |
| 474 $('metrics-reporting-reset-restart').querySelectorAll('*'); | |
| 475 for (var i = 0; i < restartTextFragments.length; i++) { | |
| 476 restartElements[i].textContent = restartTextFragments[i]; | |
| 477 } | |
| 478 restartElements[1].onclick = function(event) { | |
| 479 chrome.send('restartBrowser'); | |
| 480 }; | |
| 481 $('metrics-reporting-enabled').onclick = function(event) { | 464 $('metrics-reporting-enabled').onclick = function(event) { |
| 482 chrome.send('metricsReportingCheckboxChanged', | 465 chrome.send('metricsReportingCheckboxChanged', |
| 483 [Boolean(event.currentTarget.checked)]); | 466 [Boolean(event.currentTarget.checked)]); |
| 484 if (cr.isMac) { | 467 if (cr.isChromeOS) { |
| 485 // A browser restart is never needed to toggle metrics reporting, | 468 // 'metricsReportingEnabled' element is only present on Chrome |
| 486 // and is only needed to toggle crash reporting when using Breakpad. | 469 // branded builds, and the 'metricsReportingCheckboxAction' message |
| 487 // Crashpad, used on Mac, does not require a browser restart. | 470 // is only handled on ChromeOS. |
| 488 return; | 471 chrome.send('metricsReportingCheckboxAction', |
| 472 [String(event.currentTarget.checked)]); |
| 489 } | 473 } |
| 490 $('metrics-reporting-reset-restart').hidden = | 474 |
| 491 loadTimeData.getBoolean('metricsReportingEnabledAtStart') == | 475 if (togglingMetricsRequiresRestart) { |
| 492 $('metrics-reporting-enabled').checked; | 476 $('metrics-reporting-reset-restart').hidden = |
| 477 loadTimeData.getBoolean('metricsReportingEnabledAtStart') == |
| 478 $('metrics-reporting-enabled').checked; |
| 479 } |
| 480 |
| 493 }; | 481 }; |
| 494 $('metrics-reporting-enabled').checked = | 482 |
| 495 loadTimeData.getBoolean('metricsReportingEnabledAtStart'); | 483 // Initialize restart button if needed. |
| 484 if (togglingMetricsRequiresRestart) { |
| 485 // The localized string has the | symbol on each side of the text that |
| 486 // needs to be made into a button to restart Chrome. We parse the text |
| 487 // and build the button from that. |
| 488 var restartTextFragments = |
| 489 loadTimeData.getString('metricsReportingResetRestart').split('|'); |
| 490 // Assume structure is something like "starting text |link text| |
| 491 // ending text" where both starting text and ending text may or may |
| 492 // not be present, but the split should always be in three pieces. |
| 493 var restartElements = |
| 494 $('metrics-reporting-reset-restart').querySelectorAll('*'); |
| 495 for (var i = 0; i < restartTextFragments.length; i++) { |
| 496 restartElements[i].textContent = restartTextFragments[i]; |
| 497 } |
| 498 restartElements[1].onclick = function(event) { |
| 499 chrome.send('restartBrowser'); |
| 500 }; |
| 501 } |
| 496 } | 502 } |
| 497 $('networkPredictionOptions').onchange = function(event) { | 503 $('networkPredictionOptions').onchange = function(event) { |
| 498 var value = (event.target.checked ? | 504 var value = (event.target.checked ? |
| 499 NetworkPredictionOptions.WIFI_ONLY : | 505 NetworkPredictionOptions.WIFI_ONLY : |
| 500 NetworkPredictionOptions.NEVER); | 506 NetworkPredictionOptions.NEVER); |
| 501 var metric = event.target.metric; | 507 var metric = event.target.metric; |
| 502 Preferences.setIntegerPref( | 508 Preferences.setIntegerPref( |
| 503 'net.network_prediction_options', | 509 'net.network_prediction_options', |
| 504 value, | 510 value, |
| 505 true, | 511 true, |
| (...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1743 * @private | 1749 * @private |
| 1744 */ | 1750 */ |
| 1745 enableFactoryResetSection_: function() { | 1751 enableFactoryResetSection_: function() { |
| 1746 $('factory-reset-section').hidden = false; | 1752 $('factory-reset-section').hidden = false; |
| 1747 }, | 1753 }, |
| 1748 | 1754 |
| 1749 /** | 1755 /** |
| 1750 * Set the checked state of the metrics reporting checkbox. | 1756 * Set the checked state of the metrics reporting checkbox. |
| 1751 * @private | 1757 * @private |
| 1752 */ | 1758 */ |
| 1753 setMetricsReportingCheckboxState_: function(checked, disabled) { | 1759 setMetricsReportingCheckboxState_: function(checked, |
| 1760 policyManaged, |
| 1761 ownerManaged) { |
| 1754 $('metrics-reporting-enabled').checked = checked; | 1762 $('metrics-reporting-enabled').checked = checked; |
| 1755 $('metrics-reporting-enabled').disabled = disabled; | 1763 $('metrics-reporting-enabled').disabled = policyManaged || ownerManaged; |
| 1756 | 1764 |
| 1757 // If checkbox gets disabled then add an attribute for displaying the | 1765 // If checkbox gets disabled then add an attribute for displaying the |
| 1758 // special icon. Otherwise remove the indicator attribute. | 1766 // special icon. Otherwise remove the indicator attribute. |
| 1759 if (disabled) { | 1767 if (policyManaged) { |
| 1760 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', | 1768 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', |
| 1761 'policy'); | 1769 'policy'); |
| 1770 } else if (ownerManaged) { |
| 1771 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', |
| 1772 'owner'); |
| 1762 } else { | 1773 } else { |
| 1763 $('metrics-reporting-disabled-icon').removeAttribute('controlled-by'); | 1774 $('metrics-reporting-disabled-icon').removeAttribute('controlled-by'); |
| 1764 } | 1775 } |
| 1776 |
| 1765 }, | 1777 }, |
| 1766 | 1778 |
| 1767 /** | 1779 /** |
| 1768 * @private | 1780 * @private |
| 1769 */ | 1781 */ |
| 1770 setMetricsReportingSettingVisibility_: function(visible) { | 1782 setMetricsReportingSettingVisibility_: function(visible) { |
| 1771 if (visible) | 1783 if (visible) |
| 1772 $('metrics-reporting-setting').style.display = 'block'; | 1784 $('metrics-reporting-setting').style.display = 'block'; |
| 1773 else | 1785 else |
| 1774 $('metrics-reporting-setting').style.display = 'none'; | 1786 $('metrics-reporting-setting').style.display = 'none'; |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2271 } | 2283 } |
| 2272 button.textContent = loadTimeData.getString(strId); | 2284 button.textContent = loadTimeData.getString(strId); |
| 2273 }; | 2285 }; |
| 2274 } | 2286 } |
| 2275 | 2287 |
| 2276 // Export | 2288 // Export |
| 2277 return { | 2289 return { |
| 2278 BrowserOptions: BrowserOptions | 2290 BrowserOptions: BrowserOptions |
| 2279 }; | 2291 }; |
| 2280 }); | 2292 }); |
| OLD | NEW |