Skip to content

Commit

Permalink
Merge pull request #3236 from brave/disable_translate_pref_in_tor
Browse files Browse the repository at this point in the history
Disable translate pref in Tor profile.
  • Loading branch information
yrliou committed Aug 22, 2019
1 parent 6a5688c commit fd9a928
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions browser/profiles/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ source_set("profiles") {
"//chrome/common",
"//content/public/common",
"//brave/browser/tor",
"//brave/browser/translate/buildflags",
"//brave/content:browser",
"//brave/common/tor",
"//brave/components/brave_ads/browser",
"//brave/components/brave_sync",
"//brave/components/brave_rewards/browser",
"//components/translate/core/browser",
"//ui/base",
]
}
8 changes: 8 additions & 0 deletions browser/profiles/brave_profile_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "brave/browser/tor/buildflags.h"
#include "brave/browser/tor/tor_profile_service.h"
#include "brave/browser/tor/tor_profile_service_factory.h"
#include "brave/browser/translate/buildflags/buildflags.h"
#include "brave/common/pref_names.h"
#include "brave/common/tor/pref_names.h"
#include "brave/common/tor/tor_constants.h"
Expand All @@ -31,6 +32,7 @@
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/common/safe_browsing_prefs.h"
#include "components/signin/core/browser/signin_pref_names.h"
#include "components/translate/core/browser/translate_pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/common/webrtc_ip_handling_policy.h"
Expand Down Expand Up @@ -66,6 +68,12 @@ void BraveProfileManager::InitTorProfileUserPrefs(Profile* profile) {
// https://blog.torproject.org/bittorrent-over-tor-isnt-good-idea
#if BUILDFLAG(ENABLE_BRAVE_WEBTORRENT)
pref_service->SetBoolean(kWebTorrentEnabled, false);
#endif
// Disable the automatic translate bubble in Tor because we currently don't
// support extensions in Tor mode and users cannot disable this through
// settings page for Tor windows.
#if BUILDFLAG(ENABLE_BRAVE_TRANSLATE_EXTENSION)
pref_service->SetBoolean(prefs::kOfferTranslateEnabled, false);
#endif
}

Expand Down
16 changes: 11 additions & 5 deletions browser/profiles/brave_profile_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "base/strings/utf_string_conversions.h"
#include "brave/browser/profiles/tor_unittest_profile_manager.h"
#include "brave/browser/tor/tor_launcher_factory.h"
#include "brave/browser/translate/buildflags/buildflags.h"
#include "brave/common/tor/pref_names.h"
#include "brave/common/tor/tor_constants.h"
#include "brave/components/brave_webtorrent/browser/webtorrent_util.h"
Expand All @@ -29,6 +30,7 @@
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/safe_browsing/common/safe_browsing_prefs.h"
#include "components/translate/core/browser/translate_pref_names.h"
#include "content/public/common/webrtc_ip_handling_policy.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_utils.h"
Expand Down Expand Up @@ -142,19 +144,23 @@ TEST_F(BraveProfileManagerTest, InitProfileUserPrefs) {
tor_profile->GetPrefs()->GetInteger(prefs::kProfileAvatarIndex);
EXPECT_EQ(avatar_index, size_t(0));
EXPECT_FALSE(
tor_profile->GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultName));
tor_profile->GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultName));
EXPECT_FALSE(profile->GetPrefs()->GetBoolean(tor::prefs::kProfileUsingTor));
EXPECT_TRUE(
tor_profile->GetPrefs()->GetBoolean(tor::prefs::kProfileUsingTor));
tor_profile->GetPrefs()->GetBoolean(tor::prefs::kProfileUsingTor));

// Check WebRTC IP handling policy.
EXPECT_EQ(
tor_profile->GetPrefs()->GetString(prefs::kWebRTCIPHandlingPolicy),
content::kWebRTCIPHandlingDisableNonProxiedUdp);
tor_profile->GetPrefs()->GetString(prefs::kWebRTCIPHandlingPolicy),
content::kWebRTCIPHandlingDisableNonProxiedUdp);

// Check SafeBrowsing status
EXPECT_FALSE(
tor_profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled));
tor_profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled));

// Check translate.enabled for translate bubble.
EXPECT_FALSE(
tor_profile->GetPrefs()->GetBoolean(prefs::kOfferTranslateEnabled));
}

// This is for tor guest window, remove it when we have persistent tor profiles
Expand Down

0 comments on commit fd9a928

Please sign in to comment.