OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_METRICS_METRICS_REPORTING_STATE_H_ | 5 #ifndef CHROME_BROWSER_METRICS_METRICS_REPORTING_STATE_H_ |
6 #define CHROME_BROWSER_METRICS_METRICS_REPORTING_STATE_H_ | 6 #define CHROME_BROWSER_METRICS_METRICS_REPORTING_STATE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "components/metrics/metrics_service_client.h" | 9 #include "components/metrics/metrics_service_client.h" |
10 | 10 |
11 typedef base::Callback<void(bool)> OnMetricsReportingCallbackType; | 11 typedef base::Callback<void(bool)> OnMetricsReportingCallbackType; |
12 | 12 |
13 class PrefService; | |
14 class PrefRegistrySimple; | |
15 | |
16 // Changes metrics reporting state without caring about the success of the | 13 // Changes metrics reporting state without caring about the success of the |
17 // change. | 14 // change. |
18 void ChangeMetricsReportingState(bool enabled); | 15 void ChangeMetricsReportingState(bool enabled); |
19 | 16 |
20 // Changes metrics reporting state to the new value of |enabled|. Starts or | 17 // Changes metrics reporting state to the new value of |enabled|. Starts or |
21 // stops the metrics service based on the new state and then runs |callback_fn| | 18 // stops the metrics service based on the new state and then runs |callback_fn| |
22 // (which can be null) with the updated state (as the operation may fail). On | 19 // (which can be null) with the updated state (as the operation may fail). On |
23 // platforms other than CrOS and Android, also updates the underlying pref. | 20 // platforms other than CrOS and Android, also updates the underlying pref. |
24 // TODO(gayane): Support setting the pref on all platforms. | 21 // TODO(gayane): Support setting the pref on all platforms. |
25 void ChangeMetricsReportingStateWithReply( | 22 void ChangeMetricsReportingStateWithReply( |
26 bool enabled, | 23 bool enabled, |
27 const OnMetricsReportingCallbackType& callback_fn); | 24 const OnMetricsReportingCallbackType& callback_fn); |
28 | 25 |
29 // Update metrics prefs on a permission (opt-in/out) change. When opting out, | 26 // Update metrics prefs on a permission (opt-in/out) change. When opting out, |
30 // this clears various client ids. When opting in, this resets saving crash | 27 // this clears various client ids. When opting in, this resets saving crash |
31 // prefs, so as not to trigger upload of various stale data. | 28 // prefs, so as not to trigger upload of various stale data. |
32 void UpdateMetricsPrefsOnPermissionChange(bool metrics_enabled); | 29 void UpdateMetricsPrefsOnPermissionChange(bool metrics_enabled); |
33 | 30 |
34 // Returns whether MetricsReporting can be modified by the user (except | 31 // Returns whether MetricsReporting can be modified by the user (except |
35 // Android). | 32 // Android). |
36 bool IsMetricsReportingPolicyManaged(); | 33 bool IsMetricsReportingPolicyManaged(); |
37 | 34 |
38 // Initialize kMetricsReportingEnabled based on kStatsReportingPref device | 35 // Initialize kMetricsReportingEnabled based on kStatsReportingPref device |
39 // setting and add an observer as it is the source of truth on Chrome OS. | 36 // setting and add an observer as it is the source of truth on Chrome OS. |
40 void SetupMetricsStateForChromeOS(); | 37 void SetupMetricsStateForChromeOS(); |
41 | 38 |
42 #endif // CHROME_BROWSER_METRICS_METRICS_REPORTING_STATE_H_ | 39 #endif // CHROME_BROWSER_METRICS_METRICS_REPORTING_STATE_H_ |
OLD | NEW |