diff --git a/chromium_src/components/metrics/enabled_state_provider.cc b/chromium_src/components/metrics/enabled_state_provider.cc new file mode 100644 index 000000000000..0e3d640dd7c2 --- /dev/null +++ b/chromium_src/components/metrics/enabled_state_provider.cc @@ -0,0 +1,17 @@ +/* Copyright (c) 2019 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "components/metrics/enabled_state_provider.h" + +#include "base/base_switches.h" +#include "base/command_line.h" + +namespace metrics { + +bool EnabledStateProvider::IsReportingEnabled() const { + return false; +} + +} // namespace metrics diff --git a/chromium_src/components/metrics/enabled_state_provider_unittest.cc b/chromium_src/components/metrics/enabled_state_provider_unittest.cc new file mode 100644 index 000000000000..9b4c26244d33 --- /dev/null +++ b/chromium_src/components/metrics/enabled_state_provider_unittest.cc @@ -0,0 +1,27 @@ +/* Copyright (c) 2019 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "chrome/browser/metrics/chrome_metrics_services_manager_client.h" + +#include "chrome/browser/metrics/chrome_metrics_service_accessor.h" +#include "components/metrics/enabled_state_provider.h" +#include "components/metrics/metrics_pref_names.h" +#include "components/prefs/pref_registry_simple.h" +#include "components/prefs/testing_pref_service.h" +#include "testing/gtest/include/gtest/gtest.h" + +TEST(ChromeMetricsServicesManagerClient, MetricsReportingDisabled) { + TestingPrefServiceSimple local_state; + metrics::RegisterMetricsReportingStatePrefs(local_state.registry()); + local_state.registry()->RegisterBooleanPref( + metrics::prefs::kMetricsReportingEnabled, true); + + ChromeMetricsServicesManagerClient client(&local_state); + const metrics::EnabledStateProvider& provider = + client.GetEnabledStateProviderForTesting(); + + // Reporting should never be enabled + EXPECT_FALSE(provider.IsReportingEnabled()); +} diff --git a/test/BUILD.gn b/test/BUILD.gn index 5327a8f503a4..a2f733da7888 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -56,6 +56,7 @@ test("brave_unit_tests") { "//brave/chromium_src/chrome/browser/external_protocol/external_protocol_handler_unittest.cc", "//brave/chromium_src/chrome/browser/signin/account_consistency_disabled_unittest.cc", "//brave/chromium_src/chrome/browser/ui/bookmarks/brave_bookmark_context_menu_controller_unittest.cc", + "//brave/chromium_src/components/metrics/enabled_state_provider_unittest.cc", "//brave/chromium_src/components/search_engines/brave_template_url_prepopulate_data_unittest.cc", "//brave/chromium_src/components/search_engines/brave_template_url_service_util_unittest.cc", "//brave/chromium_src/components/version_info/brave_version_info_unittest.cc",