| 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; | 13 class PrefService; |
| 14 class PrefRegistrySimple; | 14 class PrefRegistrySimple; |
| 15 | 15 |
| 16 // Initiates a change to metrics reporting state to the new value of |enabled|. | 16 // Changes metrics reporting state without caring about the success of the |
| 17 // Starts or stops the metrics service based on the new state and then runs | 17 // change. |
| 18 // |callback_fn| (which can be null) with the updated state (as the operation | 18 void ChangeMetricsReportingState(bool enabled); |
| 19 // may fail). On platforms other than CrOS and Android, also updates the | 19 |
| 20 // underlying pref. | 20 // 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| |
| 22 // (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. |
| 21 // TODO(gayane): Support setting the pref on all platforms. | 24 // TODO(gayane): Support setting the pref on all platforms. |
| 22 void InitiateMetricsReportingChange( | 25 void ChangeMetricsReportingStateWithReply( |
| 23 bool enabled, | 26 bool enabled, |
| 24 const OnMetricsReportingCallbackType& callback_fn); | 27 const OnMetricsReportingCallbackType& callback_fn); |
| 25 | 28 |
| 26 // Returns whether MetricsReporting can be modified by the user (except | 29 // Returns whether MetricsReporting can be modified by the user (except |
| 27 // Android). | 30 // Android). |
| 28 bool IsMetricsReportingPolicyManaged(); | 31 bool IsMetricsReportingPolicyManaged(); |
| 29 | 32 |
| 30 // Initialize kMetricsReportingEnabled based on kStatsReportingPref device | 33 // Initialize kMetricsReportingEnabled based on kStatsReportingPref device |
| 31 // setting and add an observer as it is the source of truth on Chrome OS. | 34 // setting and add an observer as it is the source of truth on Chrome OS. |
| 32 void SetupMetricsStateForChromeOS(); | 35 void SetupMetricsStateForChromeOS(); |
| 33 | 36 |
| 34 #endif // CHROME_BROWSER_METRICS_METRICS_REPORTING_STATE_H_ | 37 #endif // CHROME_BROWSER_METRICS_METRICS_REPORTING_STATE_H_ |
| OLD | NEW |