Chromium Code Reviews| Index: content/browser/frame_host/frame_mojo_shell.cc |
| diff --git a/content/browser/frame_host/frame_mojo_shell.cc b/content/browser/frame_host/frame_mojo_shell.cc |
| index 6823931ea20f0a1285b4b56b52168e826f34fcbb..1e4c9ee6682dddb43ed1005d2c07e715282396a2 100644 |
| --- a/content/browser/frame_host/frame_mojo_shell.cc |
| +++ b/content/browser/frame_host/frame_mojo_shell.cc |
| @@ -5,11 +5,42 @@ |
| #include "content/browser/frame_host/frame_mojo_shell.h" |
| #include "content/browser/mojo/mojo_shell_context.h" |
| +#include "content/common/mojo/service_registry_impl.h" |
| +#include "content/public/browser/content_browser_client.h" |
| #include "content/public/browser/render_frame_host.h" |
| #include "content/public/browser/site_instance.h" |
| +#include "content/public/common/content_client.h" |
| +#include "content/public/common/service_registry.h" |
| +#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
| namespace content { |
| +namespace { |
| + |
| +// A ServiceProvider implementation based on ServiceRegistryImpl. Strongly bound |
|
Ken Rockot(use gerrit already)
2015/07/06 18:58:00
I think this class might be unnecessary if FrameMo
xhwang
2015/07/07 19:21:04
Removed in favor of WeakBindingSet.
|
| +// to the ServiceProvider request. |
| +class ProxyServiceProvider : public mojo::ServiceProvider { |
| + public: |
| + ProxyServiceProvider(ServiceRegistryImpl* service_registry, |
| + mojo::InterfaceRequest<mojo::ServiceProvider> services) |
| + : service_registry_(service_registry), binding_(this, services.Pass()){}; |
| + ~ProxyServiceProvider() final{}; |
| + |
| + // mojo::ServiceProvider implementation. |
| + void ConnectToService(const mojo::String& interface_name, |
| + mojo::ScopedMessagePipeHandle pipe) final { |
| + // Cast because ConnectToService() is private in ServiceRegistryImpl. |
| + static_cast<mojo::ServiceProvider*>(service_registry_) |
| + ->ConnectToService(interface_name.get(), pipe.Pass()); |
| + }; |
| + |
| + private: |
| + ServiceRegistryImpl* service_registry_; |
| + mojo::StrongBinding<ServiceProvider> binding_; |
| +}; |
| + |
| +} // namespace |
| + |
| FrameMojoShell::FrameMojoShell(RenderFrameHost* frame_host) |
| : frame_host_(frame_host) { |
| } |
| @@ -22,16 +53,33 @@ void FrameMojoShell::BindRequest( |
| bindings_.AddBinding(this, shell_request.Pass()); |
| } |
| +// TODO(xhwang): Currently no callers are exposing |exposed_services|. So we |
| +// drop it and replace it with services we provide in the browser. In the |
| +// future we may need to support both. |
| void FrameMojoShell::ConnectToApplication( |
| mojo::URLRequestPtr application_url, |
| mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| - mojo::ServiceProviderPtr exposed_services) { |
| + mojo::ServiceProviderPtr /* exposed_services */) { |
| + mojo::ServiceProviderPtr frame_services; |
| + new ProxyServiceProvider(GetServiceRegistry(), GetProxy(&frame_services)); |
|
Ken Rockot(use gerrit already)
2015/07/06 18:58:00
Though it may be true in practice (and I may be mi
xhwang
2015/07/07 19:21:04
Use SRI + WBS now.
|
| + |
| MojoShellContext::ConnectToApplication( |
| GURL(application_url->url), frame_host_->GetSiteInstance()->GetSiteURL(), |
| - services.Pass()); |
| + services.Pass(), frame_services.Pass()); |
| } |
| void FrameMojoShell::QuitApplication() { |
| } |
| +ServiceRegistryImpl* FrameMojoShell::GetServiceRegistry() { |
| + if (!service_registry_) { |
| + service_registry_.reset(new ServiceRegistryImpl()); |
| + |
| + GetContentClient()->browser()->OverrideFrameMojoShellServices( |
| + service_registry_.get(), frame_host_); |
| + } |
| + |
| + return service_registry_.get(); |
| +} |
| + |
| } // namespace content |