OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_ | 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_ |
6 #define COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_ | 6 #define COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "components/mus/public/cpp/types.h" | 10 #include "components/mus/public/cpp/types.h" |
11 #include "components/mus/public/interfaces/view_tree.mojom.h" | 11 #include "components/mus/public/interfaces/view_tree.mojom.h" |
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" | 12 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" |
13 | 13 |
14 namespace mus { | 14 namespace mus { |
15 | 15 |
16 class View; | 16 class View; |
17 class ViewTreeDelegate; | 17 class ViewTreeDelegate; |
18 | 18 |
19 // Encapsulates a connection to a view tree. A unique connection is made | 19 // Encapsulates a connection to a view tree. A unique connection is made |
20 // every time an app is embedded. | 20 // every time an app is embedded. |
21 class ViewTreeConnection { | 21 class ViewTreeConnection { |
22 public: | 22 public: |
| 23 enum class CreateType { |
| 24 // Indicates Create() should wait for OnEmbed(). If true, the |
| 25 // ViewTreeConnection returned from Create() will have its root, otherwise |
| 26 // the ViewTreeConnection will get the root at a later time. |
| 27 WAIT_FOR_EMBED, |
| 28 DONT_WAIT_FOR_EMBED |
| 29 }; |
| 30 |
23 virtual ~ViewTreeConnection() {} | 31 virtual ~ViewTreeConnection() {} |
24 | 32 |
25 // The returned ViewTreeConnection instance owns itself, and is deleted when | 33 // The returned ViewTreeConnection instance owns itself, and is deleted when |
26 // the last root is destroyed or the connection to the service is broken. | 34 // the last root is destroyed or the connection to the service is broken. |
27 static ViewTreeConnection* Create( | 35 static ViewTreeConnection* Create( |
28 ViewTreeDelegate* delegate, | 36 ViewTreeDelegate* delegate, |
29 mojo::InterfaceRequest<mojo::ViewTreeClient> request); | 37 mojo::InterfaceRequest<mojo::ViewTreeClient> request, |
| 38 CreateType create_type); |
30 | 39 |
31 // Returns the root of this connection. | 40 // Returns the root of this connection. |
32 virtual View* GetRoot() = 0; | 41 virtual View* GetRoot() = 0; |
33 | 42 |
34 // Returns a View known to this connection. | 43 // Returns a View known to this connection. |
35 virtual View* GetViewById(Id id) = 0; | 44 virtual View* GetViewById(Id id) = 0; |
36 | 45 |
37 // Returns the focused view; null if focus is not yet known or another app is | 46 // Returns the focused view; null if focus is not yet known or another app is |
38 // focused. | 47 // focused. |
39 virtual View* GetFocusedView() = 0; | 48 virtual View* GetFocusedView() = 0; |
40 | 49 |
41 // Creates and returns a new View (which is owned by the ViewManager). Views | 50 // Creates and returns a new View (which is owned by the ViewManager). Views |
42 // are initially hidden, use SetVisible(true) to show. | 51 // are initially hidden, use SetVisible(true) to show. |
43 virtual View* CreateView() = 0; | 52 virtual View* CreateView() = 0; |
44 | 53 |
45 // Returns true if ACCESS_POLICY_EMBED_ROOT was specified. | 54 // Returns true if ACCESS_POLICY_EMBED_ROOT was specified. |
46 virtual bool IsEmbedRoot() = 0; | 55 virtual bool IsEmbedRoot() = 0; |
47 | 56 |
48 // Returns the id for this connection. | 57 // Returns the id for this connection. |
49 virtual ConnectionSpecificId GetConnectionId() = 0; | 58 virtual ConnectionSpecificId GetConnectionId() = 0; |
50 }; | 59 }; |
51 | 60 |
52 } // namespace mus | 61 } // namespace mus |
53 | 62 |
54 #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_ | 63 #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_ |
OLD | NEW |