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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 PageManager.showPageByName('content'); | 443 PageManager.showPageByName('content'); |
444 OptionsPage.showTab($('cookies-nav-tab')); | 444 OptionsPage.showTab($('cookies-nav-tab')); |
445 chrome.send('coreOptionsUserMetricsAction', | 445 chrome.send('coreOptionsUserMetricsAction', |
446 ['Options_ContentSettings']); | 446 ['Options_ContentSettings']); |
447 }; | 447 }; |
448 $('privacyClearDataButton').onclick = function(event) { | 448 $('privacyClearDataButton').onclick = function(event) { |
449 PageManager.showPageByName('clearBrowserData'); | 449 PageManager.showPageByName('clearBrowserData'); |
450 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); | 450 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); |
451 }; | 451 }; |
452 $('privacyClearDataButton').hidden = OptionsPage.isSettingsApp(); | 452 $('privacyClearDataButton').hidden = OptionsPage.isSettingsApp(); |
453 // 'metricsReportingEnabled' element is only present on Chrome branded | 453 |
454 // builds, and the 'metricsReportingCheckboxAction' message is only | 454 if ($('metrics-reporting-enabled')) { |
455 // handled on ChromeOS. | 455 $('metrics-reporting-enabled').checked = |
456 if ($('metrics-reporting-enabled') && cr.isChromeOS) { | 456 loadTimeData.getBoolean('metricsReportingEnabledAtStart'); |
457 $('metrics-reporting-enabled').onclick = function(event) { | 457 |
458 chrome.send('metricsReportingCheckboxAction', | 458 // A browser restart is never needed to toggle metrics reporting, |
459 [String(event.currentTarget.checked)]); | 459 // and is only needed to toggle crash reporting when using Breakpad. |
460 }; | 460 // Crashpad, used on Mac, does not require a browser restart. |
461 } | 461 var togglingMetricsRequiresRestart = !cr.isMac && !cr.isChromeOS; |
462 if ($('metrics-reporting-enabled') && !cr.isChromeOS) { | |
463 // The localized string has the | symbol on each side of the text that | |
464 // needs to be made into a button to restart Chrome. We parse the text | |
465 // and build the button from that. | |
466 var restartTextFragments = | |
467 loadTimeData.getString('metricsReportingResetRestart').split('|'); | |
468 // Assume structure is something like "starting text |link text| ending | |
469 // text" where both starting text and ending text may or may not be | |
470 // present, but the split should always be in three pieces. | |
471 var restartElements = | |
472 $('metrics-reporting-reset-restart').querySelectorAll('*'); | |
473 for (var i = 0; i < restartTextFragments.length; i++) { | |
474 restartElements[i].textContent = restartTextFragments[i]; | |
475 } | |
476 restartElements[1].onclick = function(event) { | |
477 chrome.send('restartBrowser'); | |
478 }; | |
479 $('metrics-reporting-enabled').onclick = function(event) { | 462 $('metrics-reporting-enabled').onclick = function(event) { |
480 chrome.send('metricsReportingCheckboxChanged', | 463 chrome.send('metricsReportingCheckboxChanged', |
481 [Boolean(event.currentTarget.checked)]); | 464 [Boolean(event.currentTarget.checked)]); |
482 if (cr.isMac) { | 465 if (cr.isChromeOS) { |
483 // A browser restart is never needed to toggle metrics reporting, | 466 // 'metricsReportingEnabled' element is only present on Chrome |
484 // and is only needed to toggle crash reporting when using Breakpad. | 467 // branded builds, and the 'metricsReportingCheckboxAction' message |
485 // Crashpad, used on Mac, does not require a browser restart. | 468 // is only handled on ChromeOS. |
486 return; | 469 chrome.send('metricsReportingCheckboxAction', |
| 470 [String(event.currentTarget.checked)]); |
487 } | 471 } |
488 $('metrics-reporting-reset-restart').hidden = | 472 |
489 loadTimeData.getBoolean('metricsReportingEnabledAtStart') == | 473 if (togglingMetricsRequiresRestart) { |
490 $('metrics-reporting-enabled').checked; | 474 $('metrics-reporting-reset-restart').hidden = |
| 475 loadTimeData.getBoolean('metricsReportingEnabledAtStart') == |
| 476 $('metrics-reporting-enabled').checked; |
| 477 } |
| 478 |
491 }; | 479 }; |
492 $('metrics-reporting-enabled').checked = | 480 |
493 loadTimeData.getBoolean('metricsReportingEnabledAtStart'); | 481 // Initialize restart button if needed. |
| 482 if (togglingMetricsRequiresRestart) { |
| 483 // The localized string has the | symbol on each side of the text that |
| 484 // needs to be made into a button to restart Chrome. We parse the text |
| 485 // and build the button from that. |
| 486 var restartTextFragments = |
| 487 loadTimeData.getString('metricsReportingResetRestart').split('|'); |
| 488 // Assume structure is something like "starting text |link text| |
| 489 // ending text" where both starting text and ending text may or may |
| 490 // not be present, but the split should always be in three pieces. |
| 491 var restartElements = |
| 492 $('metrics-reporting-reset-restart').querySelectorAll('*'); |
| 493 for (var i = 0; i < restartTextFragments.length; i++) { |
| 494 restartElements[i].textContent = restartTextFragments[i]; |
| 495 } |
| 496 restartElements[1].onclick = function(event) { |
| 497 chrome.send('restartBrowser'); |
| 498 }; |
| 499 } |
494 } | 500 } |
495 $('networkPredictionOptions').onchange = function(event) { | 501 $('networkPredictionOptions').onchange = function(event) { |
496 var value = (event.target.checked ? | 502 var value = (event.target.checked ? |
497 NetworkPredictionOptions.WIFI_ONLY : | 503 NetworkPredictionOptions.WIFI_ONLY : |
498 NetworkPredictionOptions.NEVER); | 504 NetworkPredictionOptions.NEVER); |
499 var metric = event.target.metric; | 505 var metric = event.target.metric; |
500 Preferences.setIntegerPref( | 506 Preferences.setIntegerPref( |
501 'net.network_prediction_options', | 507 'net.network_prediction_options', |
502 value, | 508 value, |
503 true, | 509 true, |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 * @private | 1729 * @private |
1724 */ | 1730 */ |
1725 enableFactoryResetSection_: function() { | 1731 enableFactoryResetSection_: function() { |
1726 $('factory-reset-section').hidden = false; | 1732 $('factory-reset-section').hidden = false; |
1727 }, | 1733 }, |
1728 | 1734 |
1729 /** | 1735 /** |
1730 * Set the checked state of the metrics reporting checkbox. | 1736 * Set the checked state of the metrics reporting checkbox. |
1731 * @private | 1737 * @private |
1732 */ | 1738 */ |
1733 setMetricsReportingCheckboxState_: function(checked, disabled) { | 1739 setMetricsReportingCheckboxState_: function(checked, |
| 1740 policyManaged, |
| 1741 ownerManaged) { |
1734 $('metrics-reporting-enabled').checked = checked; | 1742 $('metrics-reporting-enabled').checked = checked; |
1735 $('metrics-reporting-enabled').disabled = disabled; | 1743 $('metrics-reporting-enabled').disabled = policyManaged || ownerManaged; |
1736 | 1744 |
1737 // If checkbox gets disabled then add an attribute for displaying the | 1745 // If checkbox gets disabled then add an attribute for displaying the |
1738 // special icon. Otherwise remove the indicator attribute. | 1746 // special icon. Otherwise remove the indicator attribute. |
1739 if (disabled) { | 1747 if (policyManaged) { |
1740 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', | 1748 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', |
1741 'policy'); | 1749 'policy'); |
| 1750 } else if (ownerManaged) { |
| 1751 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', |
| 1752 'owner'); |
1742 } else { | 1753 } else { |
1743 $('metrics-reporting-disabled-icon').removeAttribute('controlled-by'); | 1754 $('metrics-reporting-disabled-icon').removeAttribute('controlled-by'); |
1744 } | 1755 } |
| 1756 |
1745 }, | 1757 }, |
1746 | 1758 |
1747 /** | 1759 /** |
1748 * @private | 1760 * @private |
1749 */ | 1761 */ |
1750 setMetricsReportingSettingVisibility_: function(visible) { | 1762 setMetricsReportingSettingVisibility_: function(visible) { |
1751 if (visible) | 1763 if (visible) |
1752 $('metrics-reporting-setting').style.display = 'block'; | 1764 $('metrics-reporting-setting').style.display = 'block'; |
1753 else | 1765 else |
1754 $('metrics-reporting-setting').style.display = 'none'; | 1766 $('metrics-reporting-setting').style.display = 'none'; |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2250 } | 2262 } |
2251 button.textContent = loadTimeData.getString(strId); | 2263 button.textContent = loadTimeData.getString(strId); |
2252 }; | 2264 }; |
2253 } | 2265 } |
2254 | 2266 |
2255 // Export | 2267 // Export |
2256 return { | 2268 return { |
2257 BrowserOptions: BrowserOptions | 2269 BrowserOptions: BrowserOptions |
2258 }; | 2270 }; |
2259 }); | 2271 }); |
OLD | NEW |