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_LIB_VIEW_TREE_CLIENT_IMPL_H_ | 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_ |
6 #define COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_ | 6 #define COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_ |
7 | 7 |
8 #include "components/mus/public/cpp/types.h" | 8 #include "components/mus/public/cpp/types.h" |
9 #include "components/mus/public/cpp/view.h" | 9 #include "components/mus/public/cpp/view.h" |
10 #include "components/mus/public/cpp/view_tree_connection.h" | 10 #include "components/mus/public/cpp/view_tree_connection.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/strong_binding.h" | 12 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
13 | 13 |
14 namespace mus { | 14 namespace mojo { |
15 class ViewTreeConnection; | 15 class ViewTreeConnection; |
16 class ViewTreeDelegate; | 16 class ViewTreeDelegate; |
17 | 17 |
18 // Manages the connection with the View Manager service. | 18 // Manages the connection with the View Manager service. |
19 class ViewTreeClientImpl : public ViewTreeConnection, | 19 class ViewTreeClientImpl : public ViewTreeConnection, public ViewTreeClient { |
20 public mojo::ViewTreeClient { | |
21 public: | 20 public: |
22 ViewTreeClientImpl(ViewTreeDelegate* delegate, | 21 ViewTreeClientImpl(ViewTreeDelegate* delegate, |
23 mojo::InterfaceRequest<mojo::ViewTreeClient> request); | 22 InterfaceRequest<ViewTreeClient> request); |
24 ~ViewTreeClientImpl() override; | 23 ~ViewTreeClientImpl() override; |
25 | 24 |
26 bool connected() const { return tree_; } | 25 bool connected() const { return tree_; } |
27 ConnectionSpecificId connection_id() const { return connection_id_; } | 26 ConnectionSpecificId connection_id() const { return connection_id_; } |
28 | 27 |
29 // API exposed to the view implementations that pushes local changes to the | 28 // API exposed to the view implementations that pushes local changes to the |
30 // service. | 29 // service. |
31 void DestroyView(Id view_id); | 30 void DestroyView(Id view_id); |
32 | 31 |
33 // These methods take TransportIds. For views owned by the current connection, | 32 // These methods take TransportIds. For views owned by the current connection, |
34 // the connection id high word can be zero. In all cases, the TransportId 0x1 | 33 // the connection id high word can be zero. In all cases, the TransportId 0x1 |
35 // refers to the root view. | 34 // refers to the root view. |
36 void AddChild(Id child_id, Id parent_id); | 35 void AddChild(Id child_id, Id parent_id); |
37 void RemoveChild(Id child_id, Id parent_id); | 36 void RemoveChild(Id child_id, Id parent_id); |
38 | 37 |
39 void Reorder(Id view_id, Id relative_view_id, mojo::OrderDirection direction); | 38 void Reorder(Id view_id, Id relative_view_id, OrderDirection direction); |
40 | 39 |
41 // Returns true if the specified view was created by this connection. | 40 // Returns true if the specified view was created by this connection. |
42 bool OwnsView(Id id) const; | 41 bool OwnsView(Id id) const; |
43 | 42 |
44 void SetBounds(Id view_id, const mojo::Rect& bounds); | 43 void SetBounds(Id view_id, const Rect& bounds); |
45 void SetFocus(Id view_id); | 44 void SetFocus(Id view_id); |
46 void SetVisible(Id view_id, bool visible); | 45 void SetVisible(Id view_id, bool visible); |
47 void SetProperty(Id view_id, | 46 void SetProperty(Id view_id, |
48 const std::string& name, | 47 const std::string& name, |
49 const std::vector<uint8_t>& data); | 48 const std::vector<uint8_t>& data); |
50 void SetViewTextInputState(Id view_id, mojo::TextInputStatePtr state); | 49 void SetViewTextInputState(Id view_id, TextInputStatePtr state); |
51 void SetImeVisibility(Id view_id, | 50 void SetImeVisibility(Id view_id, bool visible, TextInputStatePtr state); |
52 bool visible, | |
53 mojo::TextInputStatePtr state); | |
54 | 51 |
55 void Embed(Id view_id, | 52 void Embed(Id view_id, |
56 mojo::ViewTreeClientPtr client, | 53 ViewTreeClientPtr client, |
57 uint32_t policy_bitmask, | 54 uint32_t policy_bitmask, |
58 const mojo::ViewTree::EmbedCallback& callback); | 55 const ViewTree::EmbedCallback& callback); |
59 | 56 |
60 void RequestSurface(Id view_id, | 57 void RequestSurface(Id view_id, |
61 mojo::InterfaceRequest<mojo::Surface> surface, | 58 InterfaceRequest<Surface> surface, |
62 mojo::SurfaceClientPtr client); | 59 SurfaceClientPtr client); |
63 | 60 |
64 void set_change_acked_callback(const mojo::Callback<void(void)>& callback) { | 61 void set_change_acked_callback(const Callback<void(void)>& callback) { |
65 change_acked_callback_ = callback; | 62 change_acked_callback_ = callback; |
66 } | 63 } |
67 void ClearChangeAckedCallback() { change_acked_callback_.reset(); } | 64 void ClearChangeAckedCallback() { change_acked_callback_.reset(); } |
68 | 65 |
69 // Start/stop tracking views. While tracked, they can be retrieved via | 66 // Start/stop tracking views. While tracked, they can be retrieved via |
70 // ViewTreeConnection::GetViewById. | 67 // ViewTreeConnection::GetViewById. |
71 void AddView(View* view); | 68 void AddView(View* view); |
72 void RemoveView(Id view_id); | 69 void RemoveView(Id view_id); |
73 | 70 |
74 bool is_embed_root() const { return is_embed_root_; } | 71 bool is_embed_root() const { return is_embed_root_; } |
(...skipping 11 matching lines...) Expand all Loading... |
86 // Overridden from ViewTreeConnection: | 83 // Overridden from ViewTreeConnection: |
87 View* GetRoot() override; | 84 View* GetRoot() override; |
88 View* GetViewById(Id id) override; | 85 View* GetViewById(Id id) override; |
89 View* GetFocusedView() override; | 86 View* GetFocusedView() override; |
90 View* CreateView() override; | 87 View* CreateView() override; |
91 bool IsEmbedRoot() override; | 88 bool IsEmbedRoot() override; |
92 ConnectionSpecificId GetConnectionId() override; | 89 ConnectionSpecificId GetConnectionId() override; |
93 | 90 |
94 // Overridden from ViewTreeClient: | 91 // Overridden from ViewTreeClient: |
95 void OnEmbed(ConnectionSpecificId connection_id, | 92 void OnEmbed(ConnectionSpecificId connection_id, |
96 mojo::ViewDataPtr root, | 93 ViewDataPtr root, |
97 mojo::ViewTreePtr tree, | 94 ViewTreePtr tree, |
98 Id focused_view_id, | 95 Id focused_view_id, |
99 uint32_t access_policy) override; | 96 uint32_t access_policy) override; |
100 void OnEmbeddedAppDisconnected(Id view_id) override; | 97 void OnEmbeddedAppDisconnected(Id view_id) override; |
101 void OnUnembed() override; | 98 void OnUnembed() override; |
102 void OnViewBoundsChanged(Id view_id, | 99 void OnViewBoundsChanged(Id view_id, |
103 mojo::RectPtr old_bounds, | 100 RectPtr old_bounds, |
104 mojo::RectPtr new_bounds) override; | 101 RectPtr new_bounds) override; |
105 void OnViewViewportMetricsChanged( | 102 void OnViewViewportMetricsChanged(ViewportMetricsPtr old_metrics, |
106 mojo::ViewportMetricsPtr old_metrics, | 103 ViewportMetricsPtr new_metrics) override; |
107 mojo::ViewportMetricsPtr new_metrics) override; | |
108 void OnViewHierarchyChanged(Id view_id, | 104 void OnViewHierarchyChanged(Id view_id, |
109 Id new_parent_id, | 105 Id new_parent_id, |
110 Id old_parent_id, | 106 Id old_parent_id, |
111 mojo::Array<mojo::ViewDataPtr> views) override; | 107 Array<ViewDataPtr> views) override; |
112 void OnViewReordered(Id view_id, | 108 void OnViewReordered(Id view_id, |
113 Id relative_view_id, | 109 Id relative_view_id, |
114 mojo::OrderDirection direction) override; | 110 OrderDirection direction) override; |
115 void OnViewDeleted(Id view_id) override; | 111 void OnViewDeleted(Id view_id) override; |
116 void OnViewVisibilityChanged(Id view_id, bool visible) override; | 112 void OnViewVisibilityChanged(Id view_id, bool visible) override; |
117 void OnViewDrawnStateChanged(Id view_id, bool drawn) override; | 113 void OnViewDrawnStateChanged(Id view_id, bool drawn) override; |
118 void OnViewSharedPropertyChanged(Id view_id, | 114 void OnViewSharedPropertyChanged(Id view_id, |
119 const mojo::String& name, | 115 const String& name, |
120 mojo::Array<uint8_t> new_data) override; | 116 Array<uint8_t> new_data) override; |
121 void OnViewInputEvent(Id view_id, | 117 void OnViewInputEvent(Id view_id, |
122 mojo::EventPtr event, | 118 EventPtr event, |
123 const mojo::Callback<void()>& callback) override; | 119 const Callback<void()>& callback) override; |
124 void OnViewFocused(Id focused_view_id) override; | 120 void OnViewFocused(Id focused_view_id) override; |
125 | 121 |
126 void RootDestroyed(View* root); | 122 void RootDestroyed(View* root); |
127 | 123 |
128 void OnActionCompleted(bool success); | 124 void OnActionCompleted(bool success); |
129 | 125 |
130 mojo::Callback<void(bool)> ActionCompletedCallback(); | 126 Callback<void(bool)> ActionCompletedCallback(); |
131 | 127 |
132 ConnectionSpecificId connection_id_; | 128 ConnectionSpecificId connection_id_; |
133 ConnectionSpecificId next_id_; | 129 ConnectionSpecificId next_id_; |
134 | 130 |
135 mojo::Callback<void(void)> change_acked_callback_; | 131 Callback<void(void)> change_acked_callback_; |
136 | 132 |
137 ViewTreeDelegate* delegate_; | 133 ViewTreeDelegate* delegate_; |
138 | 134 |
139 View* root_; | 135 View* root_; |
140 | 136 |
141 IdToViewMap views_; | 137 IdToViewMap views_; |
142 | 138 |
143 View* capture_view_; | 139 View* capture_view_; |
144 View* focused_view_; | 140 View* focused_view_; |
145 View* activated_view_; | 141 View* activated_view_; |
146 | 142 |
147 mojo::Binding<ViewTreeClient> binding_; | 143 Binding<ViewTreeClient> binding_; |
148 mojo::ViewTreePtr tree_; | 144 ViewTreePtr tree_; |
149 | 145 |
150 bool is_embed_root_; | 146 bool is_embed_root_; |
151 | 147 |
152 bool in_destructor_; | 148 bool in_destructor_; |
153 | 149 |
154 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTreeClientImpl); | 150 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTreeClientImpl); |
155 }; | 151 }; |
156 | 152 |
157 } // namespace mus | 153 } // namespace mojo |
158 | 154 |
159 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_ | 155 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_ |
OLD | NEW |