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

Side by Side Diff: content/browser/mojo/mojo_shell_client_host.cc

Issue 1465793005: Pass CapabilityFilter via CreateInstanceForHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | mojo/application/public/interfaces/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/strings/stringprintf.h" 5 #include "base/strings/stringprintf.h"
6 #include "base/thread_task_runner_handle.h" 6 #include "base/thread_task_runner_handle.h"
7 #include "components/mus/public/interfaces/gpu.mojom.h"
7 #include "content/browser/mojo/mojo_shell_client_host.h" 8 #include "content/browser/mojo/mojo_shell_client_host.h"
8 #include "content/common/mojo/mojo_messages.h" 9 #include "content/common/mojo/mojo_messages.h"
9 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
10 #include "content/public/common/mojo_shell_connection.h" 11 #include "content/public/common/mojo_shell_connection.h"
11 #include "ipc/ipc_sender.h" 12 #include "ipc/ipc_sender.h"
12 #include "mojo/application/public/cpp/application_impl.h" 13 #include "mojo/application/public/cpp/application_impl.h"
14 #include "mojo/application/public/interfaces/application_manager.mojom.h"
13 #include "mojo/converters/network/network_type_converters.h" 15 #include "mojo/converters/network/network_type_converters.h"
14 #include "mojo/shell/application_manager.mojom.h"
15 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" 16 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
16 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" 17 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h"
17 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" 18 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h"
18 19
19 namespace content { 20 namespace content {
20 namespace { 21 namespace {
21 22
22 const char kMojoShellInstanceURL[] = "mojo_shell_instance_url"; 23 const char kMojoShellInstanceURL[] = "mojo_shell_instance_url";
23 24
24 void DidCreateChannel(mojo::embedder::ChannelInfo* info) {} 25 void DidCreateChannel(mojo::embedder::ChannelInfo* info) {}
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 "mojo:shell", &application_manager); 76 "mojo:shell", &application_manager);
76 // The content of the URL/qualifier we pass is actually meaningless, it's only 77 // The content of the URL/qualifier we pass is actually meaningless, it's only
77 // important that they're unique per process. 78 // important that they're unique per process.
78 // TODO(beng): We need to specify a restrictive CapabilityFilter here that 79 // TODO(beng): We need to specify a restrictive CapabilityFilter here that
79 // matches the needs of the target process. Figure out where that 80 // matches the needs of the target process. Figure out where that
80 // specification is best determined (not here, this is a common 81 // specification is best determined (not here, this is a common
81 // chokepoint for all process types) and how to wire it through. 82 // chokepoint for all process types) and how to wire it through.
82 // http://crbug.com/555393 83 // http://crbug.com/555393
83 std::string url = 84 std::string url =
84 base::StringPrintf("exe:chrome_renderer%d", child_process_id); 85 base::StringPrintf("exe:chrome_renderer%d", child_process_id);
86
87 mojo::CapabilityFilterPtr filter(mojo::CapabilityFilter::New());
88 mojo::Array<mojo::String> window_manager_interfaces;
89 window_manager_interfaces.push_back(mus::mojom::Gpu::Name_);
90 filter->filter.insert("mojo:mus", window_manager_interfaces.Pass());
85 application_manager->CreateInstanceForHandle( 91 application_manager->CreateInstanceForHandle(
86 mojo::ScopedHandle(mojo::Handle(handle.release().value())), url); 92 mojo::ScopedHandle(mojo::Handle(handle.release().value())),
93 url,
94 filter.Pass());
87 95
88 // Send the other end to the child via Chrome IPC. 96 // Send the other end to the child via Chrome IPC.
89 base::PlatformFile client_file = PlatformFileFromScopedPlatformHandle( 97 base::PlatformFile client_file = PlatformFileFromScopedPlatformHandle(
90 platform_channel_pair.PassClientHandle()); 98 platform_channel_pair.PassClientHandle());
91 render_process_host->Send(new MojoMsg_BindExternalMojoShellHandle( 99 render_process_host->Send(new MojoMsg_BindExternalMojoShellHandle(
92 IPC::GetFileHandleForProcess(client_file, process_handle, true))); 100 IPC::GetFileHandleForProcess(client_file, process_handle, true)));
93 101
94 // Store the URL on the RPH so client code can access it later via 102 // Store the URL on the RPH so client code can access it later via
95 // GetMojoApplicationInstanceURL(). 103 // GetMojoApplicationInstanceURL().
96 SetMojoApplicationInstanceURL(render_process_host, url); 104 SetMojoApplicationInstanceURL(render_process_host, url);
97 } 105 }
98 106
99 std::string GetMojoApplicationInstanceURL( 107 std::string GetMojoApplicationInstanceURL(
100 RenderProcessHost* render_process_host) { 108 RenderProcessHost* render_process_host) {
101 InstanceURL* instance_url = static_cast<InstanceURL*>( 109 InstanceURL* instance_url = static_cast<InstanceURL*>(
102 render_process_host->GetUserData(kMojoShellInstanceURL)); 110 render_process_host->GetUserData(kMojoShellInstanceURL));
103 return instance_url ? instance_url->get() : std::string(); 111 return instance_url ? instance_url->get() : std::string();
104 } 112 }
105 113
106 } // namespace content 114 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | mojo/application/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698