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 module mojo; | 5 module mojo; |
6 | 6 |
7 import "components/view_manager/public/interfaces/surface_id.mojom"; | 7 import "components/view_manager/public/interfaces/surface_id.mojom"; |
8 import "components/view_manager/public/interfaces/view_manager_constants.mojom"; | 8 import "components/view_manager/public/interfaces/view_manager_constants.mojom"; |
9 import "mojo/application/public/interfaces/service_provider.mojom"; | 9 import "mojo/application/public/interfaces/service_provider.mojom"; |
10 import "network/public/interfaces/url_loader.mojom"; | 10 import "network/public/interfaces/url_loader.mojom"; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // Returns the views comprising the tree starting at |view_id|. |view_id| is | 105 // Returns the views comprising the tree starting at |view_id|. |view_id| is |
106 // the first result in the return value, unless |view_id| is invalid, in which | 106 // the first result in the return value, unless |view_id| is invalid, in which |
107 // case an empty vector is returned. The views are visited using a depth first | 107 // case an empty vector is returned. The views are visited using a depth first |
108 // search (pre-order). | 108 // search (pre-order). |
109 GetViewTree(uint32 view_id) => (array<ViewData> views); | 109 GetViewTree(uint32 view_id) => (array<ViewData> views); |
110 | 110 |
111 // Shows the surface in the specified view. | 111 // Shows the surface in the specified view. |
112 SetViewSurfaceId(uint32 view_id, SurfaceId surface_id) => (bool success); | 112 SetViewSurfaceId(uint32 view_id, SurfaceId surface_id) => (bool success); |
113 | 113 |
114 // Tells the ViewManagerService that the ViewManagerClient wants to get | 114 // Tells the ViewManagerService that the ViewManagerClient wants to get |
115 // OnWillEmbed() when Embed() is invoked on any descendant Views created by | 115 // OnEmbedForDescendant() when EmbedAllowingReembed() is invoked on any |
116 // other ViewManagerClients. | 116 // descendant Views. |
117 // | 117 // |
118 // See Embed() docs for more details. | 118 // See Embed() docs for more details. |
119 // | 119 // |
120 // TODO(sky): this needs to be restricted in some way. Maybe the root can | 120 // TODO(sky): this needs to be restricted in some way. Maybe the root can |
121 // grant this ability? | 121 // grant this ability? |
122 SetEmbedRoot(); | 122 SetEmbedRoot(); |
123 | 123 |
124 // A connection may grant access to a view from another connection by way of | 124 // A connection may grant access to a view from another connection by way of |
125 // the embed functions. The following variants exist: | 125 // the embed functions. The following variants exist: |
126 // | 126 // |
127 // . EmbedRequest: the ViewManager connects to the app at the supplied request | 127 // . Embed: the client supplies the ViewManagerClient to embed. |
128 // and asks it for a ViewManagerClient. | 128 // . EmbedAllowingReembed: walks the view tree for the first embed root |
129 // . Embed: the client supplies the ViewManagerClient to use. | 129 // ancestor and asks it to perform the embed (OnEmbedForDescendant()). |
130 // . EmbedAllowingReembed: similar to EmbedRequest(), but no | 130 // The embed root ancestor may allow or disallow the request. If there is no |
131 // ServiceProviders are supplied. Additionally this version allows an | 131 // embed root ancestor ViewManager connects to the application and requests |
132 // EmbedRoot ancestor to call Embed() in this view at a later date. | 132 // a ViewManagerClient from it. |
133 // | 133 // |
134 // In all cases the new ViewManagerClient is configured with a root of | 134 // In all cases the new ViewManagerClient is configured with a root of |
135 // |view_id|. | 135 // |view_id|. |
136 // | 136 // |
137 // The caller must have created |view_id|. If not the request fails and the | 137 // The caller must have created |view_id|. If not the request fails and the |
138 // response is false. | 138 // response is false. |
139 // | 139 // |
140 // A view may only be a root of one connection at a time. Subsequent calls to | 140 // A view may only have one embedding in it at a time. Subsequent calls to |
141 // Embed() for the same view result in the view being removed from the | 141 // Embed() for the same view result in the currently embedded |
142 // currently embedded app. The embedded app is told this by way of | 142 // ViewManagerClient being removed. The embedded app is told this by way of |
143 // OnViewDeleted(). | 143 // OnViewDeleted(). |
144 // | 144 // |
145 // The embedder can detect when the embedded app disconnects by way of | 145 // The embedder can detect when the embedded app disconnects by way of |
146 // OnEmbeddedAppDisconnected(). | 146 // OnEmbeddedAppDisconnected(). |
147 // | 147 // |
148 // When a connection embeds an app the connection no longer has priviledges | 148 // When a connection embeds an app the connection no longer has priviledges |
149 // to access or see any of the children of the view. If the view had existing | 149 // to access or see any of the children of the view. If the view had existing |
150 // children the children are removed. The one exception is the root | 150 // children the children are removed. The one exception is the root |
151 // connection and any embed roots. Embed roots always see the full tree. | 151 // connection and any embed roots. The root always see the full tree, and |
152 // | 152 // embed roots see the complete tree at their embed point. |
153 // The embed functions call OnWillEmbed() on the first ancestor that has | |
154 // been set as an embed root. | |
155 // | |
156 // |services| encapsulates services offered by the embedder to the embedded | |
157 // app alongside this Embed() call. |exposed_services| provides a means for | |
158 // the embedder to connect to services exposed by the embedded app. Note that | |
159 // if a different app is subsequently embedded at |view_id| the | |
160 // ServiceProvider connections to its client in the embedded app and any | |
161 // services it provided are not broken and continue to be valid. | |
162 EmbedRequest(URLRequest request, | |
163 uint32 view_id, | |
164 ServiceProvider&? services, | |
165 ServiceProvider? exposed_services) => (bool success); | |
166 Embed(uint32 view_id, ViewManagerClient client) => (bool success); | 153 Embed(uint32 view_id, ViewManagerClient client) => (bool success); |
167 EmbedAllowingReembed(URLRequest request, uint32 view_id) => (bool success); | 154 EmbedAllowingReembed(uint32 view_id, URLRequest request) => (bool success); |
168 | 155 |
169 SetFocus(uint32 view_id) => (bool success); | 156 SetFocus(uint32 view_id) => (bool success); |
170 }; | 157 }; |
171 | 158 |
172 // Changes to views are not sent to the connection that originated the | 159 // Changes to views are not sent to the connection that originated the |
173 // change. For example, if connection 1 changes the bounds of a view by calling | 160 // change. For example, if connection 1 changes the bounds of a view by calling |
174 // SetBounds(), connection 1 does not receive OnViewBoundsChanged(). | 161 // SetBounds(), connection 1 does not receive OnViewBoundsChanged(). |
175 interface ViewManagerClient { | 162 interface ViewManagerClient { |
176 // Invoked when the client application has been embedded at |root|. | 163 // Invoked when the client application has been embedded at |root|. |
177 // See Embed() on ViewManagerService for more details. |view_manager_service| | 164 // See Embed() on ViewManagerService for more details. |view_manager_service| |
178 // will be a handle back to the view manager service, unless the connection is | 165 // will be a handle back to the view manager service, unless the connection is |
179 // to the WindowManager in which case it will be null. | 166 // to the WindowManager in which case it will be null. |
180 OnEmbed(uint16 connection_id, | 167 OnEmbed(uint16 connection_id, |
181 string embedder_url, | |
182 ViewData root, | 168 ViewData root, |
183 ViewManagerService? view_manager_service, | 169 ViewManagerService? view_manager_service, |
184 ServiceProvider&? services, | |
185 ServiceProvider? exposed_services, | |
186 uint32 focused_view); | 170 uint32 focused_view); |
187 | 171 |
188 // Notifies a ViewManagerClient that an embed is about to happen. The | 172 // Asks the ViewManagerClient that was marked as an embed root for the |
189 // ViewManagerClient can decide not to allow the embed as well as changing | 173 // ViewManagerClient to embed in |view|. The embed can be disallowed by |
190 // the ServiceProviders that are exposed as a result of the embed. This is | 174 // calling the callback with nullptr. |
191 // only invoked once per embed, and is invoked on the first ancestor that has | 175 OnEmbedForDescendant(uint32 view, URLRequest request) => |
192 // invoked SetEmbedRoot(). | 176 (ViewManagerClient? client); |
193 OnWillEmbed(uint32 view, | |
194 ServiceProvider&? services, | |
195 ServiceProvider? exposed_services) => | |
196 (bool proceed_with_embed, | |
197 ServiceProvider&? services, | |
198 ServiceProvider? exposed_services); | |
199 | 177 |
200 // Invoked when the application embedded at |view| is disconnected. | 178 // Invoked when the application embedded at |view| is disconnected. |
201 OnEmbeddedAppDisconnected(uint32 view); | 179 OnEmbeddedAppDisconnected(uint32 view); |
202 | 180 |
203 // Invoked when a view's bounds have changed. | 181 // Invoked when a view's bounds have changed. |
204 OnViewBoundsChanged(uint32 view, | 182 OnViewBoundsChanged(uint32 view, |
205 mojo.Rect old_bounds, | 183 mojo.Rect old_bounds, |
206 mojo.Rect new_bounds); | 184 mojo.Rect new_bounds); |
207 | 185 |
208 // Invoked when the viewport metrics for the view have changed. | 186 // Invoked when the viewport metrics for the view have changed. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 224 |
247 // Invoked when a view property is changed. If this change is a removal, | 225 // Invoked when a view property is changed. If this change is a removal, |
248 // |new_data| is null. | 226 // |new_data| is null. |
249 OnViewSharedPropertyChanged(uint32 view, string name, array<uint8>? new_data); | 227 OnViewSharedPropertyChanged(uint32 view, string name, array<uint8>? new_data); |
250 | 228 |
251 // Invoked when an event is targeted at the specified view. | 229 // Invoked when an event is targeted at the specified view. |
252 OnViewInputEvent(uint32 view, mojo.Event event) => (); | 230 OnViewInputEvent(uint32 view, mojo.Event event) => (); |
253 | 231 |
254 OnViewFocused(uint32 focused_view_id); | 232 OnViewFocused(uint32 focused_view_id); |
255 }; | 233 }; |
OLD | NEW |