Index: chrome/browser/resources/options/browser_options.js |
diff --git a/chrome/browser/resources/options/browser_options.js b/chrome/browser/resources/options/browser_options.js |
index 944a3e854c2e8f0550fabeb571e7d826ed7c9afa..b0d1ea72ee9bf29e76f4ba79fe3b13a24ffbae4f 100644 |
--- a/chrome/browser/resources/options/browser_options.js |
+++ b/chrome/browser/resources/options/browser_options.js |
@@ -452,47 +452,50 @@ cr.define('options', function() { |
chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); |
}; |
$('privacyClearDataButton').hidden = OptionsPage.isSettingsApp(); |
- // 'metricsReportingEnabled' element is only present on Chrome branded |
- // builds, and the 'metricsReportingCheckboxAction' message is only |
- // handled on ChromeOS. |
- if ($('metrics-reporting-enabled') && cr.isChromeOS) { |
- $('metrics-reporting-enabled').onclick = function(event) { |
- chrome.send('metricsReportingCheckboxAction', |
- [String(event.currentTarget.checked)]); |
- }; |
- } |
- if ($('metrics-reporting-enabled') && !cr.isChromeOS) { |
- // The localized string has the | symbol on each side of the text that |
- // needs to be made into a button to restart Chrome. We parse the text |
- // and build the button from that. |
- var restartTextFragments = |
- loadTimeData.getString('metricsReportingResetRestart').split('|'); |
- // Assume structure is something like "starting text |link text| ending |
- // text" where both starting text and ending text may or may not be |
- // present, but the split should always be in three pieces. |
- var restartElements = |
- $('metrics-reporting-reset-restart').querySelectorAll('*'); |
- for (var i = 0; i < restartTextFragments.length; i++) { |
- restartElements[i].textContent = restartTextFragments[i]; |
- } |
- restartElements[1].onclick = function(event) { |
- chrome.send('restartBrowser'); |
- }; |
+ |
+ if ($('metrics-reporting-enabled')) { |
+ $('metrics-reporting-enabled').checked = |
+ loadTimeData.getBoolean('metricsReportingEnabledAtStart'); |
+ |
$('metrics-reporting-enabled').onclick = function(event) { |
chrome.send('metricsReportingCheckboxChanged', |
[Boolean(event.currentTarget.checked)]); |
- if (cr.isMac) { |
+ if (cr.isChromeOS) { |
+ // 'metricsReportingEnabled' element is only present on Chrome |
+ // branded builds, and the 'metricsReportingCheckboxAction' message |
+ // is only handled on ChromeOS. |
+ chrome.send('metricsReportingCheckboxAction', |
+ [String(event.currentTarget.checked)]); |
+ } else if (!cr.isMac) { |
// A browser restart is never needed to toggle metrics reporting, |
// and is only needed to toggle crash reporting when using Breakpad. |
// Crashpad, used on Mac, does not require a browser restart. |
- return; |
+ $('metrics-reporting-reset-restart').hidden = |
+ loadTimeData.getBoolean('metricsReportingEnabledAtStart') == |
+ $('metrics-reporting-enabled').checked; |
} |
- $('metrics-reporting-reset-restart').hidden = |
- loadTimeData.getBoolean('metricsReportingEnabledAtStart') == |
- $('metrics-reporting-enabled').checked; |
+ |
}; |
- $('metrics-reporting-enabled').checked = |
- loadTimeData.getBoolean('metricsReportingEnabledAtStart'); |
+ |
+ // Don't need to initialize restart button for ChromeOS or Mac. |
+ 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.
|
+ // The localized string has the | symbol on each side of the text that |
+ // needs to be made into a button to restart Chrome. We parse the text |
+ // and build the button from that. |
+ var restartTextFragments = |
+ loadTimeData.getString('metricsReportingResetRestart').split('|'); |
+ // Assume structure is something like "starting text |link text| |
+ // ending text" where both starting text and ending text may or may |
+ // not be present, but the split should always be in three pieces. |
+ var restartElements = |
+ $('metrics-reporting-reset-restart').querySelectorAll('*'); |
+ for (var i = 0; i < restartTextFragments.length; i++) { |
+ restartElements[i].textContent = restartTextFragments[i]; |
+ } |
+ restartElements[1].onclick = function(event) { |
+ chrome.send('restartBrowser'); |
+ }; |
+ } |
} |
$('networkPredictionOptions').onchange = function(event) { |
var value = (event.target.checked ? |
@@ -1746,18 +1749,24 @@ cr.define('options', function() { |
* Set the checked state of the metrics reporting checkbox. |
* @private |
*/ |
- setMetricsReportingCheckboxState_: function(checked, disabled) { |
+ setMetricsReportingCheckboxState_: function(checked, |
+ policy_managed, |
+ owner_managed) { |
$('metrics-reporting-enabled').checked = checked; |
- $('metrics-reporting-enabled').disabled = disabled; |
+ $('metrics-reporting-enabled').disabled = policy_managed || owner_managed; |
// If checkbox gets disabled then add an attribute for displaying the |
// special icon. Otherwise remove the indicator attribute. |
- if (disabled) { |
+ if (policy_managed) { |
$('metrics-reporting-disabled-icon').setAttribute('controlled-by', |
'policy'); |
+ } else if (owner_managed) { |
+ $('metrics-reporting-disabled-icon').setAttribute('controlled-by', |
+ 'owner'); |
} else { |
$('metrics-reporting-disabled-icon').removeAttribute('controlled-by'); |
} |
+ |
}, |
/** |