summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/mojo/mojo_shell_client_host.cc60
-rw-r--r--content/browser/mojo/mojo_shell_client_host.h10
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mus.cc5
-rw-r--r--mojo/shell/public/cpp/connector.h6
4 files changed, 39 insertions, 42 deletions
diff --git a/content/browser/mojo/mojo_shell_client_host.cc b/content/browser/mojo/mojo_shell_client_host.cc
index e762c22..b342ed7 100644
--- a/content/browser/mojo/mojo_shell_client_host.cc
+++ b/content/browser/mojo/mojo_shell_client_host.cc
@@ -25,26 +25,26 @@
namespace content {
namespace {
-const char kMojoShellInstanceURL[] = "mojo_shell_instance_url";
+const char kMojoShellInstanceIdentity[] = "mojo_shell_instance_identity";
-class InstanceURL : public base::SupportsUserData::Data {
+class InstanceIdentity : public base::SupportsUserData::Data {
public:
- explicit InstanceURL(const std::string& instance_url)
- : instance_url_(instance_url) {}
- ~InstanceURL() override {}
+ explicit InstanceIdentity(const mojo::Identity& identity)
+ : identity_(identity) {}
+ ~InstanceIdentity() override {}
- std::string get() const { return instance_url_; }
+ mojo::Identity get() const { return identity_; }
private:
- std::string instance_url_;
+ mojo::Identity identity_;
- DISALLOW_COPY_AND_ASSIGN(InstanceURL);
+ DISALLOW_COPY_AND_ASSIGN(InstanceIdentity);
};
-void SetMojoApplicationInstanceURL(RenderProcessHost* render_process_host,
- const std::string& instance_url) {
- render_process_host->SetUserData(kMojoShellInstanceURL,
- new InstanceURL(instance_url));
+void SetMojoIdentity(RenderProcessHost* render_process_host,
+ const mojo::Identity& identity) {
+ render_process_host->SetUserData(kMojoShellInstanceIdentity,
+ new InstanceIdentity(identity));
}
class PIDSender : public RenderProcessHostObserver {
@@ -105,16 +105,6 @@ std::string RegisterChildWithExternalShell(
MojoShellConnection::Get()->GetConnector()->ConnectToInterface(
"mojo:shell", &shell);
- // The content of the URL/qualifier we pass is actually meaningless, it's only
- // important that they're unique per process.
- // TODO(beng): We need to specify a restrictive CapabilityFilter here that
- // matches the needs of the target process. Figure out where that
- // specification is best determined (not here, this is a common
- // chokepoint for all process types) and how to wire it through.
- // http://crbug.com/555393
- std::string url = base::StringPrintf(
- "exe:chrome_renderer%d_%d", child_process_id, instance_id);
-
mojo::shell::mojom::PIDReceiverPtr pid_receiver;
mojo::InterfaceRequest<mojo::shell::mojom::PIDReceiver> request =
GetProxy(&pid_receiver);
@@ -124,26 +114,26 @@ std::string RegisterChildWithExternalShell(
factory.Bind(mojo::InterfacePtrInfo<mojo::shell::mojom::ShellClientFactory>(
std::move(request_pipe), 0u));
- mojo::shell::mojom::IdentityPtr target(mojo::shell::mojom::Identity::New());
- target->name = url;
- target->user_id = mojo::shell::mojom::kInheritUserID;
- target->instance = "";
- shell->CreateInstance(std::move(factory), std::move(target),
+ mojo::Identity target("exe:chrome_renderer",
+ mojo::shell::mojom::kInheritUserID,
+ base::StringPrintf("%d_%d", child_process_id,
+ instance_id));
+ shell->CreateInstance(std::move(factory),
+ mojo::shell::mojom::Identity::From(target),
CreateCapabilityFilterForRenderer(),
std::move(request), base::Bind(&OnConnectionComplete));
- // Store the URL on the RPH so client code can access it later via
- // GetMojoApplicationInstanceURL().
- SetMojoApplicationInstanceURL(render_process_host, url);
+ // Store the Identity on the RPH so client code can access it later via
+ // GetMojoIdentity().
+ SetMojoIdentity(render_process_host, target);
return pipe_token;
}
-std::string GetMojoApplicationInstanceURL(
- RenderProcessHost* render_process_host) {
- InstanceURL* instance_url = static_cast<InstanceURL*>(
- render_process_host->GetUserData(kMojoShellInstanceURL));
- return instance_url ? instance_url->get() : std::string();
+mojo::Identity GetMojoIdentity(RenderProcessHost* render_process_host) {
+ InstanceIdentity* instance_identity = static_cast<InstanceIdentity*>(
+ render_process_host->GetUserData(kMojoShellInstanceIdentity));
+ return instance_identity ? instance_identity->get() : mojo::Identity();
}
} // namespace content
diff --git a/content/browser/mojo/mojo_shell_client_host.h b/content/browser/mojo/mojo_shell_client_host.h
index 3b1484f..74aaf6c 100644
--- a/content/browser/mojo/mojo_shell_client_host.h
+++ b/content/browser/mojo/mojo_shell_client_host.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/process/process_handle.h"
+#include "mojo/shell/public/cpp/identity.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
namespace content {
@@ -28,11 +29,10 @@ std::string RegisterChildWithExternalShell(
int instance_id,
RenderProcessHost* render_process_host);
-// Returns the URL associated with an instance corresponding to the renderer
-// process in the external shell. This URL can be passed to
-// ConnectToApplication() to open a new connection to this renderer.
-std::string GetMojoApplicationInstanceURL(
- RenderProcessHost* render_process_host);
+// Returns the Identity associated with an instance corresponding to the
+// renderer process in shell. This Identity can be passed to Connect() to open a
+// new connection to this renderer.
+mojo::Identity GetMojoIdentity(RenderProcessHost* render_process_host);
// Constructs a Capability Filter for the renderer's application instance in the
// external shell. This contains the restrictions imposed on what applications
diff --git a/content/browser/renderer_host/render_widget_host_view_mus.cc b/content/browser/renderer_host/render_widget_host_view_mus.cc
index 9ddef3e..3157266 100644
--- a/content/browser/renderer_host/render_widget_host_view_mus.cc
+++ b/content/browser/renderer_host/render_widget_host_view_mus.cc
@@ -38,9 +38,10 @@ RenderWidgetHostViewMus::RenderWidgetHostViewMus(mus::Window* parent_window,
// Connect to the renderer, pass it a WindowTreeClient interface request
// and embed that client inside our mus window.
- std::string url = GetMojoApplicationInstanceURL(host_->GetProcess());
+ mojo::Identity identity = GetMojoIdentity(host_->GetProcess());
mojom::RenderWidgetWindowTreeClientFactoryPtr factory;
- MojoShellConnection::Get()->GetConnector()->ConnectToInterface(url, &factory);
+ MojoShellConnection::Get()->GetConnector()->ConnectToInterface(
+ identity, &factory);
mus::mojom::WindowTreeClientPtr window_tree_client;
factory->CreateWindowTreeClientForRenderWidget(
diff --git a/mojo/shell/public/cpp/connector.h b/mojo/shell/public/cpp/connector.h
index be6ba43..804eb03d 100644
--- a/mojo/shell/public/cpp/connector.h
+++ b/mojo/shell/public/cpp/connector.h
@@ -62,6 +62,12 @@ class Connector {
connection->GetInterface(ptr);
}
template <typename Interface>
+ void ConnectToInterface(const Identity& target,
+ InterfacePtr<Interface>* ptr) {
+ ConnectParams params(target);
+ return ConnectToInterface(&params, ptr);
+ }
+ template <typename Interface>
void ConnectToInterface(const std::string& name,
InterfacePtr<Interface>* ptr) {
ConnectParams params(name);