Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network service tor - 0.68.x #2920

Merged
merged 2 commits into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/brave_command_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#define IDC_BRAVE_COMMANDS_START 56000
#define IDC_SHOW_BRAVE_REWARDS 56000
#define IDC_SHOW_BRAVE_ADBLOCK 56001
#define IDC_NEW_TOR_IDENTITY 56002
#define IDC_NEW_TOR_CONNECTION_FOR_SITE 56002
#define IDC_NEW_OFFTHERECORD_WINDOW_TOR 56003
#define IDC_CONTENT_CONTEXT_OPENLINKTOR 56004
#define IDC_SHOW_BRAVE_SYNC 56005
Expand Down
3 changes: 3 additions & 0 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
<message name="IDS_NEW_TOR_IDENTITY" desc="The text label of a menu item for requesting new Tor identity">
New Tor Identity
</message>
<message name="IDS_NEW_TOR_CONNECTION_FOR_SITE" desc="The text label of a menu item for requesting new Tor connection for the current site">
New Tor Connection For This Site
</message>
<message name="IDS_PROFILES_EXIT_TOR" desc="Button in the avatar menu bubble view for exiting the active Tor session.">
Exit Tor
</message>
Expand Down
1 change: 1 addition & 0 deletions browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ source_set("browser_process") {
"//components/autofill/core/common",
"//components/browsing_data/core",
"//components/component_updater",
"//components/content_settings/core/common",
"//components/password_manager/core/common",
"//components/prefs",
"//components/safe_browsing/common:safe_browsing_prefs",
Expand Down
15 changes: 0 additions & 15 deletions browser/brave_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "brave/browser/brave_browser_main_extra_parts.h"
#include "brave/browser/brave_browser_process_impl.h"
#include "brave/browser/extensions/brave_tor_client_updater.h"
#include "brave/browser/renderer_host/brave_navigation_ui_data.h"
#include "brave/browser/tor/buildflags.h"
#include "brave/common/brave_cookie_blocking.h"
#include "brave/common/tor/switches.h"
Expand Down Expand Up @@ -260,20 +259,6 @@ void BraveContentBrowserClient::RegisterOutOfProcessServices(
#endif
}

std::unique_ptr<content::NavigationUIData>
BraveContentBrowserClient::GetNavigationUIData(
content::NavigationHandle* navigation_handle) {
std::unique_ptr<BraveNavigationUIData> navigation_ui_data =
std::make_unique<BraveNavigationUIData>(navigation_handle);
#if BUILDFLAG(ENABLE_TOR)
Profile* profile = Profile::FromBrowserContext(
navigation_handle->GetWebContents()->GetBrowserContext());
TorProfileServiceFactory::SetTorNavigationUIData(profile,
navigation_ui_data.get());
#endif
return std::move(navigation_ui_data);
}

base::Optional<service_manager::Manifest>
BraveContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
auto manifest = ChromeContentBrowserClient::GetServiceManifestOverlay(name);
Expand Down
2 changes: 0 additions & 2 deletions browser/brave_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ class BraveContentBrowserClient : public ChromeContentBrowserClient {
base::Optional<service_manager::Manifest> GetServiceManifestOverlay(
base::StringPiece name) override;

std::unique_ptr<content::NavigationUIData> GetNavigationUIData(
content::NavigationHandle* navigation_handle) override;
void AdjustUtilityServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) override;
Expand Down
8 changes: 7 additions & 1 deletion browser/brave_local_state_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "base/values.h"
#include "brave/browser/brave_stats_updater.h"
#include "brave/browser/metrics/metrics_reporting_util.h"
#include "brave/browser/tor/tor_profile_service.h"
#include "brave/browser/tor/buildflags.h"
#include "brave/components/brave_referrals/buildflags/buildflags.h"
#include "brave/components/brave_shields/browser/ad_block_service.h"
#include "chrome/browser/first_run/first_run.h"
Expand All @@ -20,6 +20,10 @@
#include "brave/components/brave_referrals/browser/brave_referrals_service.h"
#endif

#if BUILDFLAG(ENABLE_TOR)
#include "brave/browser/tor/tor_profile_service.h"
#endif

namespace brave {

void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
Expand All @@ -33,7 +37,9 @@ void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
registry->SetDefaultPrefValue(prefs::kConfirmToQuitEnabled,
base::Value(false));
#endif
#if BUILDFLAG(ENABLE_TOR)
tor::TorProfileService::RegisterLocalStatePrefs(registry);
#endif
#if !defined(OS_ANDROID)
RegisterPrefsForMuonMigration(registry);
#endif
Expand Down
17 changes: 15 additions & 2 deletions browser/brave_profile_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#include "brave/browser/brave_profile_prefs.h"

#include "brave/browser/themes/brave_theme_service.h"
#include "brave/browser/tor/tor_profile_service.h"
#include "brave/browser/tor/buildflags.h"
#include "brave/common/pref_names.h"
#include "brave/components/brave_rewards/browser/rewards_service.h"
#include "brave/components/brave_shields/browser/brave_shields_web_contents_observer.h"
#include "brave/components/brave_webtorrent/browser/buildflags/buildflags.h"
#include "chrome/browser/net/prediction_options.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/common/pref_names.h"
Expand All @@ -25,6 +26,14 @@
#include "brave/browser/widevine/brave_widevine_bundle_manager.h"
#endif

#if BUILDFLAG(ENABLE_BRAVE_WEBTORRENT)
#include "brave/components/brave_webtorrent/browser/webtorrent_util.h"
#endif

#if BUILDFLAG(ENABLE_TOR)
#include "brave/browser/tor/tor_profile_service.h"
#endif

namespace brave {

void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
Expand All @@ -39,7 +48,9 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(kLocationBarIsWide, false);
registry->RegisterBooleanPref(kHideBraveRewardsButton, false);

#if BUILDFLAG(ENABLE_TOR)
tor::TorProfileService::RegisterProfilePrefs(registry);
#endif

registry->RegisterBooleanPref(kWidevineOptedIn, false);
#if BUILDFLAG(BUNDLE_WIDEVINE_CDM)
Expand All @@ -56,7 +67,9 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(kLinkedInEmbedControlType, false);

// WebTorrent
registry->RegisterBooleanPref(kWebTorrentEnabled, true);
#if BUILDFLAG(ENABLE_BRAVE_WEBTORRENT)
webtorrent::RegisterProfilePrefs(registry);
#endif

// Hangouts
registry->RegisterBooleanPref(kHangoutsEnabled, true);
Expand Down
8 changes: 7 additions & 1 deletion browser/extensions/brave_extension_management.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@

#include "base/command_line.h"
#include "brave/browser/brave_browser_process_impl.h"
#include "brave/browser/tor/buildflags.h"
#include "brave/common/brave_switches.h"
#include "brave/common/extensions/extension_constants.h"
#include "brave/common/pref_names.h"
#include "brave/browser/extensions/brave_extension_provider.h"
#include "brave/browser/extensions/brave_tor_client_updater.h"
#include "chrome/browser/extensions/external_policy_loader.h"
#include "chrome/browser/profiles/profile.h"
#include "components/prefs/pref_service.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_urls.h"

#if BUILDFLAG(ENABLE_TOR)
#include "brave/browser/extensions/brave_tor_client_updater.h"
#endif

namespace extensions {

BraveExtensionManagement::BraveExtensionManagement(Profile* profile)
Expand All @@ -37,10 +41,12 @@ BraveExtensionManagement::~BraveExtensionManagement() {
}

void BraveExtensionManagement::RegisterBraveExtensions() {
#if BUILDFLAG(ENABLE_TOR)
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (!command_line.HasSwitch(switches::kDisableTorClientUpdaterExtension))
g_brave_browser_process->tor_client_updater()->Register();
#endif
}

void BraveExtensionManagement::OnExtensionLoaded(
Expand Down
31 changes: 18 additions & 13 deletions browser/geolocation/brave_geolocation_permission_context.cc
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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 "brave/browser/geolocation/brave_geolocation_permission_context.h"

#include "chrome/browser/profiles/profile.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/prefs/pref_service.h"
#include "brave/common/tor/pref_names.h"

BraveGeolocationPermissionContext::BraveGeolocationPermissionContext(
Profile* profile) : GeolocationPermissionContext(profile) {
Profile* profile) : GeolocationPermissionContext(profile) {
}

BraveGeolocationPermissionContext::~BraveGeolocationPermissionContext() {
}

void BraveGeolocationPermissionContext::DecidePermission(
content::WebContents* web_contents,
const PermissionRequestID& id,
const GURL& requesting_origin,
const GURL& embedding_origin,
bool user_gesture,
const BrowserPermissionCallback& callback) {

PrefService* prefs = profile()->GetPrefs();
if (prefs->HasPrefPath(tor::prefs::kProfileUsingTor) &&
prefs->GetBoolean(tor::prefs::kProfileUsingTor)) {
content::WebContents* web_contents,
const PermissionRequestID& id,
const GURL& requesting_origin,
const GURL& embedding_origin,
bool user_gesture,
const BrowserPermissionCallback& callback) {
if (profile()->IsTorProfile()) {
callback.Run(ContentSetting::CONTENT_SETTING_BLOCK);
return;
}

return GeolocationPermissionContext::DecidePermission(web_contents, id, requesting_origin, embedding_origin, user_gesture, callback);
return GeolocationPermissionContext::DecidePermission(web_contents,
id,
requesting_origin,
embedding_origin,
user_gesture,
callback);
}
8 changes: 0 additions & 8 deletions browser/net/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import("//brave/browser/tor/buildflags/buildflags.gni")
import("//brave/browser/translate/buildflags/buildflags.gni")
import("//brave/components/brave_referrals/buildflags/buildflags.gni")
import("//brave/components/brave_webtorrent/browser/buildflags/buildflags.gni")
Expand Down Expand Up @@ -60,13 +59,6 @@ source_set("net") {
]
}

if (enable_tor) {
sources += [
"brave_tor_network_delegate_helper.cc",
"brave_tor_network_delegate_helper.h",
]
}

if (enable_brave_webtorrent) {
deps += [
"//brave/components/brave_webtorrent/browser/net",
Expand Down
10 changes: 0 additions & 10 deletions browser/net/brave_profile_network_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "brave/browser/net/cookie_network_delegate_helper.h"
#include "brave/browser/net/brave_httpse_network_delegate_helper.h"
#include "brave/browser/net/brave_site_hacks_network_delegate_helper.h"
#include "brave/browser/tor/buildflags.h"
#include "brave/browser/translate/buildflags/buildflags.h"
#include "brave/common/pref_names.h"
#include "brave/components/brave_referrals/buildflags/buildflags.h"
Expand All @@ -27,10 +26,6 @@
#include "brave/components/brave_rewards/browser/net/network_delegate_helper.h"
#endif

#if BUILDFLAG(ENABLE_TOR)
#include "brave/browser/net/brave_tor_network_delegate_helper.h"
#endif

#if BUILDFLAG(ENABLE_BRAVE_WEBTORRENT)
#include "brave/components/brave_webtorrent/browser/net/brave_torrent_redirect_network_delegate_helper.h"
#endif
Expand Down Expand Up @@ -64,11 +59,6 @@ BraveProfileNetworkDelegate::BraveProfileNetworkDelegate(
before_url_request_callbacks_.push_back(callback);
#endif

#if BUILDFLAG(ENABLE_TOR)
callback = base::Bind(brave::OnBeforeURLRequest_TorWork);
before_url_request_callbacks_.push_back(callback);
#endif

#if BUILDFLAG(ENABLE_BRAVE_TRANSLATE)
callback = base::BindRepeating(
brave::OnBeforeURLRequest_TranslateRedirectWork);
Expand Down
60 changes: 0 additions & 60 deletions browser/net/brave_tor_network_delegate_helper.cc

This file was deleted.

20 changes: 0 additions & 20 deletions browser/net/brave_tor_network_delegate_helper.h

This file was deleted.

Loading