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

Side by Side Diff: components/view_manager/view_manager_service_impl.h

Issue 1166123005: Removes ServiceProviders from ViewManager::Embed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use is_headless rather than check for browser. Created 5 years, 6 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_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ 5 #ifndef COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_
6 #define COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ 6 #define COMPONENTS_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 17 matching lines...) Expand all
28 class ConnectionManager; 28 class ConnectionManager;
29 class ServerView; 29 class ServerView;
30 30
31 // An instance of ViewManagerServiceImpl is created for every ViewManagerService 31 // An instance of ViewManagerServiceImpl is created for every ViewManagerService
32 // request. ViewManagerServiceImpl tracks all the state and views created by a 32 // request. ViewManagerServiceImpl tracks all the state and views created by a
33 // client. ViewManagerServiceImpl coordinates with ConnectionManager to update 33 // client. ViewManagerServiceImpl coordinates with ConnectionManager to update
34 // the client (and internal state) as necessary. 34 // the client (and internal state) as necessary.
35 class ViewManagerServiceImpl : public mojo::ViewManagerService, 35 class ViewManagerServiceImpl : public mojo::ViewManagerService,
36 public AccessPolicyDelegate { 36 public AccessPolicyDelegate {
37 public: 37 public:
38 enum class EmbedType {
39 ALLOW_REEMBED,
40 NO_REEMBED,
41 };
42
43 ViewManagerServiceImpl(ConnectionManager* connection_manager, 38 ViewManagerServiceImpl(ConnectionManager* connection_manager,
44 mojo::ConnectionSpecificId creator_id, 39 mojo::ConnectionSpecificId creator_id,
45 const std::string& creator_url,
46 const std::string& url,
47 const ViewId& root_id); 40 const ViewId& root_id);
48 ~ViewManagerServiceImpl() override; 41 ~ViewManagerServiceImpl() override;
49 42
50 // |services| and |exposed_services| are the ServiceProviders to pass to the 43 // |services| and |exposed_services| are the ServiceProviders to pass to the
51 // client via OnEmbed(). 44 // client via OnEmbed().
52 void Init(mojo::ViewManagerClient* client, 45 void Init(mojo::ViewManagerClient* client,
53 mojo::ViewManagerServicePtr service_ptr, 46 mojo::ViewManagerServicePtr service_ptr);
54 mojo::InterfaceRequest<mojo::ServiceProvider> services,
55 mojo::ServiceProviderPtr exposed_services);
56 47
57 mojo::ConnectionSpecificId id() const { return id_; } 48 mojo::ConnectionSpecificId id() const { return id_; }
58 mojo::ConnectionSpecificId creator_id() const { return creator_id_; } 49 mojo::ConnectionSpecificId creator_id() const { return creator_id_; }
59 const std::string& url() const { return url_; }
60 50
61 mojo::ViewManagerClient* client() { return client_; } 51 mojo::ViewManagerClient* client() { return client_; }
62 52
63 // Returns the View with the specified id. 53 // Returns the View with the specified id.
64 ServerView* GetView(const ViewId& id) { 54 ServerView* GetView(const ViewId& id) {
65 return const_cast<ServerView*>( 55 return const_cast<ServerView*>(
66 const_cast<const ViewManagerServiceImpl*>(this)->GetView(id)); 56 const_cast<const ViewManagerServiceImpl*>(this)->GetView(id));
67 } 57 }
68 const ServerView* GetView(const ViewId& id) const; 58 const ServerView* GetView(const ViewId& id) const;
69 59
70 // Returns true if this connection's root is |id|. 60 // Returns true if this connection's root is |id|.
71 bool IsRoot(const ViewId& id) const; 61 bool IsRoot(const ViewId& id) const;
72 62
73 // Returns the id of the root node. This is null if the root has been 63 // Returns the id of the root node. This is null if the root has been
74 // destroyed but the connection is still valid. 64 // destroyed but the connection is still valid.
75 const ViewId* root() const { return root_.get(); } 65 const ViewId* root() const { return root_.get(); }
76 66
77 bool is_embed_root() const { return is_embed_root_; } 67 bool is_embed_root() const { return is_embed_root_; }
78 68
79 // Invoked when a connection is about to be destroyed. 69 // Invoked when a connection is about to be destroyed.
80 void OnWillDestroyViewManagerServiceImpl(ViewManagerServiceImpl* connection); 70 void OnWillDestroyViewManagerServiceImpl(ViewManagerServiceImpl* connection);
81 71
82 // These functions are synchronous variants of those defined in the mojom. The 72 // These functions are synchronous variants of those defined in the mojom. The
83 // ViewManagerService implementations all call into these. See the mojom for 73 // ViewManagerService implementations all call into these. See the mojom for
84 // details. 74 // details.
85 mojo::ErrorCode CreateView(const ViewId& view_id); 75 mojo::ErrorCode CreateView(const ViewId& view_id);
86 bool AddView(const ViewId& parent_id, const ViewId& child_id); 76 bool AddView(const ViewId& parent_id, const ViewId& child_id);
87 std::vector<const ServerView*> GetViewTree(const ViewId& view_id) const; 77 std::vector<const ServerView*> GetViewTree(const ViewId& view_id) const;
88 bool SetViewVisibility(const ViewId& view_id, bool visible); 78 bool SetViewVisibility(const ViewId& view_id, bool visible);
89 void Embed(mojo::URLRequestPtr request, 79 void EmbedAllowingReembed(const ViewId& view_id,
90 const ViewId& view_id, 80 mojo::URLRequestPtr request,
91 EmbedType type, 81 const mojo::Callback<void(bool)>& callback);
92 mojo::InterfaceRequest<mojo::ServiceProvider> services,
93 mojo::ServiceProviderPtr exposed_services,
94 const mojo::Callback<void(bool)>& callback);
95 bool Embed(const ViewId& view_id, mojo::ViewManagerClientPtr client); 82 bool Embed(const ViewId& view_id, mojo::ViewManagerClientPtr client);
96 83
97 // The following methods are invoked after the corresponding change has been 84 // The following methods are invoked after the corresponding change has been
98 // processed. They do the appropriate bookkeeping and update the client as 85 // processed. They do the appropriate bookkeeping and update the client as
99 // necessary. 86 // necessary.
100 void ProcessViewBoundsChanged(const ServerView* view, 87 void ProcessViewBoundsChanged(const ServerView* view,
101 const gfx::Rect& old_bounds, 88 const gfx::Rect& old_bounds,
102 const gfx::Rect& new_bounds, 89 const gfx::Rect& new_bounds,
103 bool originated_change); 90 bool originated_change);
104 void ProcessViewportMetricsChanged(const mojo::ViewportMetrics& old_metrics, 91 void ProcessViewportMetricsChanged(const mojo::ViewportMetrics& old_metrics,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // Notify the client if the drawn state of any of the roots changes. 160 // Notify the client if the drawn state of any of the roots changes.
174 // |view| is the view that is changing to the drawn state |new_drawn_value|. 161 // |view| is the view that is changing to the drawn state |new_drawn_value|.
175 void NotifyDrawnStateChanged(const ServerView* view, bool new_drawn_value); 162 void NotifyDrawnStateChanged(const ServerView* view, bool new_drawn_value);
176 163
177 // Deletes all Views we own. 164 // Deletes all Views we own.
178 void DestroyViews(); 165 void DestroyViews();
179 166
180 bool CanEmbed(const ViewId& view_id) const; 167 bool CanEmbed(const ViewId& view_id) const;
181 void PrepareForEmbed(const ViewId& view_id); 168 void PrepareForEmbed(const ViewId& view_id);
182 void RemoveChildrenAsPartOfEmbed(const ViewId& view_id); 169 void RemoveChildrenAsPartOfEmbed(const ViewId& view_id);
183 void OnWillEmbedDone(scoped_refptr<PendingEmbed> pending_embed, 170 void OnEmbedForDescendantDone(scoped_refptr<PendingEmbed> pending_embed,
184 bool allow_embed, 171 mojo::ViewManagerClientPtr client);
185 mojo::InterfaceRequest<mojo::ServiceProvider> services,
186 mojo::ServiceProviderPtr exposed_services);
187 172
188 // Invalidates any PendingEmbeds with |connection| as the embed root. 173 // Invalidates any PendingEmbeds with |connection| as the embed root.
189 void InvalidatePendingEmbedForConnection(ViewManagerServiceImpl* connection); 174 void InvalidatePendingEmbedForConnection(ViewManagerServiceImpl* connection);
190 175
191 // Invalidates any PendingEmbemds targetting |view_id|. 176 // Invalidates any PendingEmbemds targetting |view_id|.
192 void InvalidatePendingEmbedForView(const ViewId& view_id); 177 void InvalidatePendingEmbedForView(const ViewId& view_id);
193 178
194 // Runs the callback for |embed| and releases it. 179 // Runs the callback for |embed| and releases it.
195 void RemovePendingEmbedAndNotifyCallback(scoped_refptr<PendingEmbed> embed, 180 void RemovePendingEmbedAndNotifyCallback(scoped_refptr<PendingEmbed> embed,
196 bool success); 181 bool success);
(...skipping 24 matching lines...) Expand all
221 mojo::RectPtr bounds, 206 mojo::RectPtr bounds,
222 const mojo::Callback<void(bool)>& callback) override; 207 const mojo::Callback<void(bool)>& callback) override;
223 void SetViewVisibility(mojo::Id view_id, 208 void SetViewVisibility(mojo::Id view_id,
224 bool visible, 209 bool visible,
225 const mojo::Callback<void(bool)>& callback) override; 210 const mojo::Callback<void(bool)>& callback) override;
226 void SetViewProperty(mojo::Id view_id, 211 void SetViewProperty(mojo::Id view_id,
227 const mojo::String& name, 212 const mojo::String& name,
228 mojo::Array<uint8_t> value, 213 mojo::Array<uint8_t> value,
229 const mojo::Callback<void(bool)>& callback) override; 214 const mojo::Callback<void(bool)>& callback) override;
230 void SetEmbedRoot() override; 215 void SetEmbedRoot() override;
231 void EmbedRequest(mojo::URLRequestPtr request,
232 mojo::Id transport_view_id,
233 mojo::InterfaceRequest<mojo::ServiceProvider> services,
234 mojo::ServiceProviderPtr exposed_services,
235 const mojo::Callback<void(bool)>& callback) override;
236 void Embed(mojo::Id transport_view_id, 216 void Embed(mojo::Id transport_view_id,
237 mojo::ViewManagerClientPtr client, 217 mojo::ViewManagerClientPtr client,
238 const mojo::Callback<void(bool)>& callback) override; 218 const mojo::Callback<void(bool)>& callback) override;
239 void EmbedAllowingReembed( 219 void EmbedAllowingReembed(
220 mojo::Id transport_view_id,
240 mojo::URLRequestPtr request, 221 mojo::URLRequestPtr request,
241 mojo::Id transport_view_id,
242 const mojo::Callback<void(bool)>& callback) override; 222 const mojo::Callback<void(bool)>& callback) override;
243 void SetFocus(uint32_t view_id, const SetFocusCallback& callback) override; 223 void SetFocus(uint32_t view_id, const SetFocusCallback& callback) override;
244 224
245 // AccessPolicyDelegate: 225 // AccessPolicyDelegate:
246 bool IsRootForAccessPolicy(const ViewId& id) const override; 226 bool IsRootForAccessPolicy(const ViewId& id) const override;
247 bool IsViewKnownForAccessPolicy(const ServerView* view) const override; 227 bool IsViewKnownForAccessPolicy(const ServerView* view) const override;
248 bool IsViewRootOfAnotherConnectionForAccessPolicy( 228 bool IsViewRootOfAnotherConnectionForAccessPolicy(
249 const ServerView* view) const override; 229 const ServerView* view) const override;
250 bool IsEmbedRootForAccessPolicy() override; 230 bool IsEmbedRootForAccessPolicy() override;
251 231
252 ConnectionManager* connection_manager_; 232 ConnectionManager* connection_manager_;
253 233
254 // Id of this connection as assigned by ConnectionManager. 234 // Id of this connection as assigned by ConnectionManager.
255 const mojo::ConnectionSpecificId id_; 235 const mojo::ConnectionSpecificId id_;
256 236
257 // URL this connection was created for.
258 const std::string url_;
259
260 // ID of the connection that created us. If 0 it indicates either we were 237 // ID of the connection that created us. If 0 it indicates either we were
261 // created by the root, or the connection that created us has been destroyed. 238 // created by the root, or the connection that created us has been destroyed.
262 mojo::ConnectionSpecificId creator_id_; 239 mojo::ConnectionSpecificId creator_id_;
263 240
264 // The URL of the app that embedded the app this connection was created for.
265 // NOTE: this is empty if the connection was created by way of directly
266 // supplying the ViewManagerClient.
267 const std::string creator_url_;
268
269 mojo::ViewManagerClient* client_; 241 mojo::ViewManagerClient* client_;
270 242
271 scoped_ptr<AccessPolicy> access_policy_; 243 scoped_ptr<AccessPolicy> access_policy_;
272 244
273 // The views created by this connection. This connection owns these objects. 245 // The views created by this connection. This connection owns these objects.
274 ViewMap view_map_; 246 ViewMap view_map_;
275 247
276 // The set of views that has been communicated to the client. 248 // The set of views that has been communicated to the client.
277 ViewIdSet known_views_; 249 ViewIdSet known_views_;
278 250
279 // The root of this connection. This is a scoped_ptr to reinforce the 251 // The root of this connection. This is a scoped_ptr to reinforce the
280 // connection may have no root. A connection has no root if either the root 252 // connection may have no root. A connection has no root if either the root
281 // is destroyed or Embed() is invoked on the root. 253 // is destroyed or Embed() is invoked on the root.
282 scoped_ptr<ViewId> root_; 254 scoped_ptr<ViewId> root_;
283 255
284 bool is_embed_root_; 256 bool is_embed_root_;
285 257
286 // If we have an ancestor marked as an embed root then we have to query it 258 // If we have an ancestor marked as an embed root then we have to query it
287 // before completing the embed. |pending_embeds_| contains such requests. 259 // before completing the embed. |pending_embeds_| contains such requests.
288 // The requests are removed if the embed becomes invalid, for example, the 260 // The requests are removed if the embed becomes invalid, for example, the
289 // view embed was called for is removed. 261 // view embed was called for is removed.
290 std::set<scoped_refptr<PendingEmbed>> pending_embeds_; 262 std::set<scoped_refptr<PendingEmbed>> pending_embeds_;
291 263
292 DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceImpl); 264 DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceImpl);
293 }; 265 };
294 266
295 } // namespace view_manager 267 } // namespace view_manager
296 268
297 #endif // COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ 269 #endif // COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « components/view_manager/view_manager_service_apptest.cc ('k') | components/view_manager/view_manager_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698