Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/metrics/metrics_services_manager.h" | 5 #include "chrome/browser/metrics/metrics_services_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | |
| 13 #include "chrome/browser/metrics/chrome_metrics_service_client.h" | 14 #include "chrome/browser/metrics/chrome_metrics_service_client.h" |
| 14 #include "chrome/browser/metrics/variations/variations_service.h" | 15 #include "chrome/browser/metrics/variations/variations_service.h" |
| 15 #include "chrome/browser/ui/browser_otr_state.h" | 16 #include "chrome/browser/ui/browser_otr_state.h" |
| 16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/installer/util/google_update_settings.h" | 19 #include "chrome/installer/util/google_update_settings.h" |
| 19 #include "components/metrics/metrics_service.h" | 20 #include "components/metrics/metrics_service.h" |
| 20 #include "components/metrics/metrics_state_manager.h" | 21 #include "components/metrics/metrics_state_manager.h" |
| 21 #include "components/rappor/rappor_service.h" | 22 #include "components/rappor/rappor_service.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 metrics->DisableReporting(); | 121 metrics->DisableReporting(); |
| 121 } else if (metrics->recording_active() || metrics->reporting_active()) { | 122 } else if (metrics->recording_active() || metrics->reporting_active()) { |
| 122 metrics->Stop(); | 123 metrics->Stop(); |
| 123 } | 124 } |
| 124 | 125 |
| 125 rappor::RecordingLevel recording_level = may_record ? | 126 rappor::RecordingLevel recording_level = may_record ? |
| 126 rappor::FINE_LEVEL : rappor::RECORDING_DISABLED; | 127 rappor::FINE_LEVEL : rappor::RECORDING_DISABLED; |
| 127 GetRapporService()->Update(recording_level, may_upload); | 128 GetRapporService()->Update(recording_level, may_upload); |
| 128 } | 129 } |
| 129 | 130 |
| 131 void MetricsServicesManager::UpdateUploadPermissions(bool may_upload) { | |
| 132 return UpdatePermissions(IsMetricsReportingEnabled(), may_upload); | |
| 133 } | |
| 134 | |
| 130 // TODO(asvitkine): This function does not report the correct value on Android, | 135 // TODO(asvitkine): This function does not report the correct value on Android, |
| 131 // see http://crbug.com/362192. | 136 // see http://crbug.com/362192. |
|
Alexei Svitkine (slow)
2015/02/12 15:58:46
Nit: Move this comment to the moved implementation
anthonyvd
2015/02/12 16:29:20
Done.
| |
| 132 bool MetricsServicesManager::IsMetricsReportingEnabled() const { | 137 bool MetricsServicesManager::IsMetricsReportingEnabled() const { |
|
Alexei Svitkine (slow)
2015/02/12 15:58:46
Maybe we don't need this function on this wrapper
anthonyvd
2015/02/12 16:29:19
Done.
| |
| 133 // If the user permits metrics reporting with the checkbox in the | 138 return ChromeMetricsServiceAccessor::IsMetricsReportingEnabled(); |
| 134 // prefs, we turn on recording. We disable metrics completely for | |
| 135 // non-official builds, or when field trials are forced. | |
| 136 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 137 switches::kForceFieldTrials)) | |
| 138 return false; | |
| 139 | |
| 140 bool enabled = false; | |
| 141 #if defined(GOOGLE_CHROME_BUILD) | |
| 142 #if defined(OS_CHROMEOS) | |
| 143 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | |
| 144 &enabled); | |
| 145 #else | |
| 146 enabled = local_state_->GetBoolean(prefs::kMetricsReportingEnabled); | |
| 147 #endif // #if defined(OS_CHROMEOS) | |
| 148 #endif // defined(GOOGLE_CHROME_BUILD) | |
| 149 return enabled; | |
| 150 } | 139 } |
| OLD | NEW |