| Index: chrome/browser/ui/webui/options/browser_options_handler.cc
|
| diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
|
| index ab08941ddff6b200a15a71c5a05e3972ee17b16e..5b1ba94fd664cc8813b7963f7a6166e05843fa76 100644
|
| --- a/chrome/browser/ui/webui/options/browser_options_handler.cc
|
| +++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
|
| @@ -569,11 +569,9 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) {
|
|
|
| values->SetString("doNotTrackLearnMoreURL", chrome::kDoNotTrackLearnMoreURL);
|
|
|
| -#if !defined(OS_CHROMEOS)
|
| values->SetBoolean(
|
| "metricsReportingEnabledAtStart",
|
| ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled());
|
| -#endif
|
|
|
| #if defined(OS_CHROMEOS)
|
| // TODO(pastarmovj): replace this with a call to the CrosSettings list
|
| @@ -2147,14 +2145,18 @@ void BrowserOptionsHandler::SetupExtensionControlledIndicators() {
|
| }
|
|
|
| void BrowserOptionsHandler::SetupMetricsReportingCheckbox() {
|
| - // This function does not work for ChromeOS and non-official builds.
|
| -#if !defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD)
|
| +// As the Metrics and crash reporting checkbox only exists for official builds
|
| +// it doesn't need setup for non-official builds.
|
| +#if defined(GOOGLE_CHROME_BUILD)
|
| bool checked =
|
| ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled();
|
| - bool disabled = !IsMetricsReportingUserChangable();
|
| -
|
| - SetMetricsReportingCheckbox(checked, disabled);
|
| -#endif
|
| + bool policy_managed = IsMetricsReportingPolicyManaged();
|
| + bool owner_managed = false;
|
| +#if defined(OS_CHROMEOS)
|
| + owner_managed = IsMetricsReportingOwnerManaged();
|
| +#endif // defined(OS_CHROMEOS)
|
| + SetMetricsReportingCheckbox(checked, policy_managed, owner_managed);
|
| +#endif // defined(GOOGLE_CHROME_BUILD)
|
| }
|
|
|
| void BrowserOptionsHandler::HandleMetricsReportingChange(
|
| @@ -2162,6 +2164,11 @@ void BrowserOptionsHandler::HandleMetricsReportingChange(
|
| bool enable;
|
| if (!args->GetBoolean(0, &enable))
|
| return;
|
| + if (IsMetricsReportingOwnerManaged() || IsMetricsReportingPolicyManaged()) {
|
| + MetricsReportingChangeCallback(
|
| + ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled());
|
| + return;
|
| + }
|
|
|
| InitiateMetricsReportingChange(
|
| enable,
|
| @@ -2170,15 +2177,17 @@ void BrowserOptionsHandler::HandleMetricsReportingChange(
|
| }
|
|
|
| void BrowserOptionsHandler::MetricsReportingChangeCallback(bool enabled) {
|
| - SetMetricsReportingCheckbox(enabled, !IsMetricsReportingUserChangable());
|
| + SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(),
|
| + IsMetricsReportingOwnerManaged());
|
| }
|
|
|
| void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked,
|
| - bool disabled) {
|
| + bool policy_managed,
|
| + bool owner_managed) {
|
| web_ui()->CallJavascriptFunction(
|
| "BrowserOptions.setMetricsReportingCheckboxState",
|
| - base::FundamentalValue(checked),
|
| - base::FundamentalValue(disabled));
|
| + base::FundamentalValue(checked), base::FundamentalValue(policy_managed),
|
| + base::FundamentalValue(owner_managed));
|
| }
|
|
|
| void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns,
|
| @@ -2190,4 +2199,12 @@ void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns,
|
| SetupMetricsReportingCheckbox();
|
| }
|
|
|
| +bool BrowserOptionsHandler::IsMetricsReportingOwnerManaged() {
|
| +#if defined(OS_CHROMEOS)
|
| + return !chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui()));
|
| +#else
|
| + return false;
|
| +#endif
|
| +}
|
| +
|
| } // namespace options
|
|
|