Chromium Code Reviews| 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 "content/browser/frame_host/frame_mojo_shell.h" | 5 #include "content/browser/frame_host/frame_mojo_shell.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "content/browser/mojo/mojo_shell_context.h" | 10 #include "content/browser/mojo/mojo_shell_context.h" |
| 11 #include "content/common/mojo/service_registry_impl.h" | |
| 12 #include "content/public/browser/content_browser_client.h" | 11 #include "content/public/browser/content_browser_client.h" |
| 13 #include "content/public/browser/render_frame_host.h" | 12 #include "content/public/browser/render_frame_host.h" |
| 14 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
| 15 #include "content/public/browser/site_instance.h" | 14 #include "content/public/browser/site_instance.h" |
| 16 #include "content/public/common/content_client.h" | 15 #include "content/public/common/content_client.h" |
| 16 #include "services/shell/public/cpp/interface_registry.h" | |
| 17 | 17 |
| 18 #if defined(OS_ANDROID) && defined(ENABLE_MOJO_CDM) | 18 #if defined(OS_ANDROID) && defined(ENABLE_MOJO_CDM) |
| 19 #include "content/browser/media/android/provision_fetcher_impl.h" | 19 #include "content/browser/media/android/provision_fetcher_impl.h" |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 void RegisterFrameMojoShellServices(ServiceRegistry* registry, | 26 void RegisterFrameMojoShellInterfaces(shell::InterfaceRegistry* registry, |
| 27 RenderFrameHost* render_frame_host) { | 27 RenderFrameHost* render_frame_host) { |
| 28 #if defined(OS_ANDROID) && defined(ENABLE_MOJO_CDM) | 28 #if defined(OS_ANDROID) && defined(ENABLE_MOJO_CDM) |
| 29 registry->AddService( | 29 registry->AddInterface( |
| 30 base::Bind(&ProvisionFetcherImpl::Create, render_frame_host)); | 30 base::Bind(&ProvisionFetcherImpl::Create, render_frame_host)); |
| 31 #endif | 31 #endif |
| 32 } | 32 } |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 FrameMojoShell::FrameMojoShell(RenderFrameHost* frame_host) | 36 FrameMojoShell::FrameMojoShell(RenderFrameHost* frame_host) |
| 37 : frame_host_(frame_host) { | 37 : frame_host_(frame_host) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 FrameMojoShell::~FrameMojoShell() { | 40 FrameMojoShell::~FrameMojoShell() { |
| 41 } | 41 } |
| 42 | 42 |
| 43 void FrameMojoShell::BindRequest(shell::mojom::ConnectorRequest request) { | 43 void FrameMojoShell::BindRequest(shell::mojom::ConnectorRequest request) { |
| 44 connectors_.AddBinding(this, std::move(request)); | 44 connectors_.AddBinding(this, std::move(request)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // TODO(xhwang): Currently no callers are exposing |exposed_services|. So we | 47 // TODO(xhwang): Currently no callers are exposing |exposed_interfaces|. So we |
| 48 // drop it and replace it with services we provide in the browser. In the | 48 // drop it and replace it with interfaces we provide in the browser. In the |
| 49 // future we may need to support both. | 49 // future we may need to support both. |
| 50 void FrameMojoShell::Connect( | 50 void FrameMojoShell::Connect( |
| 51 shell::mojom::IdentityPtr target, | 51 shell::mojom::IdentityPtr target, |
| 52 shell::mojom::InterfaceProviderRequest services, | 52 shell::mojom::InterfaceProviderRequest interfaces, |
| 53 shell::mojom::InterfaceProviderPtr /* exposed_services */, | 53 shell::mojom::InterfaceProviderPtr /* exposed_interfaces */, |
| 54 shell::mojom::ClientProcessConnectionPtr client_process_connection, | 54 shell::mojom::ClientProcessConnectionPtr client_process_connection, |
| 55 const shell::mojom::Connector::ConnectCallback& callback) { | 55 const shell::mojom::Connector::ConnectCallback& callback) { |
| 56 shell::mojom::InterfaceProviderPtr frame_services; | 56 shell::mojom::InterfaceProviderPtr frame_interfaces; |
| 57 service_provider_bindings_.AddBinding(GetServiceRegistry(), | 57 interface_provider_bindings_.AddBinding(GetInterfaceRegistry(), |
| 58 GetProxy(&frame_services)); | 58 GetProxy(&frame_interfaces)); |
| 59 MojoShellContext::ConnectToApplication( | 59 MojoShellContext::ConnectToApplication( |
| 60 shell::mojom::kRootUserID, target->name, | 60 shell::mojom::kRootUserID, target->name, |
| 61 frame_host_->GetSiteInstance()->GetSiteURL().spec(), std::move(services), | 61 frame_host_->GetSiteInstance()->GetSiteURL().spec(), |
| 62 std::move(frame_services), callback); | 62 std::move(interfaces), |
| 63 std::move(frame_interfaces), callback); | |
| 63 } | 64 } |
| 64 | 65 |
| 65 void FrameMojoShell::Clone(shell::mojom::ConnectorRequest request) { | 66 void FrameMojoShell::Clone(shell::mojom::ConnectorRequest request) { |
| 66 connectors_.AddBinding(this, std::move(request)); | 67 connectors_.AddBinding(this, std::move(request)); |
| 67 } | 68 } |
| 68 | 69 |
| 69 ServiceRegistryImpl* FrameMojoShell::GetServiceRegistry() { | 70 shell::InterfaceRegistry* FrameMojoShell::GetInterfaceRegistry() { |
| 70 if (!service_registry_) { | 71 if (!interface_registry_) { |
| 71 service_registry_.reset(new ServiceRegistryImpl()); | 72 // TODO(beng): find connection. |
|
Ken Rockot(use gerrit already)
2016/06/21 16:16:23
What does this mean?
| |
| 73 interface_registry_.reset(new shell::InterfaceRegistry(nullptr)); | |
| 72 | 74 |
| 73 // TODO(rockot/xhwang): Currently all applications connected share the same | 75 // TODO(rockot/xhwang): Currently all applications connected share the same |
| 74 // set of services registered in the |registry|. We may want to provide | 76 // set of interfaces registered in the |registry|. We may want to provide |
| 75 // different services for different apps for better isolation. | 77 // different interfaces for different apps for better isolation. |
| 76 RegisterFrameMojoShellServices(service_registry_.get(), frame_host_); | 78 RegisterFrameMojoShellInterfaces(interface_registry_.get(), frame_host_); |
| 77 GetContentClient()->browser()->RegisterFrameMojoShellServices( | 79 GetContentClient()->browser()->RegisterFrameMojoShellInterfaces( |
| 78 service_registry_.get(), frame_host_); | 80 interface_registry_.get(), frame_host_); |
| 79 } | 81 } |
| 80 | 82 |
| 81 return service_registry_.get(); | 83 return interface_registry_.get(); |
| 82 } | 84 } |
| 83 | 85 |
| 84 } // namespace content | 86 } // namespace content |
| OLD | NEW |