Skip to content

Commit

Permalink
Merge pull request #248 from brave/disable-url-tracker
Browse files Browse the repository at this point in the history
Disable Chrome Google URL Tracker
  • Loading branch information
bbondy authored Jul 12, 2018
2 parents 0daf6a0 + d49d88e commit e808c50
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/brave_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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());
}
3 changes: 3 additions & 0 deletions common/brave_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions common/brave_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ extern const char kDisableBraveUpdate[];

extern const char kDisablePDFJSExtension[];

extern const char kDisableChromeGoogleURLTrackingClient[];

} // namespace switches

#endif // BRAVE_COMMON_BRAVE_SWITCHES_H_
Expand Down
1 change: 1 addition & 0 deletions test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e808c50

Please sign in to comment.