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" | 11 #include "content/common/mojo/service_registry_impl.h" |
| 12 #include "content/public/browser/browser_context.h" | |
| 12 #include "content/public/browser/content_browser_client.h" | 13 #include "content/public/browser/content_browser_client.h" |
| 13 #include "content/public/browser/render_frame_host.h" | 14 #include "content/public/browser/render_frame_host.h" |
| 15 #include "content/public/browser/render_process_host.h" | |
| 14 #include "content/public/browser/site_instance.h" | 16 #include "content/public/browser/site_instance.h" |
| 15 #include "content/public/common/content_client.h" | 17 #include "content/public/common/content_client.h" |
| 16 #include "mojo/common/url_type_converters.h" | 18 #include "mojo/common/url_type_converters.h" |
| 17 | 19 |
| 18 #if defined(OS_ANDROID) && defined(ENABLE_MOJO_CDM) | 20 #if defined(OS_ANDROID) && defined(ENABLE_MOJO_CDM) |
| 19 #include "content/browser/media/android/provision_fetcher_impl.h" | 21 #include "content/browser/media/android/provision_fetcher_impl.h" |
| 20 #endif | 22 #endif |
| 21 | 23 |
| 22 namespace content { | 24 namespace content { |
| 23 | 25 |
| 24 namespace { | 26 namespace { |
| 25 | 27 |
| 26 void RegisterFrameMojoShellServices(ServiceRegistry* registry, | 28 void RegisterFrameMojoShellServices(ServiceRegistry* registry, |
| 27 RenderFrameHost* render_frame_host) { | 29 RenderFrameHost* render_frame_host) { |
| 28 #if defined(OS_ANDROID) && defined(ENABLE_MOJO_CDM) | 30 #if defined(OS_ANDROID) && defined(ENABLE_MOJO_CDM) |
| 29 registry->AddService( | 31 registry->AddService( |
| 30 base::Bind(&ProvisionFetcherImpl::Create, render_frame_host)); | 32 base::Bind(&ProvisionFetcherImpl::Create, render_frame_host)); |
| 31 #endif | 33 #endif |
| 32 } | 34 } |
| 33 | 35 |
| 34 } // namespace | 36 } // namespace |
| 35 | 37 |
| 36 FrameMojoShell::FrameMojoShell(RenderFrameHost* frame_host) | 38 FrameMojoShell::FrameMojoShell(RenderFrameHost* frame_host) |
| 37 : frame_host_(frame_host) { | 39 : frame_host_(frame_host), |
| 40 mojo_user_id_(BrowserContext::GetMojoUserIdFor( | |
|
Ben Goodger (Google)
2016/03/14 22:25:57
do you need to do this here or can you just wait u
Elliot Glaysher
2016/03/14 23:14:53
Done.
| |
| 41 frame_host->GetProcess()->GetBrowserContext())) { | |
| 38 } | 42 } |
| 39 | 43 |
| 40 FrameMojoShell::~FrameMojoShell() { | 44 FrameMojoShell::~FrameMojoShell() { |
| 41 } | 45 } |
| 42 | 46 |
| 43 void FrameMojoShell::BindRequest(mojo::shell::mojom::ConnectorRequest request) { | 47 void FrameMojoShell::BindRequest(mojo::shell::mojom::ConnectorRequest request) { |
| 44 connectors_.AddBinding(this, std::move(request)); | 48 connectors_.AddBinding(this, std::move(request)); |
| 45 } | 49 } |
| 46 | 50 |
| 47 // TODO(xhwang): Currently no callers are exposing |exposed_services|. So we | 51 // TODO(xhwang): Currently no callers are exposing |exposed_services|. So we |
| 48 // drop it and replace it with services we provide in the browser. In the | 52 // drop it and replace it with services we provide in the browser. In the |
| 49 // future we may need to support both. | 53 // future we may need to support both. |
| 50 void FrameMojoShell::Connect( | 54 void FrameMojoShell::Connect( |
| 51 mojo::shell::mojom::IdentityPtr target, | 55 mojo::shell::mojom::IdentityPtr target, |
| 52 mojo::shell::mojom::InterfaceProviderRequest services, | 56 mojo::shell::mojom::InterfaceProviderRequest services, |
| 53 mojo::shell::mojom::InterfaceProviderPtr /* exposed_services */, | 57 mojo::shell::mojom::InterfaceProviderPtr /* exposed_services */, |
| 54 mojo::shell::mojom::ClientProcessConnectionPtr client_process_connection, | 58 mojo::shell::mojom::ClientProcessConnectionPtr client_process_connection, |
| 55 const mojo::shell::mojom::Connector::ConnectCallback& callback) { | 59 const mojo::shell::mojom::Connector::ConnectCallback& callback) { |
| 56 // TODO(beng): user_id is dropped on the floor right now. Figure out what to | |
| 57 // do with it. | |
| 58 mojo::shell::mojom::InterfaceProviderPtr frame_services; | 60 mojo::shell::mojom::InterfaceProviderPtr frame_services; |
| 59 service_provider_bindings_.AddBinding(GetServiceRegistry(), | 61 service_provider_bindings_.AddBinding(GetServiceRegistry(), |
| 60 GetProxy(&frame_services)); | 62 GetProxy(&frame_services)); |
| 61 | 63 |
| 62 MojoShellContext::ConnectToApplication( | 64 MojoShellContext::ConnectToApplication( |
| 63 target->name, | 65 mojo_user_id_, target->name, |
|
Elliot Glaysher
2016/03/14 20:33:20
We can't pass kInheritUser here since we're callin
| |
| 64 frame_host_->GetSiteInstance()->GetSiteURL().spec(), std::move(services), | 66 frame_host_->GetSiteInstance()->GetSiteURL().spec(), std::move(services), |
| 65 std::move(frame_services), callback); | 67 std::move(frame_services), callback); |
| 66 } | 68 } |
| 67 | 69 |
| 68 void FrameMojoShell::Clone(mojo::shell::mojom::ConnectorRequest request) { | 70 void FrameMojoShell::Clone(mojo::shell::mojom::ConnectorRequest request) { |
| 69 connectors_.AddBinding(this, std::move(request)); | 71 connectors_.AddBinding(this, std::move(request)); |
| 70 } | 72 } |
| 71 | 73 |
| 72 ServiceRegistryImpl* FrameMojoShell::GetServiceRegistry() { | 74 ServiceRegistryImpl* FrameMojoShell::GetServiceRegistry() { |
| 73 if (!service_registry_) { | 75 if (!service_registry_) { |
| 74 service_registry_.reset(new ServiceRegistryImpl()); | 76 service_registry_.reset(new ServiceRegistryImpl()); |
| 75 | 77 |
| 76 // TODO(rockot/xhwang): Currently all applications connected share the same | 78 // TODO(rockot/xhwang): Currently all applications connected share the same |
| 77 // set of services registered in the |registry|. We may want to provide | 79 // set of services registered in the |registry|. We may want to provide |
| 78 // different services for different apps for better isolation. | 80 // different services for different apps for better isolation. |
| 79 RegisterFrameMojoShellServices(service_registry_.get(), frame_host_); | 81 RegisterFrameMojoShellServices(service_registry_.get(), frame_host_); |
| 80 GetContentClient()->browser()->RegisterFrameMojoShellServices( | 82 GetContentClient()->browser()->RegisterFrameMojoShellServices( |
| 81 service_registry_.get(), frame_host_); | 83 service_registry_.get(), frame_host_); |
| 82 } | 84 } |
| 83 | 85 |
| 84 return service_registry_.get(); | 86 return service_registry_.get(); |
| 85 } | 87 } |
| 86 | 88 |
| 87 } // namespace content | 89 } // namespace content |
| OLD | NEW |