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

Unified Diff: chrome/browser/metrics/chrome_metrics_service_accessor.cc

Issue 916133003: Fix ChromeMetricsServiceAccessor::IsMetricsReportingEnabled on CrOs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make MetricsServicesManager::IsMetricsReportingEnabled private Created 5 years, 10 months 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/metrics/chrome_metrics_service_accessor.cc
diff --git a/chrome/browser/metrics/chrome_metrics_service_accessor.cc b/chrome/browser/metrics/chrome_metrics_service_accessor.cc
index 271af31bc9d108bfc4367c8f76175daac9eb7b13..fd60772ab4c1c0bdc301acdb4deb47766ede09fd 100644
--- a/chrome/browser/metrics/chrome_metrics_service_accessor.cc
+++ b/chrome/browser/metrics/chrome_metrics_service_accessor.cc
@@ -4,8 +4,11 @@
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
+#include "base/command_line.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/metrics/metrics_services_manager.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/metrics/metrics_service.h"
#include "components/variations/metrics_util.h"
@@ -16,27 +19,28 @@
// static
bool ChromeMetricsServiceAccessor::IsMetricsReportingEnabled() {
- bool result = false;
- const PrefService* local_state = g_browser_process->local_state();
- if (local_state) {
- const PrefService::Preference* uma_pref =
- local_state->FindPreference(prefs::kMetricsReportingEnabled);
- if (uma_pref) {
- bool success = uma_pref->GetValue()->GetAsBoolean(&result);
- DCHECK(success);
- }
- }
- return result;
-}
+ // If the user permits metrics reporting with the checkbox in the
+ // prefs, we turn on recording. We disable metrics completely for
+ // non-official builds, or when field trials are forced.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kForceFieldTrials))
Alexei Svitkine (slow) 2015/02/12 15:58:46 Nit: While you're touching this, add {}'s here.
anthonyvd 2015/02/12 16:29:19 Done.
+ return false;
-bool ChromeMetricsServiceAccessor::IsCrashReportingEnabled() {
+ bool enabled = false;
#if defined(GOOGLE_CHROME_BUILD)
#if defined(OS_CHROMEOS)
- bool reporting_enabled = false;
chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref,
- &reporting_enabled);
- return reporting_enabled;
-#elif defined(OS_ANDROID)
+ &enabled);
+#else
+ enabled = local_state_->GetBoolean(prefs::kMetricsReportingEnabled);
Alexei Svitkine (slow) 2015/02/12 15:58:46 I don't think this will compile, since there's no
anthonyvd 2015/02/12 16:29:19 Done.
+#endif // #if defined(OS_CHROMEOS)
+#endif // defined(GOOGLE_CHROME_BUILD)
+ return enabled;
+}
+
+bool ChromeMetricsServiceAccessor::IsCrashReportingEnabled() {
+#if defined(GOOGLE_CHROME_BUILD)
+#if defined(OS_ANDROID)
// Android has its own settings for metrics / crash uploading.
const PrefService* prefs = g_browser_process->local_state();
return prefs->GetBoolean(prefs::kCrashReportingEnabled);

Powered by Google App Engine
This is Rietveld 408576698