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 "content/browser/mojo/mojo_shell_context.h" | 7 #include "content/browser/mojo/mojo_shell_context.h" |
8 #include "content/common/mojo/service_registry_impl.h" | |
9 #include "content/public/browser/content_browser_client.h" | |
8 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
9 #include "content/public/browser/site_instance.h" | 11 #include "content/public/browser/site_instance.h" |
12 #include "content/public/common/content_client.h" | |
13 #include "content/public/common/service_registry.h" | |
14 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | |
10 | 15 |
11 namespace content { | 16 namespace content { |
12 | 17 |
18 namespace { | |
19 | |
20 // 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.
| |
21 // to the ServiceProvider request. | |
22 class ProxyServiceProvider : public mojo::ServiceProvider { | |
23 public: | |
24 ProxyServiceProvider(ServiceRegistryImpl* service_registry, | |
25 mojo::InterfaceRequest<mojo::ServiceProvider> services) | |
26 : service_registry_(service_registry), binding_(this, services.Pass()){}; | |
27 ~ProxyServiceProvider() final{}; | |
28 | |
29 // mojo::ServiceProvider implementation. | |
30 void ConnectToService(const mojo::String& interface_name, | |
31 mojo::ScopedMessagePipeHandle pipe) final { | |
32 // Cast because ConnectToService() is private in ServiceRegistryImpl. | |
33 static_cast<mojo::ServiceProvider*>(service_registry_) | |
34 ->ConnectToService(interface_name.get(), pipe.Pass()); | |
35 }; | |
36 | |
37 private: | |
38 ServiceRegistryImpl* service_registry_; | |
39 mojo::StrongBinding<ServiceProvider> binding_; | |
40 }; | |
41 | |
42 } // namespace | |
43 | |
13 FrameMojoShell::FrameMojoShell(RenderFrameHost* frame_host) | 44 FrameMojoShell::FrameMojoShell(RenderFrameHost* frame_host) |
14 : frame_host_(frame_host) { | 45 : frame_host_(frame_host) { |
15 } | 46 } |
16 | 47 |
17 FrameMojoShell::~FrameMojoShell() { | 48 FrameMojoShell::~FrameMojoShell() { |
18 } | 49 } |
19 | 50 |
20 void FrameMojoShell::BindRequest( | 51 void FrameMojoShell::BindRequest( |
21 mojo::InterfaceRequest<mojo::Shell> shell_request) { | 52 mojo::InterfaceRequest<mojo::Shell> shell_request) { |
22 bindings_.AddBinding(this, shell_request.Pass()); | 53 bindings_.AddBinding(this, shell_request.Pass()); |
23 } | 54 } |
24 | 55 |
56 // TODO(xhwang): Currently no callers are exposing |exposed_services|. So we | |
57 // drop it and replace it with services we provide in the browser. In the | |
58 // future we may need to support both. | |
25 void FrameMojoShell::ConnectToApplication( | 59 void FrameMojoShell::ConnectToApplication( |
26 mojo::URLRequestPtr application_url, | 60 mojo::URLRequestPtr application_url, |
27 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 61 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
28 mojo::ServiceProviderPtr exposed_services) { | 62 mojo::ServiceProviderPtr /* exposed_services */) { |
63 mojo::ServiceProviderPtr frame_services; | |
64 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.
| |
65 | |
29 MojoShellContext::ConnectToApplication( | 66 MojoShellContext::ConnectToApplication( |
30 GURL(application_url->url), frame_host_->GetSiteInstance()->GetSiteURL(), | 67 GURL(application_url->url), frame_host_->GetSiteInstance()->GetSiteURL(), |
31 services.Pass()); | 68 services.Pass(), frame_services.Pass()); |
32 } | 69 } |
33 | 70 |
34 void FrameMojoShell::QuitApplication() { | 71 void FrameMojoShell::QuitApplication() { |
35 } | 72 } |
36 | 73 |
74 ServiceRegistryImpl* FrameMojoShell::GetServiceRegistry() { | |
75 if (!service_registry_) { | |
76 service_registry_.reset(new ServiceRegistryImpl()); | |
77 | |
78 GetContentClient()->browser()->OverrideFrameMojoShellServices( | |
79 service_registry_.get(), frame_host_); | |
80 } | |
81 | |
82 return service_registry_.get(); | |
83 } | |
84 | |
37 } // namespace content | 85 } // namespace content |
OLD | NEW |