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 MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ | 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ |
6 #define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ | 6 #define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
15 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | 15 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" |
16 #include "mojo/services/view_manager/ids.h" | 16 #include "mojo/services/view_manager/ids.h" |
17 #include "mojo/services/view_manager/node_delegate.h" | |
18 #include "mojo/services/view_manager/view_manager_export.h" | 17 #include "mojo/services/view_manager/view_manager_export.h" |
19 | 18 |
20 namespace gfx { | 19 namespace gfx { |
21 class Rect; | 20 class Rect; |
22 } | 21 } |
23 | 22 |
24 namespace mojo { | 23 namespace mojo { |
25 namespace view_manager { | 24 namespace view_manager { |
26 namespace service { | 25 namespace service { |
27 | 26 |
28 class Node; | 27 class Node; |
29 class RootNodeManager; | 28 class RootNodeManager; |
30 class View; | 29 class View; |
31 | 30 |
32 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
33 // Equivalent of NON_EXPORTED_BASE which does not work with the template snafu | 32 // Equivalent of NON_EXPORTED_BASE which does not work with the template snafu |
34 // below. | 33 // below. |
35 #pragma warning(push) | 34 #pragma warning(push) |
36 #pragma warning(disable : 4275) | 35 #pragma warning(disable : 4275) |
37 #endif | 36 #endif |
38 | 37 |
39 // Manages a connection from the client. | 38 // Manages a connection from the client. |
40 class MOJO_VIEW_MANAGER_EXPORT ViewManagerServiceImpl | 39 class MOJO_VIEW_MANAGER_EXPORT ViewManagerServiceImpl |
41 : public InterfaceImpl<ViewManagerService>, | 40 : public InterfaceImpl<ViewManagerService> { |
42 public NodeDelegate { | |
43 public: | 41 public: |
44 ViewManagerServiceImpl(RootNodeManager* root_node_manager, | 42 ViewManagerServiceImpl(RootNodeManager* root_node_manager, |
45 ConnectionSpecificId creator_id, | 43 ConnectionSpecificId creator_id, |
46 const std::string& creator_url, | 44 const std::string& creator_url, |
47 const std::string& url); | 45 const std::string& url); |
48 virtual ~ViewManagerServiceImpl(); | 46 virtual ~ViewManagerServiceImpl(); |
49 | 47 |
50 // Used to mark this connection as originating from a call to | 48 // Used to mark this connection as originating from a call to |
51 // ViewManagerService::Connect(). When set OnConnectionError() deletes |this|. | 49 // ViewManagerService::Connect(). When set OnConnectionError() deletes |this|. |
52 void set_delete_on_connection_error() { delete_on_connection_error_ = true; } | 50 void set_delete_on_connection_error() { delete_on_connection_error_ = true; } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 const Callback<void(bool)>& callback) OVERRIDE; | 207 const Callback<void(bool)>& callback) OVERRIDE; |
210 virtual void SetNodeVisibility(Id transport_node_id, | 208 virtual void SetNodeVisibility(Id transport_node_id, |
211 bool visible, | 209 bool visible, |
212 const Callback<void(bool)>& callback) OVERRIDE; | 210 const Callback<void(bool)>& callback) OVERRIDE; |
213 virtual void Embed(const mojo::String& url, | 211 virtual void Embed(const mojo::String& url, |
214 mojo::Array<uint32_t> node_ids, | 212 mojo::Array<uint32_t> node_ids, |
215 const mojo::Callback<void(bool)>& callback) OVERRIDE; | 213 const mojo::Callback<void(bool)>& callback) OVERRIDE; |
216 virtual void DispatchOnViewInputEvent(Id transport_view_id, | 214 virtual void DispatchOnViewInputEvent(Id transport_view_id, |
217 EventPtr event) OVERRIDE; | 215 EventPtr event) OVERRIDE; |
218 | 216 |
219 // Overridden from NodeDelegate: | |
220 virtual void OnNodeHierarchyChanged(const Node* node, | |
221 const Node* new_parent, | |
222 const Node* old_parent) OVERRIDE; | |
223 virtual void OnNodeBoundsChanged(const Node* node, | |
224 const gfx::Rect& old_bounds, | |
225 const gfx::Rect& new_bounds) OVERRIDE; | |
226 virtual void OnNodeViewReplaced(const Node* node, | |
227 const View* new_view, | |
228 const View* old_view) OVERRIDE; | |
229 virtual void OnViewInputEvent(const View* view, | |
230 const ui::Event* event) OVERRIDE; | |
231 | |
232 // InterfaceImp overrides: | 217 // InterfaceImp overrides: |
233 virtual void OnConnectionEstablished() MOJO_OVERRIDE; | 218 virtual void OnConnectionEstablished() MOJO_OVERRIDE; |
234 | 219 |
235 RootNodeManager* root_node_manager_; | 220 RootNodeManager* root_node_manager_; |
236 | 221 |
237 // Id of this connection as assigned by RootNodeManager. | 222 // Id of this connection as assigned by RootNodeManager. |
238 const ConnectionSpecificId id_; | 223 const ConnectionSpecificId id_; |
239 | 224 |
240 // URL this connection was created for. | 225 // URL this connection was created for. |
241 const std::string url_; | 226 const std::string url_; |
242 | 227 |
243 // ID of the connection that created us. If 0 it indicates either we were | 228 // ID of the connection that created us. If 0 it indicates either we were |
244 // created by the root, or the connection that created us has been destroyed. | 229 // created by the root, or the connection that created us has been destroyed. |
245 ConnectionSpecificId creator_id_; | 230 ConnectionSpecificId creator_id_; |
246 | 231 |
247 // The URL of the app that embedded the app this connection was created for. | 232 // The URL of the app that embedded the app this connection was created for. |
248 const std::string creator_url_; | 233 const std::string creator_url_; |
249 | 234 |
| 235 // The nodes and views created by this connection. This connection owns these |
| 236 // objects. |
250 NodeMap node_map_; | 237 NodeMap node_map_; |
251 | |
252 ViewMap view_map_; | 238 ViewMap view_map_; |
253 | 239 |
254 // The set of nodes that has been communicated to the client. | 240 // The set of nodes that has been communicated to the client. |
255 NodeIdSet known_nodes_; | 241 NodeIdSet known_nodes_; |
256 | 242 |
257 // This is the set of nodes the connection can parent nodes to (in addition to | 243 // This is the set of nodes the connection can parent nodes to (in addition to |
258 // any nodes created by this connection). If empty the connection can | 244 // any nodes created by this connection). If empty the connection can |
259 // manipulate any nodes (except for deleting other connections nodes/views). | 245 // manipulate any nodes (except for deleting other connections nodes/views). |
260 // The connection can not delete or move these. If this is set to a non-empty | 246 // The connection can not delete or move these. If this is set to a non-empty |
261 // value and all the nodes are deleted (by another connection), then an | 247 // value and all the nodes are deleted (by another connection), then an |
262 // invalid node is added here to ensure this connection is still constrained. | 248 // invalid node is added here to ensure this connection is still constrained. |
263 NodeIdSet roots_; | 249 NodeIdSet roots_; |
264 | 250 |
265 // See description above setter. | 251 // See description above setter. |
266 bool delete_on_connection_error_; | 252 bool delete_on_connection_error_; |
267 | 253 |
268 DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceImpl); | 254 DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceImpl); |
269 }; | 255 }; |
270 | 256 |
271 #if defined(OS_WIN) | 257 #if defined(OS_WIN) |
272 #pragma warning(pop) | 258 #pragma warning(pop) |
273 #endif | 259 #endif |
274 | 260 |
275 } // namespace service | 261 } // namespace service |
276 } // namespace view_manager | 262 } // namespace view_manager |
277 } // namespace mojo | 263 } // namespace mojo |
278 | 264 |
279 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ | 265 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ |
OLD | NEW |