Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_reporting_state.h" | 5 #include "chrome/browser/metrics/metrics_reporting_state.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 callback_fn.Run(updated_pref); | 86 callback_fn.Run(updated_pref); |
| 87 } | 87 } |
| 88 | 88 |
| 89 #if defined(OS_CHROMEOS) | 89 #if defined(OS_CHROMEOS) |
| 90 // Callback function for Chrome OS device settings change, so that the update is | 90 // Callback function for Chrome OS device settings change, so that the update is |
| 91 // applied to metrics reporting state. | 91 // applied to metrics reporting state. |
| 92 void OnDeviceSettingChange() { | 92 void OnDeviceSettingChange() { |
| 93 bool enable_metrics = false; | 93 bool enable_metrics = false; |
| 94 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | 94 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, |
| 95 &enable_metrics); | 95 &enable_metrics); |
| 96 InitiateMetricsReportingChange(enable_metrics, | 96 ChangeMetricsReportingState(enable_metrics); |
| 97 OnMetricsReportingCallbackType()); | |
| 98 } | 97 } |
| 99 #endif | 98 #endif |
| 100 | 99 |
| 101 } // namespace | 100 } // namespace |
| 102 | 101 |
| 102 void ChangeMetricsReportingState(bool enabled) { | |
| 103 ChangeMetricsReportingStateWithReply(enabled, | |
| 104 OnMetricsReportingCallbackType()); | |
| 105 } | |
|
Ilya Sherman
2016/08/05 03:39:06
nit: Please define this in the same order in the .
gayane -on leave until 09-2017
2016/08/05 17:31:43
Done.
| |
| 106 | |
| 103 // TODO(gayane): Instead of checking policy before setting the metrics pref set | 107 // TODO(gayane): Instead of checking policy before setting the metrics pref set |
| 104 // the pref and register for notifications for the rest of the changes. | 108 // the pref and register for notifications for the rest of the changes. |
| 105 void InitiateMetricsReportingChange( | 109 void ChangeMetricsReportingStateWithReply( |
| 106 bool enabled, | 110 bool enabled, |
| 107 const OnMetricsReportingCallbackType& callback_fn) { | 111 const OnMetricsReportingCallbackType& callback_fn) { |
| 108 #if !defined(OS_ANDROID) | 112 #if !defined(OS_ANDROID) |
| 109 if (IsMetricsReportingPolicyManaged()) { | 113 if (IsMetricsReportingPolicyManaged()) { |
| 110 if (!callback_fn.is_null()) { | 114 if (!callback_fn.is_null()) { |
| 111 callback_fn.Run( | 115 callback_fn.Run( |
| 112 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()); | 116 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()); |
| 113 } | 117 } |
| 114 return; | 118 return; |
| 115 } | 119 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 133 // will trigger this function and kMetricsReportinEnabled as well as metrics | 137 // will trigger this function and kMetricsReportinEnabled as well as metrics |
| 134 // service state will be updated accordingly. | 138 // service state will be updated accordingly. |
| 135 void SetupMetricsStateForChromeOS() { | 139 void SetupMetricsStateForChromeOS() { |
| 136 #if defined(OS_CHROMEOS) | 140 #if defined(OS_CHROMEOS) |
| 137 chromeos::CrosSettings::Get()->AddSettingsObserver( | 141 chromeos::CrosSettings::Get()->AddSettingsObserver( |
| 138 chromeos::kStatsReportingPref, base::Bind(&OnDeviceSettingChange)); | 142 chromeos::kStatsReportingPref, base::Bind(&OnDeviceSettingChange)); |
| 139 | 143 |
| 140 OnDeviceSettingChange(); | 144 OnDeviceSettingChange(); |
| 141 #endif // defined(OS_CHROMEOS) | 145 #endif // defined(OS_CHROMEOS) |
| 142 } | 146 } |
| OLD | NEW |