OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 module web_view.mojom; | |
6 | |
7 import "network/public/interfaces/url_loader.mojom"; | |
8 | |
9 // This files defines the interfaces and structures used for frames. | |
10 // | |
11 // When a client in the frame tree is connected to by way of the WindowManager a | |
12 // FrameClient is obtained (from the ServiceProvider interface request passed | |
13 // in WindowManager::OnEmbed()). The FrameClient is told the frame tree (by way | |
14 // of OnConnection()), which allows the client to use other frames in the tree | |
15 // (assuming the client has the appropriate permissions). | |
16 // | |
17 // frame_ids are the same as windows ids. This means that when a client creates | |
18 // a new window to be part of the frame tree it immediately knows the id to use | |
19 // for Frame calls. | |
20 // | |
21 // The server provides an id that may be used to identify the state of the | |
22 // tree. The change id is an integer that is incremented every time the | |
23 // structure of the tree changes. The change id is not used by the server; the | |
24 // server only updates the change id and notifies clients of the new id (by | |
25 // way of structure change functions such as OnFrameAdded()). | |
26 | |
27 // Expresses a preference for where a navigation should occur. | |
28 enum NavigationTargetType { | |
29 // No preference. | |
30 NO_PREFERENCE, | |
31 | |
32 // In the specified frame. | |
33 EXISTING_FRAME, | |
34 | |
35 // In a new frame. | |
36 NEW_FRAME, | |
37 }; | |
38 | |
39 // Provides information about a frame. | |
40 struct FrameData { | |
41 // 0 if the frame has no parent (its the root). | |
42 uint32 parent_id; | |
43 uint32 frame_id; | |
44 | |
45 // A map of the properties supplied by the client. The server does not | |
46 // intepret these values in anyway, the meaning and usage is left up to | |
47 // clients. | |
48 map<string, array<uint8>>? client_properties; | |
49 }; | |
50 | |
51 // TODO(sky): decide which bits of this make sense for all frames, and move the | |
52 // html specific parts into properties. | |
53 struct HTMLMessageEvent { | |
54 // The serialized script value. | |
55 array<uint8>? data; | |
56 | |
57 // The origin of the source frame. | |
58 string source_origin; | |
59 | |
60 // The origin for the message's target. | |
61 string? target_origin; | |
62 | |
63 // TODO(sky): these two are not implemented. Figure out what they should be. | |
64 // Information about the MessagePorts this message contains. | |
65 // IPC_STRUCT_MEMBER(std::vector<content::TransferredMessagePort>, message_por
ts) | |
66 // IPC_STRUCT_MEMBER(std::vector<int>, new_routing_ids) | |
67 }; | |
68 | |
69 // Options used when performing a find-in-page query. | |
70 struct FindOptions { | |
71 // Whether to search forward or backward within the page. | |
72 bool forward = true; | |
73 | |
74 // Whether this operation is a follow-up to the last find. | |
75 bool continue_last_find = false; | |
76 }; | |
77 | |
78 interface Frame { | |
79 // Requests the server to message the specified frame with |event|. If the | |
80 // operation is allowed OnPostMessageEvent() is called on the appropriate | |
81 // FrameClient. | |
82 PostMessageEventToFrame(uint32 target_frame_id, HTMLMessageEvent event); | |
83 | |
84 // Notifies the server that the loading state and progress changed. | |
85 LoadingStateChanged(bool loading, double progress); | |
86 | |
87 // Called when the title becomes available or changes. | |
88 TitleChanged(string? title); | |
89 | |
90 // Called when the response body has been received. | |
91 DidCommitProvisionalLoad(); | |
92 | |
93 // Sets the value of the specified client property, notifying clients if the | |
94 // value changed. If |value| is null the property is removed. | |
95 SetClientProperty(string name, array<uint8>? value); | |
96 | |
97 // Called when the client creates a new frame. |frame_id| corresponds to | |
98 // the id of the window hosting the frame, and |parent_id| the id of the | |
99 // parent. See FrameData::client_properties for details of | |
100 // |client_properties|. | |
101 // | |
102 // Note that the FrameClient still gets an OnConnect(), but the only thing of | |
103 // interest is the callback. | |
104 OnCreatedFrame(Frame& frame_request, | |
105 FrameClient client, | |
106 uint32 frame_id, | |
107 map<string, array<uint8>> client_properties); | |
108 | |
109 // Requests a navigation. If |target_TYPE| is |EXISTING_FRAME|, then | |
110 // |target_frame_id| identifies the frame to navigate in. Otherwise | |
111 // |target_frame_id| is unused. | |
112 RequestNavigate(NavigationTargetType target_type, | |
113 uint32 target_frame_id, | |
114 mojo.URLRequest request); | |
115 | |
116 // The frame navigated locally, for example, pushState() navigations in an | |
117 // HTML application. | |
118 DidNavigateLocally(string url); | |
119 | |
120 // Dispatches a load event to the parent of the frame. | |
121 DispatchLoadEventToParent(); | |
122 | |
123 // Reports the number of matches for a given find. This is an asynchronous | |
124 // notification and can fire multiple times per HighlightFindResults() call. | |
125 OnFindInFrameCountUpdated(int32 request_id, int32 count, | |
126 bool final_update); | |
127 | |
128 // Reports which match is currently highlighted. | |
129 OnFindInPageSelectionUpdated(int32 request_id, int32 active_match_ordinal); | |
130 }; | |
131 | |
132 enum WindowConnectType { | |
133 // Indicates the app is already a WindowTreeClient and the existing window sho
uld | |
134 // be used. In this case the app is not asked for a new WindowTreeClient. | |
135 USE_EXISTING, | |
136 | |
137 // Indicates a new WindowTreeClient is obtained and the Window provided to | |
138 // OnEmbed() should be used. | |
139 USE_NEW | |
140 }; | |
141 | |
142 interface FrameClient { | |
143 // Called once per client. |frame_data| gives the contents of the tree. | |
144 // |window_id| is the id of the window the FrameClient should render to. If a | |
145 // WindowTreeClient is asked for then |window_id| is the same id as that of th
e | |
146 // Window supplied to WindowTreeClient::OnEmbed(). |navigation_start_time_tick
s| | |
147 // is the time when the navigation resulting in this OnConnect() call was | |
148 // started. | |
149 OnConnect(Frame? frame, | |
150 uint32 change_id, | |
151 uint32 window_id, | |
152 WindowConnectType window_connect_type, | |
153 array<FrameData>? frame_data, | |
154 int64 navigation_start_time_ticks) => (); | |
155 | |
156 // Called when a new frame is added to the tree. | |
157 OnFrameAdded(uint32 change_id, FrameData frame_data); | |
158 | |
159 // Called when a frame is removed from the tree. | |
160 OnFrameRemoved(uint32 change_id, uint32 frame_id); | |
161 | |
162 // Called when a client property changes. | |
163 OnFrameClientPropertyChanged(uint32 frame_id, | |
164 string name, | |
165 array<uint8>? new_value); | |
166 | |
167 // See description in PostMessageEventToFrame(). | |
168 OnPostMessageEvent(uint32 source_frame_id, | |
169 uint32 target_frame_id, | |
170 HTMLMessageEvent event); | |
171 | |
172 // Called prior to starting a new navigation. This is only called on the | |
173 // FrameClient that is rendering to the frame, and only when another content | |
174 // handler is going to start handling the rendering. | |
175 // | |
176 // The new navigation is not started until the callback is run. | |
177 // | |
178 // TODO(sky): sort out origin. It needs to be more than a string. | |
179 // Additionally it overlaps with the client properties. | |
180 OnWillNavigate(string origin) => (); | |
181 | |
182 // Called to notify that |frame_id|'s loading state has changed. This is only | |
183 // called on the FrameClient rendering the parent of |frame_id|. | |
184 OnFrameLoadingStateChanged(uint32 frame_id, bool loading); | |
185 | |
186 // Called to dispatch a load event of |frame_id| in its parent. This is only | |
187 // called on the FrameClient rendering the parent of |frame_id|. | |
188 OnDispatchFrameLoadEvent(uint32 frame_id); | |
189 | |
190 // TODO(erg): Several of these take a WebFindOptions struct; we probably need | |
191 // to build a Frame version of that struct. | |
192 | |
193 // Searches for a given string. If a match is found, it will be | |
194 // selected. Find() will only return true if it found a match, and will return | |
195 // the result in the future through OnFindInPageSelectionUpdated(). That | |
196 // callback will return |request_id|, and the listener should verify the | |
197 // |request_id| on callback to guard against race conditions. | |
198 // | |
199 // |request_id| should be a monotonically increasing number which should only | |
200 // be reused between Find() and the HighlightFindResults() calls that are | |
201 // searching for the same string. |search_text| may be empty. | |
202 Find(int32 request_id, string search_text, FindOptions options, | |
203 bool wrap_within_frame) => (bool found); | |
204 | |
205 // Stop finding the single find result on the page. If |clear_selection| is | |
206 // set, it will also clear the selected find text. | |
207 StopFinding(bool clear_selection); | |
208 | |
209 // Match every instance of a string in a document asynchronously, highlighting | |
210 // them and putting a tick mark in the scroll bar. This differs from Find() as | |
211 // Find() is about finding the one selected instance of the text. | |
212 // HighlightFindResults() is about highlighting all the instances of the text. | |
213 // | |
214 // HighlightFindResults() will asynchronously call | |
215 // OnFindInFrameCountUpdated() multiple times to report its progress. | |
216 HighlightFindResults(int32 request_id, string search_text, | |
217 FindOptions options, bool reset); | |
218 | |
219 // Removes the tick marks and highlighting done by HighlightFindResults() in | |
220 // this frame. | |
221 StopHighlightingFindResults(); | |
222 }; | |
OLD | NEW |