OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 [DartPackage="mojo_services"] | |
6 module mojo; | |
7 | |
8 import "geometry/interfaces/geometry.mojom"; | |
9 import "input_events/interfaces/input_events.mojom"; | |
10 import "mojo/public/interfaces/application/service_provider.mojom"; | |
11 import "native_viewport/interfaces/native_viewport.mojom"; | |
12 import "surfaces/interfaces/surface_id.mojom"; | |
13 import "view_manager/interfaces/view_manager_constants.mojom"; | |
14 | |
15 struct ViewData { | |
16 uint32 parent_id; | |
17 uint32 view_id; | |
18 mojo.Rect bounds; | |
19 map<string, array<uint8>> properties; | |
20 // True if this view is visible. The view may not be drawn on screen (see | |
21 // drawn for specifics). | |
22 bool visible; | |
23 // True if this view is drawn on screen. A view is drawn if attached to the | |
24 // root and all ancestors (including this view) are visible. | |
25 bool drawn; | |
26 ViewportMetrics viewport_metrics; | |
27 }; | |
28 | |
29 enum ErrorCode { | |
30 NONE, | |
31 VALUE_IN_USE, | |
32 ILLEGAL_ARGUMENT, | |
33 }; | |
34 | |
35 // Views are identified by a uint32. The upper 16 bits are the connection id, | |
36 // and the lower 16 the id assigned by the client. | |
37 // | |
38 // The root view is identified with a connection id of 0, and value of 1. | |
39 [ServiceName="mojo::ViewManagerService"] | |
40 interface ViewManagerService { | |
41 // Creates a new view with the specified id. It is up to the client to ensure | |
42 // the id is unique to the connection (the id need not be globally unique). | |
43 // Additionally the connection id (embedded in |view_id|) must match that of | |
44 // the connection. | |
45 // Errors: | |
46 // ERROR_CODE_VALUE_IN_USE: a view already exists with the specified id. | |
47 // ERROR_CODE_ILLEGAL_ARGUMENT: The connection part of |view_id| does not | |
48 // match the connection id of the client. | |
49 // | |
50 // TODO(erg): Once we have default values in mojo, make this take a map of | |
51 // properties. | |
52 CreateView(uint32 view_id) => (ErrorCode error_code); | |
53 | |
54 // Deletes a view. This does not recurse. No hierarchy change notifications | |
55 // are sent as a result of this. Only the connection that created the view can | |
56 // delete it. | |
57 DeleteView(uint32 view_id) => (bool success); | |
58 | |
59 // Sets the specified bounds of the specified view. | |
60 SetViewBounds(uint32 view_id, mojo.Rect bounds) => (bool success); | |
61 | |
62 // Sets the visibility of the specified view to |visible|. Connections are | |
63 // allowed to change the visibility of any view they have created, as well as | |
64 // any of their roots. | |
65 SetViewVisibility(uint32 view_id, bool visible) => (bool success); | |
66 | |
67 // Sets an individual named property. Setting an individual property to null | |
68 // deletes the property. | |
69 SetViewProperty(uint32 view_id, | |
70 string name, | |
71 array<uint8>? value) => (bool success); | |
72 | |
73 // Reparents a view. | |
74 // This fails for any of the following reasons: | |
75 // . |parent| or |child| does not identify a valid view. | |
76 // . |child| is an ancestor of |parent|. | |
77 // . |child| is already a child of |parent|. | |
78 // | |
79 // This may result in a connection getting OnViewDeleted(). See | |
80 // RemoveViewFromParent for details. | |
81 AddView(uint32 parent, uint32 child) => (bool success); | |
82 | |
83 // Removes a view from its current parent. This fails if the view is not | |
84 // valid or the view already has no parent. | |
85 // | |
86 // Removing a view from a parent may result in OnViewDeleted() being sent to | |
87 // other connections. For example, connection A has views 1 and 2, with 2 a | |
88 // child of 1. Connection B has a root 1. If 2 is removed from 1 then B gets | |
89 // OnViewDeleted(). This is done as view 2 is effectively no longer visible to | |
90 // connection B. | |
91 RemoveViewFromParent(uint32 view_id) => (bool success); | |
92 | |
93 // Reorders a view in its parent, relative to |relative_view_id| according to | |
94 // |direction|. | |
95 // Only the connection that created the view's parent can reorder its | |
96 // children. | |
97 ReorderView(uint32 view_id, | |
98 uint32 relative_view_id, | |
99 OrderDirection direction) => (bool success); | |
100 | |
101 // Returns the views comprising the tree starting at |view_id|. |view_id| is | |
102 // the first result in the return value, unless |view_id| is invalid, in which | |
103 // case an empty vector is returned. The views are visited using a depth first | |
104 // search (pre-order). | |
105 GetViewTree(uint32 view_id) => (array<ViewData> views); | |
106 | |
107 // Shows the surface in the specified view. | |
108 SetViewSurfaceId(uint32 view_id, SurfaceId surface_id) => (bool success); | |
109 | |
110 // A connection may grant access to a view from another connection by way of | |
111 // the embed functions. There are two variants of this call: | |
112 // | |
113 // . EmbedUrl: the ViewManager connects to the app at the supplied url and | |
114 // asks it for a ViewManagerClient. | |
115 // . With the second variant a ViewManagerClient is directly supplied. | |
116 // | |
117 // In both cases the new ViewManagerClient is configured with a root of | |
118 // |view_id|. | |
119 // | |
120 // The caller must have created |view_id|. If not the request fails and the | |
121 // response is false. | |
122 // | |
123 // A view may only be a root of one connection at a time. Subsequent calls to | |
124 // Embed() for the same view result in the view being removed from the | |
125 // currently embedded app. The embedded app is told this by way of | |
126 // OnViewDeleted(). | |
127 // | |
128 // The embedder can detect when the embedded app disconnects by way of | |
129 // OnEmbeddedAppDisconnected(). | |
130 // | |
131 // When a connection embeds an app the connection no longer has priviledges | |
132 // to access or see any of the children of the view. If the view had existing | |
133 // children the children are removed. The one exception is the root | |
134 // connection. | |
135 // | |
136 // |services| encapsulates services offered by the embedder to the embedded | |
137 // app alongside this Embed() call. |exposed_services| provides a means for | |
138 // the embedder to connect to services exposed by the embedded app. Note that | |
139 // if a different app is subsequently embedded at |view_id| the | |
140 // ServiceProvider connections to its client in the embedded app and any | |
141 // services it provided are not broken and continue to be valid. | |
142 EmbedUrl(string url, | |
143 uint32 view_id, | |
144 ServiceProvider&? services, | |
145 ServiceProvider? exposed_services) => (bool success); | |
146 Embed(uint32 view_id, ViewManagerClient client) => (bool success); | |
147 | |
148 // Requests the WindowManager to perform an action on the specified view. | |
149 // It's up to the WindowManager to decide what |action| is. | |
150 // | |
151 // TODO(sky): nuke this. This is here to guarantee the state of the | |
152 // WindowManager matches that of the ViewManager at the time the client | |
153 // invokes the function. When we can enforce ordering this won't be necessary. | |
154 PerformAction(uint32 view_id, string action) => (bool success); | |
155 }; | |
156 | |
157 // Changes to views are not sent to the connection that originated the | |
158 // change. For example, if connection 1 changes the bounds of a view by calling | |
159 // SetBounds(), connection 1 does not receive OnViewBoundsChanged(). | |
160 [ServiceName="mojo::ViewManagerClient"] | |
161 interface ViewManagerClient { | |
162 // Invoked when the client application has been embedded at |root|. | |
163 // See Embed() on ViewManagerService for more details. |view_manager_service| | |
164 // will be a handle back to the view manager service, unless the connection is | |
165 // to the WindowManager in which case it will be null. | |
166 // |window_manager_pipe| is a pipe to the WindowManager. | |
167 OnEmbed(uint16 connection_id, | |
168 string embedder_url, | |
169 ViewData root, | |
170 ViewManagerService? view_manager_service, | |
171 ServiceProvider&? services, | |
172 ServiceProvider? exposed_services, | |
173 handle<message_pipe> window_manager_pipe); | |
174 | |
175 // Invoked when the application embedded at |view| is disconnected. | |
176 OnEmbeddedAppDisconnected(uint32 view); | |
177 | |
178 // Invoked when a view's bounds have changed. | |
179 OnViewBoundsChanged(uint32 view, | |
180 mojo.Rect old_bounds, | |
181 mojo.Rect new_bounds); | |
182 | |
183 // Invoked when the viewport metrics for the view have changed. | |
184 // Clients are expected to propagate this to the view tree. | |
185 OnViewViewportMetricsChanged(mojo.ViewportMetrics old_metrics, | |
186 mojo.ViewportMetrics new_metrics); | |
187 | |
188 // Invoked when a change is done to the hierarchy. A value of 0 is used to | |
189 // identify a null view. For example, if the old_parent is NULL, 0 is | |
190 // supplied. | |
191 // |views| contains any views that are that the client has not been told | |
192 // about. This is not sent for hierarchy changes of views not known to this | |
193 // client or not attached to the tree. | |
194 OnViewHierarchyChanged(uint32 view, | |
195 uint32 new_parent, | |
196 uint32 old_parent, | |
197 array<ViewData> views); | |
198 | |
199 // Invoked when the order of views within a parent changes. | |
200 OnViewReordered(uint32 view_id, | |
201 uint32 relative_view_id, | |
202 OrderDirection direction); | |
203 | |
204 // Invoked when a view is deleted. | |
205 OnViewDeleted(uint32 view); | |
206 | |
207 // Invoked when the visibility of the specified view changes. | |
208 OnViewVisibilityChanged(uint32 view, bool visible); | |
209 | |
210 // Invoked when a change to the visibility of |view| or one if it's ancestors | |
211 // is done such that the drawn state changes. This is only invoked for the | |
212 // top most view of a particular connection. For example, if you have the | |
213 // hierarchy: A -> B1 -> B2 (B2 is a child of B1 and B1 a child of A), B1/B2 | |
214 // are from connection 2 and A from connection 1 with all views visible and | |
215 // drawn and the visiblity of A changes to false, then connection 2 is told | |
216 // the drawn state of B1 has changed (to false), but is not told anything | |
217 // about B2 as it's drawn state can be calculated from that of B1. | |
218 // | |
219 // NOTE: This is not invoked if OnViewVisibilityChanged() is invoked. | |
220 OnViewDrawnStateChanged(uint32 view, bool drawn); | |
221 | |
222 // Invoked when a view property is changed. If this change is a removal, | |
223 // |new_data| is null. | |
224 OnViewSharedPropertyChanged(uint32 view, string name, array<uint8>? new_data); | |
225 | |
226 // Invoked when an event is targeted at the specified view. | |
227 OnViewInputEvent(uint32 view, mojo.Event event) => (); | |
228 | |
229 // Invoked solely on the WindowManager. See comments in PerformAction() above | |
230 // for details. | |
231 // TODO(sky): nuke this. | |
232 OnPerformAction(uint32 view_id, string action) => (bool success); | |
233 }; | |
OLD | NEW |