[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / browser / frame_host / frame_mojo_shell.cc
blob91a3875974174b6a2eabcd1b3eb69c78f7c5645e
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"
14 namespace content {
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 const ConnectToApplicationCallback& callback) {
37 mojo::ServiceProviderPtr frame_services;
38 service_provider_bindings_.AddBinding(GetServiceRegistry(),
39 GetProxy(&frame_services));
41 mojo::shell::CapabilityFilter capability_filter =
42 mojo::shell::GetPermissiveCapabilityFilter();
43 if (!filter.is_null())
44 capability_filter = filter->filter.To<mojo::shell::CapabilityFilter>();
45 MojoShellContext::ConnectToApplication(
46 GURL(application_url->url), frame_host_->GetSiteInstance()->GetSiteURL(),
47 services.Pass(), frame_services.Pass(), capability_filter, callback);
50 void FrameMojoShell::QuitApplication() {
53 ServiceRegistryImpl* FrameMojoShell::GetServiceRegistry() {
54 if (!service_registry_) {
55 service_registry_.reset(new ServiceRegistryImpl());
57 GetContentClient()->browser()->RegisterFrameMojoShellServices(
58 service_registry_.get(), frame_host_);
61 return service_registry_.get();
64 } // namespace content