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

Unified Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 1411863002: Use kMetricsReportingEnabled instead of kStatsReporingPref on metrics side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits 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 side-by-side diff with in-line comments
Download patch
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..51bb39dec7d2c962df4314c56f03150441324f9f 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 to be set up 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 = !IsDeviceOwnerProfile();
+#endif // defined(OS_CHROMEOS)
+ SetMetricsReportingCheckbox(checked, policy_managed, owner_managed);
+#endif // defined(GOOGLE_CHROME_BUILD)
}
void BrowserOptionsHandler::HandleMetricsReportingChange(
@@ -2162,23 +2164,35 @@ void BrowserOptionsHandler::HandleMetricsReportingChange(
bool enable;
if (!args->GetBoolean(0, &enable))
return;
+ if (!IsDeviceOwnerProfile() || IsMetricsReportingPolicyManaged()) {
Alexei Svitkine (slow) 2015/11/03 19:55:24 Add a comment please.
gayane -on leave until 09-2017 2015/11/03 21:54:22 Done.
+ MetricsReportingChangeCallback(
+ ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled());
+ return;
+ }
+#if defined(OS_CHROMEOS)
+ chromeos::CrosSettings::Get()->SetBoolean(chromeos::kStatsReportingPref,
+ enable);
Alexei Svitkine (slow) 2015/11/03 19:55:25 How will MetricsReportingChangeCallback() be invok
gayane -on leave until 09-2017 2015/11/03 21:54:22 That's right I have lost the callback for chromeos
+#else
InitiateMetricsReportingChange(
enable,
base::Bind(&BrowserOptionsHandler::MetricsReportingChangeCallback,
base::Unretained(this)));
+#endif // defined(OS_CHROMEOS)
}
void BrowserOptionsHandler::MetricsReportingChangeCallback(bool enabled) {
- SetMetricsReportingCheckbox(enabled, !IsMetricsReportingUserChangable());
+ SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(),
+ !IsDeviceOwnerProfile());
}
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 +2204,12 @@ void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns,
SetupMetricsReportingCheckbox();
}
+bool BrowserOptionsHandler::IsDeviceOwnerProfile() {
+#if defined(OS_CHROMEOS)
+ return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui()));
+#else
+ return true;
+#endif
+}
+
} // namespace options

Powered by Google App Engine
This is Rietveld 408576698