Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1337)

Unified Diff: content/child/child_thread_impl.cc

Issue 2183703005: Renderers should obtain browser InterfaceProvider by connecting to browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/child/child_thread_impl.cc
diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc
index 8be6e48be0b89dbfa3733852a1c5732cc673b5b4..4adfd772d9d6080d5d811355e3ae0934918b8c04 100644
--- a/content/child/child_thread_impl.cc
+++ b/content/child/child_thread_impl.cc
@@ -68,6 +68,7 @@
#include "mojo/edk/embedder/named_platform_channel_pair.h"
#include "mojo/edk/embedder/platform_channel_pair.h"
#include "mojo/edk/embedder/scoped_ipc_support.h"
+#include "services/shell/public/cpp/connector.h"
#include "services/shell/public/cpp/interface_provider.h"
#include "services/shell/public/cpp/interface_registry.h"
#include "services/shell/runner/common/client_util.h"
@@ -266,7 +267,8 @@ ChildThreadImpl::Options::Options()
switches::kProcessChannelID)),
use_mojo_channel(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kMojoChannelToken)),
- auto_start_mojo_shell_connection(true) {
+ auto_start_mojo_shell_connection(true),
+ connect_to_browser(false) {
}
ChildThreadImpl::Options::Options(const Options& other) = default;
@@ -301,6 +303,13 @@ ChildThreadImpl::Options::Builder::AutoStartMojoShellConnection(
}
ChildThreadImpl::Options::Builder&
+ChildThreadImpl::Options::Builder::ConnectToBrowser(
+ bool connect_to_browser) {
+ options_.connect_to_browser = connect_to_browser;
+ return *this;
+}
+
+ChildThreadImpl::Options::Builder&
ChildThreadImpl::Options::Builder::WithChannelName(
const std::string& channel_name) {
options_.channel_name = channel_name;
@@ -432,12 +441,24 @@ void ChildThreadImpl::Init(const Options& options) {
mojo::MakeRequest<shell::mojom::Service>(std::move(handle)),
GetIOTaskRunner());
+ // When connect_to_browser_ is true, we obtain interfaces from the browser
+ // process by connecting to it, rather than from the incoming interface
+ // provider. Exposed interfaces are subject to manifest capability spec.
+ connect_to_browser_ = options.connect_to_browser;
+ shell::InterfaceProvider* remote_interfaces = nullptr;
+ if (connect_to_browser_) {
+ browser_connection_ = mojo_shell_connection_->GetConnector()->Connect(
+ "exe:content_browser");
Ken Rockot(use gerrit already) 2016/07/29 17:09:46 We should really move content/browser/mojo/constan
+ } else {
+ remote_interfaces = GetRemoteInterfaces();
+ }
+
// TODO(rockot): Remove this once all child-to-browser interface connections
// are made via a Connector rather than directly through an
// InterfaceProvider, and all exposed interfaces are exposed via a
// ConnectionFilter.
mojo_shell_connection_->SetupInterfaceRequestProxies(
- GetInterfaceRegistry(), GetRemoteInterfaces());
+ GetInterfaceRegistry(), remote_interfaces);
if (options.auto_start_mojo_shell_connection)
StartMojoShellConnection();
@@ -626,6 +647,9 @@ shell::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistry() {
}
shell::InterfaceProvider* ChildThreadImpl::GetRemoteInterfaces() {
+ if (connect_to_browser_)
Ken Rockot(use gerrit already) 2016/07/29 17:09:46 Or you could get rid of connect_to_browser_ as a m
+ return browser_connection_->GetRemoteInterfaces();
+
if (!remote_interfaces_.get())
remote_interfaces_.reset(new shell::InterfaceProvider);
return remote_interfaces_.get();

Powered by Google App Engine
This is Rietveld 408576698