summaryrefslogtreecommitdiffstats
path: root/content/browser/frame_host/frame_mojo_shell.h
blob: fa8f6d8931d9cc1883604af84d43cc440e097800 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_MOJO_SHELL_H_
#define CONTENT_BROWSER_FRAME_HOST_FRAME_MOJO_SHELL_H_

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/weak_binding_set.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"

namespace content {

class RenderFrameHost;
class ServiceRegistryImpl;

// This provides the |mojo::shell::mojom::Shell| service interface to each
// frame's ServiceRegistry, giving frames the ability to connect to Mojo
// applications.
class FrameMojoShell : public mojo::shell::mojom::Shell {
 public:
  explicit FrameMojoShell(RenderFrameHost* frame_host);
  ~FrameMojoShell() override;

  void BindRequest(
      mojo::InterfaceRequest<mojo::shell::mojom::Shell> shell_request);

 private:
  // mojo::Shell:
  void Connect(
      const mojo::String& application_url,
      uint32_t user_id,
      mojo::shell::mojom::InterfaceProviderRequest services,
      mojo::shell::mojom::InterfaceProviderPtr exposed_services,
      mojo::shell::mojom::CapabilityFilterPtr filter,
      const ConnectCallback& callback) override;
  void QuitApplication() override;

  ServiceRegistryImpl* GetServiceRegistry();

  RenderFrameHost* frame_host_;
  mojo::WeakBindingSet<mojo::shell::mojom::Shell> bindings_;

  // ServiceRegistry providing browser services to connected applications.
  scoped_ptr<ServiceRegistryImpl> service_registry_;
  mojo::WeakBindingSet<mojo::shell::mojom::InterfaceProvider>
      service_provider_bindings_;

  DISALLOW_COPY_AND_ASSIGN(FrameMojoShell);
};

}  // namespace content

#endif  // CONTENT_BROWSER_FRAME_HOST_FRAME_MOJO_SHELL_H_