Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: chrome/browser/resources/options/browser_options.js

Issue 1411863002: Use kMetricsReportingEnabled instead of kStatsReporingPref on metrics side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add observer for kStatsReportingPref Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 * @private 1745 * @private
1740 */ 1746 */
1741 enableFactoryResetSection_: function() { 1747 enableFactoryResetSection_: function() {
1742 $('factory-reset-section').hidden = false; 1748 $('factory-reset-section').hidden = false;
1743 }, 1749 },
1744 1750
1745 /** 1751 /**
1746 * Set the checked state of the metrics reporting checkbox. 1752 * Set the checked state of the metrics reporting checkbox.
1747 * @private 1753 * @private
1748 */ 1754 */
1749 setMetricsReportingCheckboxState_: function(checked, disabled) { 1755 setMetricsReportingCheckboxState_: function(checked,
1756 policy_managed,
Alexei Svitkine (slow) 2015/11/02 21:50:33 Nit: camelCase for js vars
gayane -on leave until 09-2017 2015/11/03 19:46:17 Done.
1757 owner_managed) {
1750 $('metrics-reporting-enabled').checked = checked; 1758 $('metrics-reporting-enabled').checked = checked;
1751 $('metrics-reporting-enabled').disabled = disabled; 1759 $('metrics-reporting-enabled').disabled = policy_managed || owner_managed;
1752 1760
1753 // If checkbox gets disabled then add an attribute for displaying the 1761 // If checkbox gets disabled then add an attribute for displaying the
1754 // special icon. Otherwise remove the indicator attribute. 1762 // special icon. Otherwise remove the indicator attribute.
1755 if (disabled) { 1763 if (policy_managed) {
1756 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', 1764 $('metrics-reporting-disabled-icon').setAttribute('controlled-by',
1757 'policy'); 1765 'policy');
1766 } else if (owner_managed) {
1767 $('metrics-reporting-disabled-icon').setAttribute('controlled-by',
1768 'owner');
1758 } else { 1769 } else {
1759 $('metrics-reporting-disabled-icon').removeAttribute('controlled-by'); 1770 $('metrics-reporting-disabled-icon').removeAttribute('controlled-by');
1760 } 1771 }
1772
1761 }, 1773 },
1762 1774
1763 /** 1775 /**
1764 * @private 1776 * @private
1765 */ 1777 */
1766 setMetricsReportingSettingVisibility_: function(visible) { 1778 setMetricsReportingSettingVisibility_: function(visible) {
1767 if (visible) 1779 if (visible)
1768 $('metrics-reporting-setting').style.display = 'block'; 1780 $('metrics-reporting-setting').style.display = 'block';
1769 else 1781 else
1770 $('metrics-reporting-setting').style.display = 'none'; 1782 $('metrics-reporting-setting').style.display = 'none';
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 } 2279 }
2268 button.textContent = loadTimeData.getString(strId); 2280 button.textContent = loadTimeData.getString(strId);
2269 }; 2281 };
2270 } 2282 }
2271 2283
2272 // Export 2284 // Export
2273 return { 2285 return {
2274 BrowserOptions: BrowserOptions 2286 BrowserOptions: BrowserOptions
2275 }; 2287 };
2276 }); 2288 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698