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

Side by Side Diff: components/mus/view_tree_impl.h

Issue 1340983002: Mandoline UI Process: Update namespaces and file names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 3 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
« no previous file with comments | « components/mus/view_tree_host_impl.cc ('k') | components/mus/view_tree_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 COMPONENTS_MUS_VIEW_TREE_IMPL_H_ 5 #ifndef COMPONENTS_MUS_VIEW_TREE_IMPL_H_
6 #define COMPONENTS_MUS_VIEW_TREE_IMPL_H_ 6 #define COMPONENTS_MUS_VIEW_TREE_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/containers/hash_tables.h" 13 #include "base/containers/hash_tables.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "components/mus/access_policy_delegate.h" 16 #include "components/mus/access_policy_delegate.h"
17 #include "components/mus/ids.h" 17 #include "components/mus/ids.h"
18 #include "components/mus/public/interfaces/surface_id.mojom.h" 18 #include "components/mus/public/interfaces/surface_id.mojom.h"
19 #include "components/mus/public/interfaces/view_tree.mojom.h" 19 #include "components/mus/public/interfaces/view_tree.mojom.h"
20 20
21 namespace gfx { 21 namespace gfx {
22 class Rect; 22 class Rect;
23 } 23 }
24 24
25 namespace view_manager { 25 namespace mus {
26 26
27 class AccessPolicy; 27 class AccessPolicy;
28 class ConnectionManager; 28 class ConnectionManager;
29 class ServerView; 29 class ServerView;
30 class ViewTreeHostImpl; 30 class ViewTreeHostImpl;
31 31
32 // An instance of ViewTreeImpl is created for every ViewTree request. 32 // An instance of ViewTreeImpl is created for every ViewTree request.
33 // ViewTreeImpl tracks all the state and views created by a client. ViewTreeImpl 33 // ViewTreeImpl tracks all the state and views created by a client. ViewTreeImpl
34 // coordinates with ConnectionManager to update the client (and internal state) 34 // coordinates with ConnectionManager to update the client (and internal state)
35 // as necessary. 35 // as necessary.
36 class ViewTreeImpl : public mojo::ViewTree, public AccessPolicyDelegate { 36 class ViewTreeImpl : public mojo::ViewTree, public AccessPolicyDelegate {
37 public: 37 public:
38 ViewTreeImpl(ConnectionManager* connection_manager, 38 ViewTreeImpl(ConnectionManager* connection_manager,
39 mojo::ConnectionSpecificId creator_id, 39 ConnectionSpecificId creator_id,
40 const ViewId& root_id, 40 const ViewId& root_id,
41 uint32_t policy_bitmask); 41 uint32_t policy_bitmask);
42 ~ViewTreeImpl() override; 42 ~ViewTreeImpl() override;
43 43
44 // |services| and |exposed_services| are the ServiceProviders to pass to the 44 // |services| and |exposed_services| are the ServiceProviders to pass to the
45 // client via OnEmbed(). 45 // client via OnEmbed().
46 void Init(mojo::ViewTreeClient* client, mojo::ViewTreePtr tree); 46 void Init(mojo::ViewTreeClient* client, mojo::ViewTreePtr tree);
47 47
48 mojo::ConnectionSpecificId id() const { return id_; } 48 ConnectionSpecificId id() const { return id_; }
49 mojo::ConnectionSpecificId creator_id() const { return creator_id_; } 49 ConnectionSpecificId creator_id() const { return creator_id_; }
50 50
51 mojo::ViewTreeClient* client() { return client_; } 51 mojo::ViewTreeClient* client() { return client_; }
52 52
53 // Returns the View with the specified id. 53 // Returns the View with the specified id.
54 ServerView* GetView(const ViewId& id) { 54 ServerView* GetView(const ViewId& id) {
55 return const_cast<ServerView*>( 55 return const_cast<ServerView*>(
56 const_cast<const ViewTreeImpl*>(this)->GetView(id)); 56 const_cast<const ViewTreeImpl*>(this)->GetView(id));
57 } 57 }
58 const ServerView* GetView(const ViewId& id) const; 58 const ServerView* GetView(const ViewId& id) const;
59 59
(...skipping 13 matching lines...) Expand all
73 73
74 // These functions are synchronous variants of those defined in the mojom. The 74 // These functions are synchronous variants of those defined in the mojom. The
75 // ViewTree implementations all call into these. See the mojom for details. 75 // ViewTree implementations all call into these. See the mojom for details.
76 mojo::ErrorCode CreateView(const ViewId& view_id); 76 mojo::ErrorCode CreateView(const ViewId& view_id);
77 bool AddView(const ViewId& parent_id, const ViewId& child_id); 77 bool AddView(const ViewId& parent_id, const ViewId& child_id);
78 std::vector<const ServerView*> GetViewTree(const ViewId& view_id) const; 78 std::vector<const ServerView*> GetViewTree(const ViewId& view_id) const;
79 bool SetViewVisibility(const ViewId& view_id, bool visible); 79 bool SetViewVisibility(const ViewId& view_id, bool visible);
80 bool Embed(const ViewId& view_id, 80 bool Embed(const ViewId& view_id,
81 mojo::ViewTreeClientPtr client, 81 mojo::ViewTreeClientPtr client,
82 uint32_t policy_bitmask, 82 uint32_t policy_bitmask,
83 mojo::ConnectionSpecificId* connection_id); 83 ConnectionSpecificId* connection_id);
84 void Embed(const ViewId& view_id, mojo::URLRequestPtr request); 84 void Embed(const ViewId& view_id, mojo::URLRequestPtr request);
85 85
86 // The following methods are invoked after the corresponding change has been 86 // The following methods are invoked after the corresponding change has been
87 // processed. They do the appropriate bookkeeping and update the client as 87 // processed. They do the appropriate bookkeeping and update the client as
88 // necessary. 88 // necessary.
89 void ProcessViewBoundsChanged(const ServerView* view, 89 void ProcessViewBoundsChanged(const ServerView* view,
90 const gfx::Rect& old_bounds, 90 const gfx::Rect& old_bounds,
91 const gfx::Rect& new_bounds, 91 const gfx::Rect& new_bounds,
92 bool originated_change); 92 bool originated_change);
93 void ProcessViewportMetricsChanged(const mojo::ViewportMetrics& old_metrics, 93 void ProcessViewportMetricsChanged(const mojo::ViewportMetrics& old_metrics,
(...skipping 15 matching lines...) Expand all
109 const ServerView* relative_view, 109 const ServerView* relative_view,
110 mojo::OrderDirection direction, 110 mojo::OrderDirection direction,
111 bool originated_change); 111 bool originated_change);
112 void ProcessViewDeleted(const ViewId& view, bool originated_change); 112 void ProcessViewDeleted(const ViewId& view, bool originated_change);
113 void ProcessWillChangeViewVisibility(const ServerView* view, 113 void ProcessWillChangeViewVisibility(const ServerView* view,
114 bool originated_change); 114 bool originated_change);
115 void ProcessFocusChanged(const ServerView* old_focused_view, 115 void ProcessFocusChanged(const ServerView* old_focused_view,
116 const ServerView* new_focused_view); 116 const ServerView* new_focused_view);
117 117
118 private: 118 private:
119 using ViewIdSet = base::hash_set<mojo::Id>; 119 using ViewIdSet = base::hash_set<Id>;
120 using ViewMap = std::map<mojo::ConnectionSpecificId, ServerView*>; 120 using ViewMap = std::map<ConnectionSpecificId, ServerView*>;
121 121
122 bool IsViewKnown(const ServerView* view) const; 122 bool IsViewKnown(const ServerView* view) const;
123 123
124 // These functions return true if the corresponding mojom function is allowed 124 // These functions return true if the corresponding mojom function is allowed
125 // for this connection. 125 // for this connection.
126 bool CanReorderView(const ServerView* view, 126 bool CanReorderView(const ServerView* view,
127 const ServerView* relative_view, 127 const ServerView* relative_view,
128 mojo::OrderDirection direction) const; 128 mojo::OrderDirection direction) const;
129 129
130 // Deletes a view owned by this connection. Returns true on success. |source| 130 // Deletes a view owned by this connection. Returns true on success. |source|
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 // Deletes all Views we own. 164 // Deletes all Views we own.
165 void DestroyViews(); 165 void DestroyViews();
166 166
167 bool CanEmbed(const ViewId& view_id, uint32_t policy_bitmask) const; 167 bool CanEmbed(const ViewId& view_id, uint32_t policy_bitmask) const;
168 void PrepareForEmbed(const ViewId& view_id); 168 void PrepareForEmbed(const ViewId& view_id);
169 void RemoveChildrenAsPartOfEmbed(const ViewId& view_id); 169 void RemoveChildrenAsPartOfEmbed(const ViewId& view_id);
170 170
171 // ViewTree: 171 // ViewTree:
172 void CreateView( 172 void CreateView(
173 mojo::Id transport_view_id, 173 Id transport_view_id,
174 const mojo::Callback<void(mojo::ErrorCode)>& callback) override; 174 const mojo::Callback<void(mojo::ErrorCode)>& callback) override;
175 void DeleteView(mojo::Id transport_view_id, 175 void DeleteView(Id transport_view_id,
176 const mojo::Callback<void(bool)>& callback) override; 176 const mojo::Callback<void(bool)>& callback) override;
177 void AddView(mojo::Id parent_id, 177 void AddView(Id parent_id,
178 mojo::Id child_id, 178 Id child_id,
179 const mojo::Callback<void(bool)>& callback) override; 179 const mojo::Callback<void(bool)>& callback) override;
180 void RemoveViewFromParent( 180 void RemoveViewFromParent(
181 mojo::Id view_id, 181 Id view_id,
182 const mojo::Callback<void(bool)>& callback) override; 182 const mojo::Callback<void(bool)>& callback) override;
183 void ReorderView(mojo::Id view_id, 183 void ReorderView(Id view_id,
184 mojo::Id relative_view_id, 184 Id relative_view_id,
185 mojo::OrderDirection direction, 185 mojo::OrderDirection direction,
186 const mojo::Callback<void(bool)>& callback) override; 186 const mojo::Callback<void(bool)>& callback) override;
187 void GetViewTree(mojo::Id view_id, 187 void GetViewTree(Id view_id,
188 const mojo::Callback<void(mojo::Array<mojo::ViewDataPtr>)>& 188 const mojo::Callback<void(mojo::Array<mojo::ViewDataPtr>)>&
189 callback) override; 189 callback) override;
190 void SetViewBounds(mojo::Id view_id, 190 void SetViewBounds(Id view_id,
191 mojo::RectPtr bounds, 191 mojo::RectPtr bounds,
192 const mojo::Callback<void(bool)>& callback) override; 192 const mojo::Callback<void(bool)>& callback) override;
193 void SetViewVisibility(mojo::Id view_id, 193 void SetViewVisibility(Id view_id,
194 bool visible, 194 bool visible,
195 const mojo::Callback<void(bool)>& callback) override; 195 const mojo::Callback<void(bool)>& callback) override;
196 void SetViewProperty(mojo::Id view_id, 196 void SetViewProperty(Id view_id,
197 const mojo::String& name, 197 const mojo::String& name,
198 mojo::Array<uint8_t> value, 198 mojo::Array<uint8_t> value,
199 const mojo::Callback<void(bool)>& callback) override; 199 const mojo::Callback<void(bool)>& callback) override;
200 void RequestSurface(mojo::Id view_id, 200 void RequestSurface(Id view_id,
201 mojo::InterfaceRequest<mojo::Surface> surface, 201 mojo::InterfaceRequest<mojo::Surface> surface,
202 mojo::SurfaceClientPtr client) override; 202 mojo::SurfaceClientPtr client) override;
203 void Embed(mojo::Id transport_view_id, 203 void Embed(Id transport_view_id,
204 mojo::ViewTreeClientPtr client, 204 mojo::ViewTreeClientPtr client,
205 uint32_t policy_bitmask, 205 uint32_t policy_bitmask,
206 const EmbedCallback& callback) override; 206 const EmbedCallback& callback) override;
207 void SetFocus(uint32_t view_id) override; 207 void SetFocus(uint32_t view_id) override;
208 void SetViewTextInputState(uint32_t view_id, 208 void SetViewTextInputState(uint32_t view_id,
209 mojo::TextInputStatePtr state) override; 209 mojo::TextInputStatePtr state) override;
210 void SetImeVisibility(mojo::Id transport_view_id, 210 void SetImeVisibility(Id transport_view_id,
211 bool visible, 211 bool visible,
212 mojo::TextInputStatePtr state) override; 212 mojo::TextInputStatePtr state) override;
213 213
214 // AccessPolicyDelegate: 214 // AccessPolicyDelegate:
215 bool IsRootForAccessPolicy(const ViewId& id) const override; 215 bool IsRootForAccessPolicy(const ViewId& id) const override;
216 bool IsViewKnownForAccessPolicy(const ServerView* view) const override; 216 bool IsViewKnownForAccessPolicy(const ServerView* view) const override;
217 bool IsViewRootOfAnotherConnectionForAccessPolicy( 217 bool IsViewRootOfAnotherConnectionForAccessPolicy(
218 const ServerView* view) const override; 218 const ServerView* view) const override;
219 bool IsDescendantOfEmbedRoot(const ServerView* view) override; 219 bool IsDescendantOfEmbedRoot(const ServerView* view) override;
220 220
221 ConnectionManager* connection_manager_; 221 ConnectionManager* connection_manager_;
222 222
223 // Id of this connection as assigned by ConnectionManager. 223 // Id of this connection as assigned by ConnectionManager.
224 const mojo::ConnectionSpecificId id_; 224 const ConnectionSpecificId id_;
225 225
226 // ID of the connection that created us. If 0 it indicates either we were 226 // ID of the connection that created us. If 0 it indicates either we were
227 // created by the root, or the connection that created us has been destroyed. 227 // created by the root, or the connection that created us has been destroyed.
228 mojo::ConnectionSpecificId creator_id_; 228 ConnectionSpecificId creator_id_;
229 229
230 mojo::ViewTreeClient* client_; 230 mojo::ViewTreeClient* client_;
231 231
232 scoped_ptr<view_manager::AccessPolicy> access_policy_; 232 scoped_ptr<mus::AccessPolicy> access_policy_;
233 233
234 // The views created by this connection. This connection owns these objects. 234 // The views created by this connection. This connection owns these objects.
235 ViewMap view_map_; 235 ViewMap view_map_;
236 236
237 // The set of views that has been communicated to the client. 237 // The set of views that has been communicated to the client.
238 ViewIdSet known_views_; 238 ViewIdSet known_views_;
239 239
240 // The root of this connection. This is a scoped_ptr to reinforce the 240 // The root of this connection. This is a scoped_ptr to reinforce the
241 // connection may have no root. A connection has no root if either the root 241 // connection may have no root. A connection has no root if either the root
242 // is destroyed or Embed() is invoked on the root. 242 // is destroyed or Embed() is invoked on the root.
243 scoped_ptr<ViewId> root_; 243 scoped_ptr<ViewId> root_;
244 244
245 bool is_embed_root_; 245 bool is_embed_root_;
246 246
247 DISALLOW_COPY_AND_ASSIGN(ViewTreeImpl); 247 DISALLOW_COPY_AND_ASSIGN(ViewTreeImpl);
248 }; 248 };
249 249
250 } // namespace view_manager 250 } // namespace mus
251 251
252 #endif // COMPONENTS_MUS_VIEW_TREE_IMPL_H_ 252 #endif // COMPONENTS_MUS_VIEW_TREE_IMPL_H_
OLDNEW
« no previous file with comments | « components/mus/view_tree_host_impl.cc ('k') | components/mus/view_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698