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
3 // found in the LICENSE file.
5 #include "content/browser/frame_host/frame_mojo_shell.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"
10 #include "content/public/browser/render_frame_host.h"
11 #include "content/public/browser/site_instance.h"
12 #include "content/public/common/content_client.h"
16 FrameMojoShell::FrameMojoShell(RenderFrameHost
* frame_host
)
17 : frame_host_(frame_host
) {
20 FrameMojoShell::~FrameMojoShell() {
23 void FrameMojoShell::BindRequest(
24 mojo::InterfaceRequest
<mojo::Shell
> shell_request
) {
25 bindings_
.AddBinding(this, shell_request
.Pass());
28 // TODO(xhwang): Currently no callers are exposing |exposed_services|. So we
29 // drop it and replace it with services we provide in the browser. In the
30 // future we may need to support both.
31 void FrameMojoShell::ConnectToApplication(
32 mojo::URLRequestPtr application_url
,
33 mojo::InterfaceRequest
<mojo::ServiceProvider
> services
,
34 mojo::ServiceProviderPtr
/* exposed_services */,
35 mojo::CapabilityFilterPtr filter
) {
36 mojo::ServiceProviderPtr frame_services
;
37 service_provider_bindings_
.AddBinding(GetServiceRegistry(),
38 GetProxy(&frame_services
));
40 mojo::shell::CapabilityFilter capability_filter
=
41 mojo::shell::GetPermissiveCapabilityFilter();
42 if (!filter
.is_null())
43 capability_filter
= filter
->filter
.To
<mojo::shell::CapabilityFilter
>();
44 MojoShellContext::ConnectToApplication(
45 GURL(application_url
->url
), frame_host_
->GetSiteInstance()->GetSiteURL(),
46 services
.Pass(), frame_services
.Pass(), capability_filter
);
49 void FrameMojoShell::QuitApplication() {
52 ServiceRegistryImpl
* FrameMojoShell::GetServiceRegistry() {
53 if (!service_registry_
) {
54 service_registry_
.reset(new ServiceRegistryImpl());
56 GetContentClient()->browser()->RegisterFrameMojoShellServices(
57 service_registry_
.get(), frame_host_
);
60 return service_registry_
.get();
63 } // namespace content