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', | |
461 [String(event.currentTarget.checked)]); | |
462 }; | |
463 } | |
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) { | 460 $('metrics-reporting-enabled').onclick = function(event) { |
482 chrome.send('metricsReportingCheckboxChanged', | 461 chrome.send('metricsReportingCheckboxChanged', |
483 [Boolean(event.currentTarget.checked)]); | 462 [Boolean(event.currentTarget.checked)]); |
484 if (cr.isMac) { | 463 if (cr.isChromeOS) { |
464 // 'metricsReportingEnabled' element is only present on Chrome | |
465 // branded builds, and the 'metricsReportingCheckboxAction' message | |
466 // is only handled on ChromeOS. | |
467 chrome.send('metricsReportingCheckboxAction', | |
468 [String(event.currentTarget.checked)]); | |
469 } else if (!cr.isMac) { | |
485 // A browser restart is never needed to toggle metrics reporting, | 470 // A browser restart is never needed to toggle metrics reporting, |
486 // and is only needed to toggle crash reporting when using Breakpad. | 471 // and is only needed to toggle crash reporting when using Breakpad. |
487 // Crashpad, used on Mac, does not require a browser restart. | 472 // Crashpad, used on Mac, does not require a browser restart. |
488 return; | 473 $('metrics-reporting-reset-restart').hidden = |
474 loadTimeData.getBoolean('metricsReportingEnabledAtStart') == | |
475 $('metrics-reporting-enabled').checked; | |
489 } | 476 } |
490 $('metrics-reporting-reset-restart').hidden = | 477 |
491 loadTimeData.getBoolean('metricsReportingEnabledAtStart') == | |
492 $('metrics-reporting-enabled').checked; | |
493 }; | 478 }; |
494 $('metrics-reporting-enabled').checked = | 479 |
495 loadTimeData.getBoolean('metricsReportingEnabledAtStart'); | 480 // Don't need to initialize restart button for ChromeOS or Mac. |
481 if (!cr.isChromeOS && !cr.isMac) { | |
Alexei Svitkine (slow)
2015/10/29 17:04:14
Instead of duplicating these checks with the ones
gayane -on leave until 09-2017
2015/11/02 19:23:52
Done.
| |
482 // The localized string has the | symbol on each side of the text that | |
483 // needs to be made into a button to restart Chrome. We parse the text | |
484 // and build the button from that. | |
485 var restartTextFragments = | |
486 loadTimeData.getString('metricsReportingResetRestart').split('|'); | |
487 // Assume structure is something like "starting text |link text| | |
488 // ending text" where both starting text and ending text may or may | |
489 // not be present, but the split should always be in three pieces. | |
490 var restartElements = | |
491 $('metrics-reporting-reset-restart').querySelectorAll('*'); | |
492 for (var i = 0; i < restartTextFragments.length; i++) { | |
493 restartElements[i].textContent = restartTextFragments[i]; | |
494 } | |
495 restartElements[1].onclick = function(event) { | |
496 chrome.send('restartBrowser'); | |
497 }; | |
498 } | |
496 } | 499 } |
497 $('networkPredictionOptions').onchange = function(event) { | 500 $('networkPredictionOptions').onchange = function(event) { |
498 var value = (event.target.checked ? | 501 var value = (event.target.checked ? |
499 NetworkPredictionOptions.WIFI_ONLY : | 502 NetworkPredictionOptions.WIFI_ONLY : |
500 NetworkPredictionOptions.NEVER); | 503 NetworkPredictionOptions.NEVER); |
501 var metric = event.target.metric; | 504 var metric = event.target.metric; |
502 Preferences.setIntegerPref( | 505 Preferences.setIntegerPref( |
503 'net.network_prediction_options', | 506 'net.network_prediction_options', |
504 value, | 507 value, |
505 true, | 508 true, |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1739 * @private | 1742 * @private |
1740 */ | 1743 */ |
1741 enableFactoryResetSection_: function() { | 1744 enableFactoryResetSection_: function() { |
1742 $('factory-reset-section').hidden = false; | 1745 $('factory-reset-section').hidden = false; |
1743 }, | 1746 }, |
1744 | 1747 |
1745 /** | 1748 /** |
1746 * Set the checked state of the metrics reporting checkbox. | 1749 * Set the checked state of the metrics reporting checkbox. |
1747 * @private | 1750 * @private |
1748 */ | 1751 */ |
1749 setMetricsReportingCheckboxState_: function(checked, disabled) { | 1752 setMetricsReportingCheckboxState_: function(checked, |
1753 policy_managed, | |
1754 owner_managed) { | |
1750 $('metrics-reporting-enabled').checked = checked; | 1755 $('metrics-reporting-enabled').checked = checked; |
1751 $('metrics-reporting-enabled').disabled = disabled; | 1756 $('metrics-reporting-enabled').disabled = policy_managed || owner_managed; |
1752 | 1757 |
1753 // If checkbox gets disabled then add an attribute for displaying the | 1758 // If checkbox gets disabled then add an attribute for displaying the |
1754 // special icon. Otherwise remove the indicator attribute. | 1759 // special icon. Otherwise remove the indicator attribute. |
1755 if (disabled) { | 1760 if (policy_managed) { |
1756 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', | 1761 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', |
1757 'policy'); | 1762 'policy'); |
1763 } else if (owner_managed) { | |
1764 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', | |
1765 'owner'); | |
1758 } else { | 1766 } else { |
1759 $('metrics-reporting-disabled-icon').removeAttribute('controlled-by'); | 1767 $('metrics-reporting-disabled-icon').removeAttribute('controlled-by'); |
1760 } | 1768 } |
1769 | |
1761 }, | 1770 }, |
1762 | 1771 |
1763 /** | 1772 /** |
1764 * @private | 1773 * @private |
1765 */ | 1774 */ |
1766 setMetricsReportingSettingVisibility_: function(visible) { | 1775 setMetricsReportingSettingVisibility_: function(visible) { |
1767 if (visible) | 1776 if (visible) |
1768 $('metrics-reporting-setting').style.display = 'block'; | 1777 $('metrics-reporting-setting').style.display = 'block'; |
1769 else | 1778 else |
1770 $('metrics-reporting-setting').style.display = 'none'; | 1779 $('metrics-reporting-setting').style.display = 'none'; |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2267 } | 2276 } |
2268 button.textContent = loadTimeData.getString(strId); | 2277 button.textContent = loadTimeData.getString(strId); |
2269 }; | 2278 }; |
2270 } | 2279 } |
2271 | 2280 |
2272 // Export | 2281 // Export |
2273 return { | 2282 return { |
2274 BrowserOptions: BrowserOptions | 2283 BrowserOptions: BrowserOptions |
2275 }; | 2284 }; |
2276 }); | 2285 }); |
OLD | NEW |