summaryrefslogtreecommitdiffstats
path: root/components/mus/public/cpp/view_tree_connection.h
blob: 36b8588f43c3e2f08f4ca37564f004f2b62e34e1 (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
// Copyright 2014 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 COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_
#define COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_

#include <string>

#include "components/mus/public/cpp/types.h"
#include "components/mus/public/interfaces/view_tree.mojom.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"

namespace mojo {
class View;
class ViewTreeDelegate;

// Encapsulates a connection to a view tree. A unique connection is made
// every time an app is embedded.
class ViewTreeConnection {
 public:
  virtual ~ViewTreeConnection() {}

  // The returned ViewTreeConnection instance owns itself, and is deleted when
  // the last root is destroyed or the connection to the service is broken.
  static ViewTreeConnection* Create(ViewTreeDelegate* delegate,
                                    InterfaceRequest<ViewTreeClient> request);

  // Returns the root of this connection.
  virtual View* GetRoot() = 0;

  // Returns a View known to this connection.
  virtual View* GetViewById(Id id) = 0;

  // Returns the focused view; null if focus is not yet known or another app is
  // focused.
  virtual View* GetFocusedView() = 0;

  // Creates and returns a new View (which is owned by the ViewManager). Views
  // are initially hidden, use SetVisible(true) to show.
  virtual View* CreateView() = 0;

  // Returns true if ACCESS_POLICY_EMBED_ROOT was specified.
  virtual bool IsEmbedRoot() = 0;

  // Returns the id for this connection.
  virtual ConnectionSpecificId GetConnectionId() = 0;
};

}  // namespace mojo

#endif  // COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_