diff --git a/app/brave_main_delegate.cc b/app/brave_main_delegate.cc index 26b6df5ec5b8..41e4f918acbc 100644 --- a/app/brave_main_delegate.cc +++ b/app/brave_main_delegate.cc @@ -12,6 +12,7 @@ #include "base/time/time.h" #include "build/build_config.h" #include "brave/browser/brave_content_browser_client.h" +#include "brave/common/brave_switches.h" #include "brave/common/resource_bundle_helper.h" #include "brave/renderer/brave_content_renderer_client.h" #include "brave/utility/brave_content_utility_client.h" @@ -105,6 +106,7 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) { *base::CommandLine::ForCurrentProcess(); command_line.AppendSwitch(switches::kEnableTabAudioMuting); command_line.AppendSwitch(switches::kDisableDomainReliability); + command_line.AppendSwitch(switches::kDisableChromeGoogleURLTrackingClient); std::stringstream enabled_features; enabled_features << features::kEnableEmojiContextMenu.name diff --git a/chromium_src/chrome/browser/google/chrome_google_url_tracker_client.cc b/chromium_src/chrome/browser/google/chrome_google_url_tracker_client.cc new file mode 100644 index 000000000000..4ce12fcecbd1 --- /dev/null +++ b/chromium_src/chrome/browser/google/chrome_google_url_tracker_client.cc @@ -0,0 +1,18 @@ +/* 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/. */ + +// This include is required here since chrome_google_url_tracker_client.cc +// incldues it. We don't want replacements to happen though. +// The header guard will ensure this even know the .cc includes it. +#include "chrome/common/chrome_switches.h" + +// Required to declare kDisableChromeGoogleURLTrackingClient +#include "brave/common/brave_switches.h" + +// The ChromeGooglURLTrackerClient will disable itself when the kDisableBackgroundNetworking +// switch is set. Since several other services also disable themeselves when that is set, +// we rename the switch that is used to something we define. +#define kDisableBackgroundNetworking kDisableChromeGoogleURLTrackingClient +#include "../../../../../chrome/browser/google/chrome_google_url_tracker_client.cc" +#undef kDisableBackgroundNetworking diff --git a/chromium_src/chrome/browser/google/chrome_google_url_tracker_client_browsertest.cc b/chromium_src/chrome/browser/google/chrome_google_url_tracker_client_browsertest.cc new file mode 100644 index 000000000000..deb8be5628fc --- /dev/null +++ b/chromium_src/chrome/browser/google/chrome_google_url_tracker_client_browsertest.cc @@ -0,0 +1,18 @@ +/* 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 "brave/common/brave_switches.h" +#include "chrome/browser/google/chrome_google_url_tracker_client.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/test/base/in_process_browser_test.h" + +using BraveGoogleURLTrackerClientTest = InProcessBrowserTest; + +IN_PROC_BROWSER_TEST_F(BraveGoogleURLTrackerClientTest, DisablesGoogleURLTrackerClient) { + EXPECT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableChromeGoogleURLTrackingClient)); + + ChromeGoogleURLTrackerClient client(browser()->profile()); + ASSERT_FALSE(client.IsBackgroundNetworkingEnabled()); +} diff --git a/common/brave_switches.cc b/common/brave_switches.cc index b1a0bfe82297..b2c1b8857c3b 100644 --- a/common/brave_switches.cc +++ b/common/brave_switches.cc @@ -17,4 +17,7 @@ const char kDisablePDFJSExtension[] = "disable-pdfjs-extension"; // This switch disables update module(Sparkle). const char kDisableBraveUpdate[] = "disable-brave-update"; +// This switch disables the ChromeGoogleURLTrackerClient +const char kDisableChromeGoogleURLTrackingClient[] = "disable-chrome-google-url-tracking-client"; + } // namespace switches diff --git a/common/brave_switches.h b/common/brave_switches.h index 99fc04f77178..3fc8642f0f18 100644 --- a/common/brave_switches.h +++ b/common/brave_switches.h @@ -15,6 +15,8 @@ extern const char kDisableBraveUpdate[]; extern const char kDisablePDFJSExtension[]; +extern const char kDisableChromeGoogleURLTrackingClient[]; + } // namespace switches #endif // BRAVE_COMMON_BRAVE_SWITCHES_H_ diff --git a/test/BUILD.gn b/test/BUILD.gn index 2845e6e95339..d1049f4c2eb5 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -134,6 +134,7 @@ static_library("browser_tests_runner") { test("brave_browser_tests") { sources = [ "//brave/app/brave_main_delegate_browsertest.cc", + "//brave/chromium_src/chrome/browser/google/chrome_google_url_tracker_client_browsertest.cc", "//brave/chromium_src/third_party/blink/renderer/modules/battery/navigator_batterytest.cc", "//brave/chromium_src/third_party/blink/renderer/modules/bluetooth/navigator_bluetoothtest.cc", "//brave/chromium_src/third_party/blink/renderer/modules/credentialmanager/credentials_containertest.cc",