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 cd8e07148a694059c084a6a839aba95713955490..ceb626cc5aac5a01d1be9b2b569719d7914840e8 100644 |
--- a/chrome/browser/metrics/chrome_metrics_service_accessor.cc |
+++ b/chrome/browser/metrics/chrome_metrics_service_accessor.cc |
@@ -15,8 +15,26 @@ |
#include "chrome/browser/chromeos/settings/cros_settings.h" |
#endif |
+namespace { |
+ |
+const bool* g_metrics_consent_for_testing = nullptr; |
+ |
+} // namespace |
+ |
+// static |
+void ChromeMetricsServiceAccessor::SetMetricsAndCrashReportingForTesting( |
+ const bool* value) { |
+ DCHECK_NE(g_metrics_consent_for_testing == nullptr, value == nullptr) |
+ << "Unpaired set/reset"; |
+ |
+ g_metrics_consent_for_testing = value; |
+} |
+ |
// static |
bool ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled() { |
+ if (g_metrics_consent_for_testing) |
+ return *g_metrics_consent_for_testing; |
+ |
// TODO(blundell): Fix the unittests that don't set up the UI thread and |
// change this to just be DCHECK_CURRENTLY_ON(). |
DCHECK( |