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

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: Updated all the namespaces in mus 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
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 ~ViewTreeImpl() override; 41 ~ViewTreeImpl() override;
42 42
43 // |services| and |exposed_services| are the ServiceProviders to pass to the 43 // |services| and |exposed_services| are the ServiceProviders to pass to the
44 // client via OnEmbed(). 44 // client via OnEmbed().
45 void Init(mojo::ViewTreeClient* client, mojo::ViewTreePtr tree); 45 void Init(mojo::ViewTreeClient* client, mojo::ViewTreePtr tree);
46 46
47 mojo::ConnectionSpecificId id() const { return id_; } 47 ConnectionSpecificId id() const { return id_; }
48 mojo::ConnectionSpecificId creator_id() const { return creator_id_; } 48 ConnectionSpecificId creator_id() const { return creator_id_; }
49 49
50 mojo::ViewTreeClient* client() { return client_; } 50 mojo::ViewTreeClient* client() { return client_; }
51 51
52 // Returns the View with the specified id. 52 // Returns the View with the specified id.
53 ServerView* GetView(const ViewId& id) { 53 ServerView* GetView(const ViewId& id) {
54 return const_cast<ServerView*>( 54 return const_cast<ServerView*>(
55 const_cast<const ViewTreeImpl*>(this)->GetView(id)); 55 const_cast<const ViewTreeImpl*>(this)->GetView(id));
56 } 56 }
57 const ServerView* GetView(const ViewId& id) const; 57 const ServerView* GetView(const ViewId& id) const;
58 58
(...skipping 12 matching lines...) Expand all
71 void OnWillDestroyViewTreeImpl(ViewTreeImpl* connection); 71 void OnWillDestroyViewTreeImpl(ViewTreeImpl* connection);
72 72
73 // These functions are synchronous variants of those defined in the mojom. The 73 // These functions are synchronous variants of those defined in the mojom. The
74 // ViewTree implementations all call into these. See the mojom for details. 74 // ViewTree implementations all call into these. See the mojom for details.
75 mojo::ErrorCode CreateView(const ViewId& view_id); 75 mojo::ErrorCode CreateView(const ViewId& view_id);
76 bool AddView(const ViewId& parent_id, const ViewId& child_id); 76 bool AddView(const ViewId& parent_id, const ViewId& child_id);
77 std::vector<const ServerView*> GetViewTree(const ViewId& view_id) const; 77 std::vector<const ServerView*> GetViewTree(const ViewId& view_id) const;
78 bool SetViewVisibility(const ViewId& view_id, bool visible); 78 bool SetViewVisibility(const ViewId& view_id, bool visible);
79 bool Embed(const ViewId& view_id, 79 bool Embed(const ViewId& view_id,
80 mojo::ViewTreeClientPtr client, 80 mojo::ViewTreeClientPtr client,
81 mojo::ConnectionSpecificId* connection_id); 81 ConnectionSpecificId* connection_id);
82 void Embed(const ViewId& view_id, mojo::URLRequestPtr request); 82 void Embed(const ViewId& view_id, mojo::URLRequestPtr request);
83 83
84 // The following methods are invoked after the corresponding change has been 84 // The following methods are invoked after the corresponding change has been
85 // processed. They do the appropriate bookkeeping and update the client as 85 // processed. They do the appropriate bookkeeping and update the client as
86 // necessary. 86 // necessary.
87 void ProcessViewBoundsChanged(const ServerView* view, 87 void ProcessViewBoundsChanged(const ServerView* view,
88 const gfx::Rect& old_bounds, 88 const gfx::Rect& old_bounds,
89 const gfx::Rect& new_bounds, 89 const gfx::Rect& new_bounds,
90 bool originated_change); 90 bool originated_change);
91 void ProcessViewportMetricsChanged(const mojo::ViewportMetrics& old_metrics, 91 void ProcessViewportMetricsChanged(const mojo::ViewportMetrics& old_metrics,
(...skipping 15 matching lines...) Expand all
107 const ServerView* relative_view, 107 const ServerView* relative_view,
108 mojo::OrderDirection direction, 108 mojo::OrderDirection direction,
109 bool originated_change); 109 bool originated_change);
110 void ProcessViewDeleted(const ViewId& view, bool originated_change); 110 void ProcessViewDeleted(const ViewId& view, bool originated_change);
111 void ProcessWillChangeViewVisibility(const ServerView* view, 111 void ProcessWillChangeViewVisibility(const ServerView* view,
112 bool originated_change); 112 bool originated_change);
113 void ProcessFocusChanged(const ServerView* old_focused_view, 113 void ProcessFocusChanged(const ServerView* old_focused_view,
114 const ServerView* new_focused_view); 114 const ServerView* new_focused_view);
115 115
116 private: 116 private:
117 using ViewIdSet = base::hash_set<mojo::Id>; 117 using ViewIdSet = base::hash_set<Id>;
118 using ViewMap = std::map<mojo::ConnectionSpecificId, ServerView*>; 118 using ViewMap = std::map<ConnectionSpecificId, ServerView*>;
119 119
120 bool IsViewKnown(const ServerView* view) const; 120 bool IsViewKnown(const ServerView* view) const;
121 121
122 // These functions return true if the corresponding mojom function is allowed 122 // These functions return true if the corresponding mojom function is allowed
123 // for this connection. 123 // for this connection.
124 bool CanReorderView(const ServerView* view, 124 bool CanReorderView(const ServerView* view,
125 const ServerView* relative_view, 125 const ServerView* relative_view,
126 mojo::OrderDirection direction) const; 126 mojo::OrderDirection direction) const;
127 127
128 // Deletes a view owned by this connection. Returns true on success. |source| 128 // Deletes a view owned by this connection. Returns true on success. |source|
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 // Deletes all Views we own. 162 // Deletes all Views we own.
163 void DestroyViews(); 163 void DestroyViews();
164 164
165 bool CanEmbed(const ViewId& view_id) const; 165 bool CanEmbed(const ViewId& view_id) const;
166 void PrepareForEmbed(const ViewId& view_id); 166 void PrepareForEmbed(const ViewId& view_id);
167 void RemoveChildrenAsPartOfEmbed(const ViewId& view_id); 167 void RemoveChildrenAsPartOfEmbed(const ViewId& view_id);
168 168
169 // ViewTree: 169 // ViewTree:
170 void CreateView( 170 void CreateView(
171 mojo::Id transport_view_id, 171 Id transport_view_id,
172 const mojo::Callback<void(mojo::ErrorCode)>& callback) override; 172 const mojo::Callback<void(mojo::ErrorCode)>& callback) override;
173 void DeleteView(mojo::Id transport_view_id, 173 void DeleteView(Id transport_view_id,
174 const mojo::Callback<void(bool)>& callback) override; 174 const mojo::Callback<void(bool)>& callback) override;
175 void AddView(mojo::Id parent_id, 175 void AddView(Id parent_id,
176 mojo::Id child_id, 176 Id child_id,
177 const mojo::Callback<void(bool)>& callback) override; 177 const mojo::Callback<void(bool)>& callback) override;
178 void RemoveViewFromParent( 178 void RemoveViewFromParent(
179 mojo::Id view_id, 179 Id view_id,
180 const mojo::Callback<void(bool)>& callback) override; 180 const mojo::Callback<void(bool)>& callback) override;
181 void ReorderView(mojo::Id view_id, 181 void ReorderView(Id view_id,
182 mojo::Id relative_view_id, 182 Id relative_view_id,
183 mojo::OrderDirection direction, 183 mojo::OrderDirection direction,
184 const mojo::Callback<void(bool)>& callback) override; 184 const mojo::Callback<void(bool)>& callback) override;
185 void GetViewTree(mojo::Id view_id, 185 void GetViewTree(Id view_id,
186 const mojo::Callback<void(mojo::Array<mojo::ViewDataPtr>)>& 186 const mojo::Callback<void(mojo::Array<mojo::ViewDataPtr>)>&
187 callback) override; 187 callback) override;
188 void SetViewBounds(mojo::Id view_id, 188 void SetViewBounds(Id view_id,
189 mojo::RectPtr bounds, 189 mojo::RectPtr bounds,
190 const mojo::Callback<void(bool)>& callback) override; 190 const mojo::Callback<void(bool)>& callback) override;
191 void SetViewVisibility(mojo::Id view_id, 191 void SetViewVisibility(Id view_id,
192 bool visible, 192 bool visible,
193 const mojo::Callback<void(bool)>& callback) override; 193 const mojo::Callback<void(bool)>& callback) override;
194 void SetViewProperty(mojo::Id view_id, 194 void SetViewProperty(Id view_id,
195 const mojo::String& name, 195 const mojo::String& name,
196 mojo::Array<uint8_t> value, 196 mojo::Array<uint8_t> value,
197 const mojo::Callback<void(bool)>& callback) override; 197 const mojo::Callback<void(bool)>& callback) override;
198 void RequestSurface(mojo::Id view_id, 198 void RequestSurface(Id view_id,
199 mojo::InterfaceRequest<mojo::Surface> surface, 199 mojo::InterfaceRequest<mojo::Surface> surface,
200 mojo::SurfaceClientPtr client) override; 200 mojo::SurfaceClientPtr client) override;
201 void Embed(mojo::Id transport_view_id, 201 void Embed(Id transport_view_id,
202 mojo::ViewTreeClientPtr client, 202 mojo::ViewTreeClientPtr client,
203 const EmbedCallback& callback) override; 203 const EmbedCallback& callback) override;
204 void SetFocus(uint32_t view_id) override; 204 void SetFocus(uint32_t view_id) override;
205 void SetViewTextInputState(uint32_t view_id, 205 void SetViewTextInputState(uint32_t view_id,
206 mojo::TextInputStatePtr state) override; 206 mojo::TextInputStatePtr state) override;
207 void SetImeVisibility(mojo::Id transport_view_id, 207 void SetImeVisibility(Id transport_view_id,
208 bool visible, 208 bool visible,
209 mojo::TextInputStatePtr state) override; 209 mojo::TextInputStatePtr state) override;
210 void SetAccessPolicy(mojo::Id transport_view_id, 210 void SetAccessPolicy(Id transport_view_id, uint32 policy_bitmask) override;
211 uint32 policy_bitmask) override;
212 211
213 // AccessPolicyDelegate: 212 // AccessPolicyDelegate:
214 bool IsRootForAccessPolicy(const ViewId& id) const override; 213 bool IsRootForAccessPolicy(const ViewId& id) const override;
215 bool IsViewKnownForAccessPolicy(const ServerView* view) const override; 214 bool IsViewKnownForAccessPolicy(const ServerView* view) const override;
216 bool IsViewRootOfAnotherConnectionForAccessPolicy( 215 bool IsViewRootOfAnotherConnectionForAccessPolicy(
217 const ServerView* view) const override; 216 const ServerView* view) const override;
218 bool IsDescendantOfEmbedRoot(const ServerView* view) override; 217 bool IsDescendantOfEmbedRoot(const ServerView* view) override;
219 218
220 ConnectionManager* connection_manager_; 219 ConnectionManager* connection_manager_;
221 220
222 // Id of this connection as assigned by ConnectionManager. 221 // Id of this connection as assigned by ConnectionManager.
223 const mojo::ConnectionSpecificId id_; 222 const ConnectionSpecificId id_;
224 223
225 // ID of the connection that created us. If 0 it indicates either we were 224 // ID of the connection that created us. If 0 it indicates either we were
226 // created by the root, or the connection that created us has been destroyed. 225 // created by the root, or the connection that created us has been destroyed.
227 mojo::ConnectionSpecificId creator_id_; 226 ConnectionSpecificId creator_id_;
228 227
229 mojo::ViewTreeClient* client_; 228 mojo::ViewTreeClient* client_;
230 229
231 scoped_ptr<view_manager::AccessPolicy> access_policy_; 230 scoped_ptr<mus::AccessPolicy> access_policy_;
232 231
233 // The views created by this connection. This connection owns these objects. 232 // The views created by this connection. This connection owns these objects.
234 ViewMap view_map_; 233 ViewMap view_map_;
235 234
236 // The set of views that has been communicated to the client. 235 // The set of views that has been communicated to the client.
237 ViewIdSet known_views_; 236 ViewIdSet known_views_;
238 237
239 // The root of this connection. This is a scoped_ptr to reinforce the 238 // The root of this connection. This is a scoped_ptr to reinforce the
240 // connection may have no root. A connection has no root if either the root 239 // connection may have no root. A connection has no root if either the root
241 // is destroyed or Embed() is invoked on the root. 240 // is destroyed or Embed() is invoked on the root.
242 scoped_ptr<ViewId> root_; 241 scoped_ptr<ViewId> root_;
243 242
244 bool is_embed_root_; 243 bool is_embed_root_;
245 244
246 DISALLOW_COPY_AND_ASSIGN(ViewTreeImpl); 245 DISALLOW_COPY_AND_ASSIGN(ViewTreeImpl);
247 }; 246 };
248 247
249 } // namespace view_manager 248 } // namespace mus
250 249
251 #endif // COMPONENTS_MUS_VIEW_TREE_IMPL_H_ 250 #endif // COMPONENTS_MUS_VIEW_TREE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698