Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: mojo/services/view_manager/view_manager_service_impl.h

Issue 396703002: Makes Embed() take a single node (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
(...skipping 24 matching lines...) Expand all
35 #pragma warning(disable : 4275) 35 #pragma warning(disable : 4275)
36 #endif 36 #endif
37 37
38 // Manages a connection from the client. 38 // Manages a connection from the client.
39 class MOJO_VIEW_MANAGER_EXPORT ViewManagerServiceImpl 39 class MOJO_VIEW_MANAGER_EXPORT ViewManagerServiceImpl
40 : public InterfaceImpl<ViewManagerService> { 40 : public InterfaceImpl<ViewManagerService> {
41 public: 41 public:
42 ViewManagerServiceImpl(RootNodeManager* root_node_manager, 42 ViewManagerServiceImpl(RootNodeManager* root_node_manager,
43 ConnectionSpecificId creator_id, 43 ConnectionSpecificId creator_id,
44 const std::string& creator_url, 44 const std::string& creator_url,
45 const std::string& url); 45 const std::string& url,
46 const NodeId& root_id);
46 virtual ~ViewManagerServiceImpl(); 47 virtual ~ViewManagerServiceImpl();
47 48
48 // Used to mark this connection as originating from a call to 49 // Used to mark this connection as originating from a call to
49 // ViewManagerService::Connect(). When set OnConnectionError() deletes |this|. 50 // ViewManagerService::Connect(). When set OnConnectionError() deletes |this|.
50 void set_delete_on_connection_error() { delete_on_connection_error_ = true; } 51 void set_delete_on_connection_error() { delete_on_connection_error_ = true; }
51 52
52 ConnectionSpecificId id() const { return id_; } 53 ConnectionSpecificId id() const { return id_; }
53 ConnectionSpecificId creator_id() const { return creator_id_; } 54 ConnectionSpecificId creator_id() const { return creator_id_; }
54 const std::string& url() const { return url_; } 55 const std::string& url() const { return url_; }
55 56
56 // Returns the Node with the specified id. 57 // Returns the Node with the specified id.
57 Node* GetNode(const NodeId& id) { 58 Node* GetNode(const NodeId& id) {
58 return const_cast<Node*>( 59 return const_cast<Node*>(
59 const_cast<const ViewManagerServiceImpl*>(this)->GetNode(id)); 60 const_cast<const ViewManagerServiceImpl*>(this)->GetNode(id));
60 } 61 }
61 const Node* GetNode(const NodeId& id) const; 62 const Node* GetNode(const NodeId& id) const;
62 63
63 // Returns the View with the specified id. 64 // Returns the View with the specified id.
64 View* GetView(const ViewId& id) { 65 View* GetView(const ViewId& id) {
65 return const_cast<View*>( 66 return const_cast<View*>(
66 const_cast<const ViewManagerServiceImpl*>(this)->GetView(id)); 67 const_cast<const ViewManagerServiceImpl*>(this)->GetView(id));
67 } 68 }
68 const View* GetView(const ViewId& id) const; 69 const View* GetView(const ViewId& id) const;
69 70
70 void SetRoots(const Array<Id>& node_ids);
71
72 // Invoked when a connection is destroyed. 71 // Invoked when a connection is destroyed.
73 void OnViewManagerServiceImplDestroyed(ConnectionSpecificId id); 72 void OnViewManagerServiceImplDestroyed(ConnectionSpecificId id);
74 73
75 // The following methods are invoked after the corresponding change has been 74 // The following methods are invoked after the corresponding change has been
76 // processed. They do the appropriate bookkeeping and update the client as 75 // processed. They do the appropriate bookkeeping and update the client as
77 // necessary. 76 // necessary.
78 void ProcessNodeBoundsChanged(const Node* node, 77 void ProcessNodeBoundsChanged(const Node* node,
79 const gfx::Rect& old_bounds, 78 const gfx::Rect& old_bounds,
80 const gfx::Rect& new_bounds, 79 const gfx::Rect& new_bounds,
81 bool originated_change); 80 bool originated_change);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 bool CanRemoveNodeFromParent(const Node* node) const; 115 bool CanRemoveNodeFromParent(const Node* node) const;
117 bool CanAddNode(const Node* parent, const Node* child) const; 116 bool CanAddNode(const Node* parent, const Node* child) const;
118 bool CanReorderNode(const Node* node, 117 bool CanReorderNode(const Node* node,
119 const Node* relative_node, 118 const Node* relative_node,
120 OrderDirection direction) const; 119 OrderDirection direction) const;
121 bool CanDeleteNode(const NodeId& node_id) const; 120 bool CanDeleteNode(const NodeId& node_id) const;
122 bool CanDeleteView(const ViewId& view_id) const; 121 bool CanDeleteView(const ViewId& view_id) const;
123 bool CanSetView(const Node* node, const ViewId& view_id) const; 122 bool CanSetView(const Node* node, const ViewId& view_id) const;
124 bool CanSetFocus(const Node* node) const; 123 bool CanSetFocus(const Node* node) const;
125 bool CanGetNodeTree(const Node* node) const; 124 bool CanGetNodeTree(const Node* node) const;
126 bool CanEmbed(const mojo::Array<uint32_t>& node_ids) const; 125 bool CanEmbed(Id transport_node_id) const;
127 bool CanSetNodeVisibility(const Node* node, bool visible) const; 126 bool CanSetNodeVisibility(const Node* node, bool visible) const;
128 127
129 // Deletes a node owned by this connection. Returns true on success. |source| 128 // Deletes a node owned by this connection. Returns true on success. |source|
130 // is the connection that originated the change. 129 // is the connection that originated the change.
131 bool DeleteNodeImpl(ViewManagerServiceImpl* source, const NodeId& node_id); 130 bool DeleteNodeImpl(ViewManagerServiceImpl* source, const NodeId& node_id);
132 131
133 // Deletes a view owned by this connection. Returns true on success. |source| 132 // Deletes a view owned by this connection. Returns true on success. |source|
134 // is the connection that originated the change. 133 // is the connection that originated the change.
135 bool DeleteViewImpl(ViewManagerServiceImpl* source, const ViewId& view_id); 134 bool DeleteViewImpl(ViewManagerServiceImpl* source, const ViewId& view_id);
136 135
137 // Sets the view associated with a node. 136 // Sets the view associated with a node.
138 bool SetViewImpl(Node* node, const ViewId& view_id); 137 bool SetViewImpl(Node* node, const ViewId& view_id);
139 138
140 // If |node| is known (in |known_nodes_|) does nothing. Otherwise adds |node| 139 // If |node| is known (in |known_nodes_|) does nothing. Otherwise adds |node|
141 // to |nodes|, marks |node| as known and recurses. 140 // to |nodes|, marks |node| as known and recurses.
142 void GetUnknownNodesFrom(const Node* node, std::vector<const Node*>* nodes); 141 void GetUnknownNodesFrom(const Node* node, std::vector<const Node*>* nodes);
143 142
144 // Removes |node| and all its descendants from |known_nodes_|. This does not 143 // Removes |node| and all its descendants from |known_nodes_|. This does not
145 // recurse through nodes that were created by this connection. 144 // recurse through nodes that were created by this connection.
146 void RemoveFromKnown(const Node* node); 145 void RemoveFromKnown(const Node* node);
147 146
148 // Adds |node_ids| to roots, returning true if at least one of the nodes was 147 // Adds |transport_node_id| to the set of roots this connection knows about.
149 // not already a root. If at least one of the nodes was not already a root 148 // Returns true if |transport_node_id| was not already a root for this
150 // the client is told of the new roots. 149 // connection.
151 bool AddRoots(const std::vector<Id>& node_ids); 150 bool AddRoot(Id transport_node_id);
152 151
153 // Returns true if |node| is a non-null and a descendant of |roots_| (or 152 // Returns true if |node| is a non-null and a descendant of |roots_| (or
154 // |roots_| is empty). 153 // |roots_| is empty).
155 bool IsNodeDescendantOfRoots(const Node* node) const; 154 bool IsNodeDescendantOfRoots(const Node* node) const;
156 155
157 // Returns true if notification should be sent of a hierarchy change. If true 156 // Returns true if notification should be sent of a hierarchy change. If true
158 // is returned, any nodes that need to be sent to the client are added to 157 // is returned, any nodes that need to be sent to the client are added to
159 // |to_send|. 158 // |to_send|.
160 bool ShouldNotifyOnHierarchyChange(const Node* node, 159 bool ShouldNotifyOnHierarchyChange(const Node* node,
161 const Node** new_parent, 160 const Node** new_parent,
162 const Node** old_parent, 161 const Node** old_parent,
163 std::vector<const Node*>* to_send); 162 std::vector<const Node*>* to_send);
164 163
165 // Converts an array of Nodes to NodeDatas. This assumes all the nodes are 164 // Converts an array of Nodes to NodeDatas. This assumes all the nodes are
166 // valid for the client. The parent of nodes the client is not allowed to see 165 // valid for the client. The parent of nodes the client is not allowed to see
167 // are set to NULL (in the returned NodeDatas). 166 // are set to NULL (in the returned NodeDatas).
168 Array<NodeDataPtr> NodesToNodeDatas(const std::vector<const Node*>& nodes); 167 Array<NodeDataPtr> NodesToNodeDatas(const std::vector<const Node*>& nodes);
169 168
170 // Overridden from ViewManagerService: 169 // ViewManagerService:
171 virtual void CreateNode(Id transport_node_id, 170 virtual void CreateNode(Id transport_node_id,
172 const Callback<void(ErrorCode)>& callback) OVERRIDE; 171 const Callback<void(ErrorCode)>& callback) OVERRIDE;
173 virtual void DeleteNode(Id transport_node_id, 172 virtual void DeleteNode(Id transport_node_id,
174 Id server_change_id, 173 Id server_change_id,
175 const Callback<void(bool)>& callback) OVERRIDE; 174 const Callback<void(bool)>& callback) OVERRIDE;
176 virtual void AddNode(Id parent_id, 175 virtual void AddNode(Id parent_id,
177 Id child_id, 176 Id child_id,
178 Id server_change_id, 177 Id server_change_id,
179 const Callback<void(bool)>& callback) OVERRIDE; 178 const Callback<void(bool)>& callback) OVERRIDE;
180 virtual void RemoveNodeFromParent( 179 virtual void RemoveNodeFromParent(
(...skipping 21 matching lines...) Expand all
202 const Callback<void(bool)>& callback) OVERRIDE; 201 const Callback<void(bool)>& callback) OVERRIDE;
203 virtual void SetFocus(Id node_id, 202 virtual void SetFocus(Id node_id,
204 const Callback<void(bool)> & callback) OVERRIDE; 203 const Callback<void(bool)> & callback) OVERRIDE;
205 virtual void SetNodeBounds(Id node_id, 204 virtual void SetNodeBounds(Id node_id,
206 RectPtr bounds, 205 RectPtr bounds,
207 const Callback<void(bool)>& callback) OVERRIDE; 206 const Callback<void(bool)>& callback) OVERRIDE;
208 virtual void SetNodeVisibility(Id transport_node_id, 207 virtual void SetNodeVisibility(Id transport_node_id,
209 bool visible, 208 bool visible,
210 const Callback<void(bool)>& callback) OVERRIDE; 209 const Callback<void(bool)>& callback) OVERRIDE;
211 virtual void Embed(const mojo::String& url, 210 virtual void Embed(const mojo::String& url,
212 mojo::Array<uint32_t> node_ids, 211 Id transport_node_id,
213 const mojo::Callback<void(bool)>& callback) OVERRIDE; 212 const mojo::Callback<void(bool)>& callback) OVERRIDE;
214 virtual void DispatchOnViewInputEvent(Id transport_view_id, 213 virtual void DispatchOnViewInputEvent(Id transport_view_id,
215 EventPtr event) OVERRIDE; 214 EventPtr event) OVERRIDE;
216 215
217 // InterfaceImp overrides: 216 // InterfaceImp overrides:
218 virtual void OnConnectionEstablished() MOJO_OVERRIDE; 217 virtual void OnConnectionEstablished() MOJO_OVERRIDE;
219 218
220 RootNodeManager* root_node_manager_; 219 RootNodeManager* root_node_manager_;
221 220
222 // Id of this connection as assigned by RootNodeManager. 221 // Id of this connection as assigned by RootNodeManager.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 255
257 #if defined(OS_WIN) 256 #if defined(OS_WIN)
258 #pragma warning(pop) 257 #pragma warning(pop)
259 #endif 258 #endif
260 259
261 } // namespace service 260 } // namespace service
262 } // namespace view_manager 261 } // namespace view_manager
263 } // namespace mojo 262 } // namespace mojo
264 263
265 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ 264 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/services/view_manager/test_change_tracker.cc ('k') | mojo/services/view_manager/view_manager_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698