summaryrefslogtreecommitdiff
path: root/chromium/services/ui/ws/display_binding.h
blob: 647e0f4cc748f43784876de2044905d597983067 (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
57
58
59
60
// 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 SERVICES_UI_WS_DISPLAY_BINDING_H_
#define SERVICES_UI_WS_DISPLAY_BINDING_H_

#include <memory>

#include "base/macros.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/ui/public/interfaces/window_tree_host.mojom.h"
#include "services/ui/ws/user_id.h"

namespace ui {
namespace ws {

class Display;
class ServerWindow;
class WindowServer;
class WindowTree;

// DisplayBinding manages the binding between a Display and it's mojo clients.
// DisplayBinding is used when a Display is created via a
// WindowTreeHostFactory.
//
// DisplayBinding is owned by Display.
class DisplayBinding {
 public:
  virtual ~DisplayBinding() {}

  virtual WindowTree* CreateWindowTree(ServerWindow* root) = 0;
};

// Live implementation of DisplayBinding.
class DisplayBindingImpl : public DisplayBinding {
 public:
  DisplayBindingImpl(mojom::WindowTreeHostRequest request,
                     Display* display,
                     const UserId& user_id,
                     mojom::WindowTreeClientPtr client,
                     WindowServer* window_server);
  ~DisplayBindingImpl() override;

 private:
  // DisplayBinding:
  WindowTree* CreateWindowTree(ServerWindow* root) override;

  WindowServer* window_server_;
  const UserId user_id_;
  mojo::Binding<mojom::WindowTreeHost> binding_;
  mojom::WindowTreeClientPtr client_;

  DISALLOW_COPY_AND_ASSIGN(DisplayBindingImpl);
};

}  // namespace ws
}  // namespace ui

#endif  // SERVICES_UI_WS_DISPLAY_BINDING_H_