| OLD | NEW |
| 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 "content/browser/mojo/mojo_shell_client_host.h" | 7 #include "content/browser/mojo/mojo_shell_client_host.h" |
| 8 #include "content/common/mojo/mojo_messages.h" | 8 #include "content/common/mojo/mojo_messages.h" |
| 9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
| 10 #include "content/public/common/mojo_shell_connection.h" | 10 #include "content/public/common/mojo_shell_connection.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 mojo::embedder::PlatformChannelPair platform_channel_pair; | 65 mojo::embedder::PlatformChannelPair platform_channel_pair; |
| 66 | 66 |
| 67 // Give one end to the shell so that it can create an instance. | 67 // Give one end to the shell so that it can create an instance. |
| 68 mojo::embedder::ScopedPlatformHandle platform_channel = | 68 mojo::embedder::ScopedPlatformHandle platform_channel = |
| 69 platform_channel_pair.PassServerHandle(); | 69 platform_channel_pair.PassServerHandle(); |
| 70 mojo::ScopedMessagePipeHandle handle(mojo::embedder::CreateChannel( | 70 mojo::ScopedMessagePipeHandle handle(mojo::embedder::CreateChannel( |
| 71 platform_channel.Pass(), base::Bind(&DidCreateChannel), | 71 platform_channel.Pass(), base::Bind(&DidCreateChannel), |
| 72 base::ThreadTaskRunnerHandle::Get())); | 72 base::ThreadTaskRunnerHandle::Get())); |
| 73 mojo::shell::mojom::ApplicationManagerPtr application_manager; | 73 mojo::shell::mojom::ApplicationManagerPtr application_manager; |
| 74 MojoShellConnection::Get()->GetApplication()->ConnectToService( | 74 MojoShellConnection::Get()->GetApplication()->ConnectToService( |
| 75 mojo::URLRequest::From(std::string("mojo:shell")), | 75 "mojo:shell", &application_manager); |
| 76 &application_manager); | |
| 77 // The content of the URL/qualifier we pass is actually meaningless, it's only | 76 // The content of the URL/qualifier we pass is actually meaningless, it's only |
| 78 // important that they're unique per process. | 77 // important that they're unique per process. |
| 79 // TODO(beng): We need to specify a restrictive CapabilityFilter here that | 78 // TODO(beng): We need to specify a restrictive CapabilityFilter here that |
| 80 // matches the needs of the target process. Figure out where that | 79 // matches the needs of the target process. Figure out where that |
| 81 // specification is best determined (not here, this is a common | 80 // specification is best determined (not here, this is a common |
| 82 // chokepoint for all process types) and how to wire it through. | 81 // chokepoint for all process types) and how to wire it through. |
| 83 // http://crbug.com/555393 | 82 // http://crbug.com/555393 |
| 84 std::string url = | 83 std::string url = |
| 85 base::StringPrintf("exe:chrome_renderer%d", child_process_id); | 84 base::StringPrintf("exe:chrome_renderer%d", child_process_id); |
| 86 application_manager->CreateInstanceForHandle( | 85 application_manager->CreateInstanceForHandle( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 98 } | 97 } |
| 99 | 98 |
| 100 std::string GetMojoApplicationInstanceURL( | 99 std::string GetMojoApplicationInstanceURL( |
| 101 RenderProcessHost* render_process_host) { | 100 RenderProcessHost* render_process_host) { |
| 102 InstanceURL* instance_url = static_cast<InstanceURL*>( | 101 InstanceURL* instance_url = static_cast<InstanceURL*>( |
| 103 render_process_host->GetUserData(kMojoShellInstanceURL)); | 102 render_process_host->GetUserData(kMojoShellInstanceURL)); |
| 104 return instance_url ? instance_url->get() : std::string(); | 103 return instance_url ? instance_url->get() : std::string(); |
| 105 } | 104 } |
| 106 | 105 |
| 107 } // namespace content | 106 } // namespace content |
| OLD | NEW |