| 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 // Initiates a change to metrics reporting state to the new value of |enabled|. |
| 17 // Starts or stops the metrics service based on the new state and then runs | 17 // Starts or stops the metrics service based on the new state and then runs |
| 18 // |callback_fn| (which can be null) with the updated state (as the operation | 18 // |callback_fn| (which can be null) with the updated state (as the operation |
| 19 // may fail). On platforms other than CrOS and Android, also updates the | 19 // may fail). On platforms other than CrOS and Android, also updates the |
| 20 // underlying pref. | 20 // underlying pref. |
| 21 // TODO(gayane): Support setting the pref on all platforms. | 21 // TODO(gayane): Support setting the pref on all platforms. |
| 22 void InitiateMetricsReportingChange( | 22 void InitiateMetricsReportingChange( |
| 23 bool enabled, | 23 bool enabled, |
| 24 const OnMetricsReportingCallbackType& callback_fn); | 24 const OnMetricsReportingCallbackType& callback_fn); |
| 25 | 25 |
| 26 // Returns whether MetricsReporting can be modified by the user (except | 26 // Returns whether MetricsReporting can be modified by the user (except |
| 27 // Android). | 27 // Android). |
| 28 bool IsMetricsReportingPolicyManaged(); | 28 bool IsMetricsReportingPolicyManaged(); |
| 29 | 29 |
| 30 // Register prefs relating to metrics reporting state. Currently only registers | |
| 31 // a pref for metrics reporting default opt-in state. | |
| 32 void RegisterMetricsReportingStatePrefs(PrefRegistrySimple* registry); | |
| 33 | |
| 34 // Sets whether metrics reporting was opt-in or not. If it was opt-in, then the | |
| 35 // enable checkbox on first-run was default unchecked. If it was opt-out, then | |
| 36 // the checkbox was default checked. This should only be set once, and only | |
| 37 // during first-run. | |
| 38 void RecordMetricsReportingDefaultOptIn(PrefService* local_state, bool opt_in); | |
| 39 | |
| 40 // Gets information about the default value for the enable metrics reporting | |
| 41 // checkbox shown during first-run. | |
| 42 metrics::MetricsServiceClient::EnableMetricsDefault | |
| 43 GetMetricsReportingDefaultOptIn(PrefService* local_state); | |
| 44 | |
| 45 // Initialize kMetricsReportingEnabled based on kStatsReportingPref device | 30 // Initialize kMetricsReportingEnabled based on kStatsReportingPref device |
| 46 // setting and add an observer as it is the source of truth on Chrome OS. | 31 // setting and add an observer as it is the source of truth on Chrome OS. |
| 47 void SetupMetricsStateForChromeOS(); | 32 void SetupMetricsStateForChromeOS(); |
| 48 | 33 |
| 49 #endif // CHROME_BROWSER_METRICS_METRICS_REPORTING_STATE_H_ | 34 #endif // CHROME_BROWSER_METRICS_METRICS_REPORTING_STATE_H_ |
| OLD | NEW |