Skip to content

Commit

Permalink
Add tor launcher utility service
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdh committed Sep 13, 2018
1 parent bd991fd commit a3d7571
Show file tree
Hide file tree
Showing 17 changed files with 490 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/brave_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,9 @@ Please check your email at <ph name="ACCOUNT_EMAIL">$2<ex>jane.doe@example.com</
Close
</message>
</if>
<message name="IDS_UTILITY_PROCESS_TOR_LAUNCHER_NAME" desc="The utility process which launch Tor">
Tor Launcher
</message>
</messages>
</release>
</grit>
2 changes: 2 additions & 0 deletions browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ source_set("browser") {

deps = [
"autoplay",
"//base",
"//brave/components/brave_shields/browser:brave_shields",
"//brave/components/resources:brave_components_resources_grit",
"//brave/browser/resources:brave_extension_grit",
Expand All @@ -113,6 +114,7 @@ source_set("browser") {
"tor",
"net",
"permissions",
"//ui/base",
]

if (is_mac) {
Expand Down
11 changes: 11 additions & 0 deletions browser/brave_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@

#include "brave/browser/brave_content_browser_client.h"

#include "base/bind.h"
#include "brave/browser/brave_browser_main_extra_parts.h"
#include "brave/common/webui_url_constants.h"
#include "brave/common/tor/tor_launcher.mojom.h"
#include "brave/components/brave_shields/browser/brave_shields_web_contents_observer.h"
#include "brave/components/brave_webtorrent/browser/content_browser_client_helper.h"
#include "brave/components/content_settings/core/browser/brave_cookie_settings.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/profiles/profile_io_data.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browser_url_handler.h"
#include "ui/base/l10n/l10n_util.h"

using content::BrowserThread;
using content::RenderFrameHost;
Expand Down Expand Up @@ -172,3 +176,10 @@ bool BraveContentBrowserClient::AllowSetCookie(
first_party, cookie, !allow));
return allow;
}

void BraveContentBrowserClient::RegisterOutOfProcessServices(
OutOfProcessServiceMap* services) {
ChromeContentBrowserClient::RegisterOutOfProcessServices(services);
(*services)[tor::mojom::kTorLauncherServiceName] = base::BindRepeating(
l10n_util::GetStringUTF16, IDS_UTILITY_PROCESS_TOR_LAUNCHER_NAME);
}
3 changes: 3 additions & 0 deletions browser/brave_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class BraveContentBrowserClient : public ChromeContentBrowserClient {
const url::Origin& requesting_origin,
const url::Origin& embedding_origin) override;

void RegisterOutOfProcessServices(
OutOfProcessServiceMap* services) override;

private:
DISALLOW_COPY_AND_ASSIGN(BraveContentBrowserClient);
};
Expand Down
5 changes: 4 additions & 1 deletion browser/tor/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import("//build/config/features.gni")
# 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/.

source_set("tor") {
sources = [
Expand All @@ -18,6 +20,7 @@ source_set("tor") {
deps = [
"//base",
"//brave/common/tor",
"//brave/utility/tor",
"//components/keyed_service/content",
"//components/keyed_service/core",
# for profile.h
Expand Down
3 changes: 1 addition & 2 deletions common/tor/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# 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/.

import("//build/config/features.gni")
import("//mojo/public/tools/bindings/mojom.gni")

source_set("tor") {
Expand All @@ -15,13 +14,13 @@ source_set("tor") {
"//base",
"//chrome/common:constants",
"//url:url",
":tor_mojom_bindings",
]
}

mojom("tor_mojom_bindings") {
sources = [
"tor_config.mojom",
"tor_launcher.mojom",
]
public_deps = [
"//mojo/public/mojom/base",
Expand Down
18 changes: 18 additions & 0 deletions common/tor/tor_launcher.mojom
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/.

module tor.mojom;

import "brave/common/tor/tor_config.mojom";

const string kTorLauncherServiceName = "tor_launcher";

interface TorLauncher {
Launch(tor.mojom.TorConfig config) => (bool result, int64 pid);

ReLaunch(tor.mojom.TorConfig config) => (bool result, int64 pid);

SetCrashHandler() => (int64 pid);
};

10 changes: 9 additions & 1 deletion patches/chrome-app-BUILD.gn.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/chrome/app/BUILD.gn b/chrome/app/BUILD.gn
index cb79befb803ef7331e1908903bc7339cefa58d50..01472659b7625cac5f436cb22b985ed26e671b39 100644
index cb79befb803ef7331e1908903bc7339cefa58d50..fa0e720ba58d762b7f7c90534130f84d9ee22491 100644
--- a/chrome/app/BUILD.gn
+++ b/chrome/app/BUILD.gn
@@ -251,7 +251,7 @@ grit("google_chrome_strings") {
Expand All @@ -11,3 +11,11 @@ index cb79befb803ef7331e1908903bc7339cefa58d50..01472659b7625cac5f436cb22b985ed2
defines = chrome_grit_defines
output_dir = "$root_gen_dir/chrome"
outputs = [
@@ -464,6 +464,7 @@ service_manifest("chrome_content_packaged_services_manifest_overlay") {
"//ui/accessibility:manifest",
]
}
+ packaged_services += [ "//brave/utility/tor:tor_launcher_manifest" ]
}

# Per-profile services.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/chrome/browser/chrome_content_browser_manifest_overlay.json b/chrome/browser/chrome_content_browser_manifest_overlay.json
index 3425d64746dfd37466b8544e1650f5c60fa20125..7294bcd1e903d3076e048b74603c47cbd5ff2d17 100644
--- a/chrome/browser/chrome_content_browser_manifest_overlay.json
+++ b/chrome/browser/chrome_content_browser_manifest_overlay.json
@@ -64,6 +64,7 @@
"removable_storage_writer": [ "removable_storage_writer" ],
"secure_channel": [ "secure_channel" ],
"shortcut_viewer_app": [ "shortcut_viewer" ],
+ "tor_launcher": [ "tor_launcher" ],
"ui": [
"ime_registrar",
"input_device_controller",
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/chrome/browser/chrome_content_utility_manifest_overlay.json b/chrome/browser/chrome_content_utility_manifest_overlay.json
index 03d7cd6b486001765096df3bfe95624fd2700c42..a5dbd36e97f36417b861c41a2bfb201a8640aba2 100644
--- a/chrome/browser/chrome_content_utility_manifest_overlay.json
+++ b/chrome/browser/chrome_content_utility_manifest_overlay.json
@@ -10,6 +10,7 @@
"payments.mojom.PaymentManifestParser",
"heap_profiling.mojom.ProfilingClient",
"proxy_resolver.mojom.ProxyResolverFactory",
+ "tor.mojom.TorLauncher",
"safe_json.mojom.SafeJsonParser"
]
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
diff --git a/mojo/public/tools/bindings/chromium_bindings_configuration.gni b/mojo/public/tools/bindings/chromium_bindings_configuration.gni
index 1893db1ac954c0fa065a2a8dcc22367ebd298ff4..eb0a01da5c6c67e89335ac3b2563d8317a4e4100 100644
index 5c3c59f7926bc12df1381823b8f91d2d885fafe5..21a5e76e760d27782d1d1076702774bab6ad453d 100644
--- a/mojo/public/tools/bindings/chromium_bindings_configuration.gni
+++ b/mojo/public/tools/bindings/chromium_bindings_configuration.gni
@@ -4,6 +4,7 @@

_typemap_imports = [
"//ash/public/interfaces/typemaps.gni",
+ "//brave/common/tor/typemaps.gni",
"//chrome/chrome_cleaner/interfaces/typemaps/typemaps.gni",
"//chrome/common/extensions/typemaps.gni",
"//chrome/common/importer/typemaps.gni",
"//chrome/common/media_router/mojo/typemaps.gni",
26 changes: 26 additions & 0 deletions utility/tor/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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/.

import("//services/service_manager/public/service_manifest.gni")

source_set("tor") {
sources = [
"tor_launcher_impl.cc",
"tor_launcher_impl.h",
"tor_launcher_service.cc",
"tor_launcher_service.h",
]

deps = [
"//base",
"//brave/common/tor",
"//brave/common/tor:tor_mojom_bindings",
"//services/service_manager",
]
}

service_manifest("tor_launcher_manifest") {
name = "tor_launcher"
source = "tor_launcher_manifest.json"
}
Loading

0 comments on commit a3d7571

Please sign in to comment.