OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 [permissions=downloads] | |
6 namespace downloads { | |
7 [inline_doc] dictionary HeaderNameValuePair { | |
8 // Name of the HTTP header. | |
9 DOMString name; | |
10 | |
11 // Value of the HTTP header. | |
12 DOMString value; | |
13 }; | |
14 | |
15 [inline_doc] enum HttpMethod {GET, POST}; | |
16 | |
17 [inline_doc] dictionary DownloadOptions { | |
18 // The URL to download. | |
19 DOMString url; | |
20 | |
21 // A file path relative to the Downloads directory to contain the downloaded | |
22 // file. | |
23 DOMString? filename; | |
24 | |
25 // Use a file-chooser to allow the user to select a filename. | |
26 boolean? saveAs; | |
27 | |
28 // The HTTP method to use if the URL uses the HTTP[S] protocol. | |
29 HttpMethod? method; | |
30 | |
31 // Extra HTTP headers to send with the request if the URL uses the HTTP[s] | |
32 // protocol. Each header is represented as a dictionary containing the keys | |
33 // <code>name</code> and either <code>value</code> or | |
34 // <code>binaryValue</code>, restricted to those allowed by XMLHttpRequest. | |
35 HeaderNameValuePair[]? headers; | |
36 | |
37 // post body | |
38 DOMString? body; | |
39 }; | |
40 | |
41 // 'file': The download's filename is suspicious. | |
42 // 'url': The download's URL is known to be malicious. | |
43 // 'content': The downloaded file is known to be malicious. | |
44 // 'uncommon': The download's URL is not commonly downloaded and could be | |
45 // dangerous. | |
46 // 'safe': The download presents no known danger to the user's computer. | |
47 // These string constants will never change, however the set of DangerTypes | |
48 // may change. | |
49 enum DangerType {file, url, content, uncommon, safe}; | |
50 | |
51 // 'in_progress': the download is currently receiving data from the server. | |
52 // 'interrupted': an error broke the connection with the file host. | |
53 // 'complete': the download completed successfully. | |
54 // These string constants will never change, however the set of States may | |
55 // change. | |
56 enum State {in_progress, interrupted, complete}; | |
57 | |
58 // The state of the process of downloading a file. | |
59 dictionary DownloadItem { | |
60 // An identifier that is persistent across browser sessions. | |
61 long id; | |
62 | |
63 // absolute URL | |
64 DOMString url; | |
65 | |
66 // absolute local path | |
67 DOMString filename; | |
68 | |
69 // False if this download is recorded in the history, true if it is not | |
70 // recorded. | |
71 boolean incognito; | |
72 | |
73 // Indication of whether this download is thought to be safe or known to be | |
74 // suspicious. | |
75 DangerType danger; | |
76 | |
77 // true if the user has accepted the download's danger. | |
78 boolean? dangerAccepted; | |
79 | |
80 // The file's MIME type. | |
81 DOMString mime; | |
82 | |
83 // Number of milliseconds between the unix epoch and when this download | |
84 // began. | |
85 long startTime; | |
86 | |
87 // Number of milliseconds between the unix epoch and when this download | |
88 // ended. | |
89 long? endTime; | |
90 | |
91 // Indicates whether the download is progressing, interrupted, or complete. | |
92 State state; | |
93 | |
94 // true if the download has stopped reading data from the host, but kept the | |
95 // connection open. | |
96 boolean paused; | |
97 | |
98 // Number indicating why a download was interrupted. | |
99 long? error; | |
100 | |
101 // Number of bytes received so far from the host, without considering file | |
102 // compression. | |
103 long bytesReceived; | |
104 | |
105 // Number of bytes in the whole file, without considering file compression, | |
106 // or -1 if unknown. | |
107 long totalBytes; | |
108 | |
109 // Number of bytes in the whole file post-decompression, or -1 if unknown. | |
110 long fileSize; | |
111 }; | |
112 | |
113 [inline_doc] dictionary DownloadQuery { | |
114 // This space-separated string of search terms that may be grouped using | |
115 // quotation marks limits results to downloads whose filename or url contain | |
116 // all of the search terms that do not begin with a dash '-' and none of the | |
117 // search terms that do begin with a dash. | |
118 DOMString? query; | |
119 | |
120 // Limits results to downloads that started before the given ms since the | |
121 // epoch. | |
122 long? startedBefore; | |
123 | |
124 // Limits results to downloads that started after the given ms since the | |
125 // epoch. | |
126 long? startedAfter; | |
127 | |
128 // Limits results to downloads that ended before the given ms since the | |
129 // epoch. | |
130 long? endedBefore; | |
131 | |
132 // Limits results to downloads that ended after the given ms since the | |
133 // epoch. | |
134 long? endedAfter; | |
135 | |
136 // Limits results to downloads whose totalBytes is greater than the given | |
137 // integer. | |
138 long? totalBytesGreater; | |
139 | |
140 // Limits results to downloads whose totalBytes is less than the given | |
141 // integer. | |
142 long? totalBytesLess; | |
143 | |
144 // Limits results to downloads whose filename matches the given regular | |
145 // expression. | |
146 DOMString? filenameRegex; | |
147 | |
148 // Limits results to downloads whose url matches the given regular | |
149 // expression. | |
150 DOMString? urlRegex; | |
151 | |
152 // Setting this integer limits the number of results. Otherwise, all | |
153 // matching DownloadItems will be returned. | |
154 long? limit; | |
155 | |
156 // Setting this string to a DownloadItem property sorts the DownloadItems | |
157 // prior to applying the above filters. For example, setting | |
158 // <code>orderBy='startTime'</code> sorts the DownloadItems by their start | |
159 // time in ascending order. To specify descending order, prefix | |
160 // <code>orderBy</code> with a hyphen: '-startTime'. | |
asargent_no_longer_on_chrome
2012/07/02 23:43:48
From the implemenation, it looks like you allow sp
benjhayden
2012/07/09 20:18:09
Filed a bug for myself: http://crbug.com/135636
| |
161 DOMString? orderBy; | |
162 | |
163 // An identifier that is persistent across browser sessions. | |
164 long? id; | |
165 | |
166 // absolute URL | |
167 DOMString? url; | |
168 | |
169 // absolute local path | |
170 DOMString? filename; | |
171 | |
172 // Indication of whether this download is thought to be safe or known to be | |
173 // suspicious. | |
174 DangerType? danger; | |
175 | |
176 // true if the user has accepted the download's danger. | |
177 boolean? dangerAccepted; | |
178 | |
179 // The file's MIME type. | |
180 DOMString? mime; | |
181 | |
182 // Number of milliseconds between the unix epoch and when this download | |
183 // began. | |
184 long? startTime; | |
185 | |
186 // Number of milliseconds between the unix epoch and when this download | |
187 // ended. | |
188 long? endTime; | |
189 | |
190 // Indicates whether the download is progressing, interrupted, or complete. | |
191 State? state; | |
192 | |
193 // true if the download has stopped reading data from the host, but kept the | |
194 // connection open. | |
195 boolean? paused; | |
196 | |
197 // Number indicating why a download was interrupted. | |
198 long? error; | |
199 | |
200 // Number of bytes received so far from the host, without considering file | |
201 // compression. | |
202 long? bytesReceived; | |
203 | |
204 // Number of bytes in the whole file, without considering file compression, | |
205 // or -1 if unknown. | |
206 long? totalBytes; | |
207 | |
208 // Number of bytes in the whole file post-decompression, or -1 if unknown. | |
209 long? fileSize; | |
210 }; | |
211 | |
212 [inline_doc] dictionary DownloadStringDiff { | |
213 DOMString? previous; | |
214 DOMString? current; | |
215 }; | |
216 | |
217 [inline_doc] dictionary DownloadLongDiff { | |
218 long? previous; | |
219 long? current; | |
220 }; | |
221 | |
222 [inline_doc] dictionary DownloadBooleanDiff { | |
223 boolean? previous; | |
224 boolean? current; | |
225 }; | |
226 | |
227 // Encapsulates a change in a DownloadItem. | |
228 [inline_doc] dictionary DownloadDelta { | |
229 // An identifier that is persistent across browser sessions. | |
230 long id; | |
231 | |
232 // Describes a change in a DownloadItem's <code>url</code>. | |
233 DownloadStringDiff? url; | |
234 | |
235 // Describes a change in a DownloadItem's <code>filename</code>. | |
236 DownloadStringDiff? filename; | |
237 | |
238 // Describes a change in a DownloadItem's <code>danger</code>. | |
239 DownloadStringDiff? danger; | |
240 | |
241 // Describes a change in a DownloadItem's <code>dangerAccepted</code>. | |
242 DownloadBooleanDiff? dangerAccepted; | |
243 | |
244 // Describes a change in a DownloadItem's <code>mime</code>. | |
245 DownloadStringDiff? mime; | |
246 | |
247 // Describes a change in a DownloadItem's <code>startTime</code>. | |
248 DownloadLongDiff? startTime; | |
249 | |
250 // Describes a change in a DownloadItem's <code>endTime</code>. | |
251 DownloadLongDiff? endTime; | |
252 | |
253 // Describes a change in a DownloadItem's <code>state</code>. | |
254 DownloadStringDiff? state; | |
255 | |
256 // Describes a change in a DownloadItem's <code>paused</code>. | |
257 DownloadBooleanDiff? paused; | |
258 | |
259 // Describes a change in a DownloadItem's <code>error</code>. | |
260 DownloadLongDiff? error; | |
261 | |
262 // Describes a change in a DownloadItem's <code>totalBytes</code>. | |
263 DownloadLongDiff? totalBytes; | |
264 | |
265 // Describes a change in a DownloadItem's <code>fileSize</code>. | |
asargent_no_longer_on_chrome
2012/07/02 23:43:48
Optional suggestion: Repeating the word "DownloadI
benjhayden
2012/07/09 20:18:09
Done.
| |
266 DownloadLongDiff? fileSize; | |
267 }; | |
268 | |
269 [inline_doc] dictionary GetFileIconOptions { | |
270 // The size of the icon. The returned icon will be square with dimensions | |
271 // size * size pixels. The default size for the icon is 32x32 pixels. | |
272 [legalValues=(16,32)] long? size; | |
273 }; | |
274 | |
275 callback DownloadCallback = void(long downloadId); | |
276 callback SearchCallback = void(DownloadItem[] results); | |
277 callback EraseCallback = void(long[] erasedIds); | |
278 callback NullCallback = void(); | |
279 callback GetFileIconCallback = void(optional DOMString iconURL); | |
280 | |
281 interface Functions { | |
282 // Download a URL. If the URL uses the HTTP[S] protocol, then the request | |
283 // will include all cookies currently set for its hostname. If both | |
284 // <code>filename</code> and <code>saveAs</code> are specified, then the | |
285 // Save As dialog will be displayed, pre-populated with the specified | |
286 // <code>filename</code>. If the download started successfully, | |
287 // <code>callback</code> will be called with the new DownloadItem's | |
288 // <code>downloadId</code>. If there was an error starting the download, | |
289 // then <code>callback</code> will be called with | |
290 // <code>downloadId=undefined</code> and <a | |
291 // href='extension.html#property-lastError'>chrome.extension.lastError</a> | |
292 // will contain a descriptive string. The error strings are not guaranteed | |
293 // to remain backwards compatible between releases. You must not parse it. | |
294 // |options|: What to download and how. | |
295 // |callback|: Called with the id of the new DownloadItem. | |
296 static void download(DownloadOptions options, | |
297 optional DownloadCallback callback); | |
298 | |
299 // Find DownloadItems. Set <code>query</code> to the empty object to get all | |
300 // DownloadItems. To get a specific DownloadItem, set only the | |
301 // <code>id</code> field. | |
302 static void search(DownloadQuery query, SearchCallback callback); | |
303 | |
304 // Pause the download. If the request was successful the download is in a | |
305 // paused state. Otherwise <a | |
306 // href='extension.html#property-lastError'>chrome.extension.lastError</a> | |
307 // contains an error message. The request will fail if the download is not | |
308 // active. | |
309 // |downloadId|: The id of the download to pause. | |
310 // |callback|: Called when the pause request is completed. | |
311 static void pause(long downloadId, optional NullCallback callback); | |
312 | |
313 // Resume a paused download. If the request was successful the download is | |
314 // in progress and unpaused. Otherwise <a | |
315 // href='extension.html#property-lastError'>chrome.extension.lastError</a> | |
316 // contains an error message. The request will fail if the download is not | |
317 // active. | |
318 // |downloadId|: The id of the download to resume. | |
319 // |callback|: Called when the resume request is completed. | |
320 static void resume(long downloadId, optional NullCallback callback); | |
321 | |
322 // Cancel a download. When <code>callback</code> is run, the download is | |
323 // cancelled, completed, interrupted or doesn't exist anymore. | |
324 // |downloadId|: The id of the download to cancel. | |
325 // |callback|: Called when the cancel request is completed. | |
326 static void cancel(long downloadId, optional NullCallback callback); | |
327 | |
328 // Retrieve an icon for the specified download. For new downloads, file | |
329 // icons are available after the onCreated event has been received. The | |
330 // image returned by this function while a download is in progress may be | |
331 // different from the image returned after the download is complete. Icon | |
332 // retrieval is done by querying the underlying operating system or toolkit | |
333 // depending on the platform. The icon that is returned will therefore | |
334 // depend on a number of factors including state of the download, platform, | |
335 // registered file types and visual theme. If a file icon cannot be | |
336 // determined, <a | |
337 // href='extension.html#property-lastError'>chrome.extension.lastError</a> | |
338 // will contain an error message. | |
339 // |downloadId|: The identifier for the download. | |
340 // |callback|: A URL to an image that represents the download. | |
341 static void getFileIcon(long downloadId, | |
342 optional GetFileIconOptions options, | |
343 GetFileIconCallback callback); | |
344 | |
345 // Erase matching DownloadItems from history | |
346 [nodoc] static void erase(DownloadQuery query, optional EraseCallback callba ck); | |
347 | |
348 // TODO(benjhayden) Comment. | |
349 [nodoc] static void setDestination(long downloadId, DOMString relativePath); | |
350 | |
351 // Prompt the user to either accept or cancel a dangerous download. | |
352 // <code>acceptDanger()</code> does not automatically accept dangerous | |
353 // downloads. | |
354 [nodoc] static void acceptDanger(long downloadId); | |
355 | |
356 // Show the downloaded file in its folder in a file manager. | |
357 [nodoc] static void show(long downloadId); | |
358 | |
359 // Open the downloaded file. | |
360 [nodoc] static void open(long downloadId); | |
361 | |
362 // Initiate dragging the file to another application. | |
363 [nodoc] static void drag(long downloadId); | |
364 }; | |
365 | |
366 interface Events { | |
367 // This event fires with the DownloadItem object when a download begins. | |
368 static void onCreated(DownloadItem downloadItem); | |
369 | |
370 // Fires with the download id when a download is erased from history. | |
371 static void onErased(long downloadId); | |
372 | |
373 // When any of a DownloadItem's properties except <code>bytesReceived</code> | |
374 // changes, this event fires with the download id and an object containing | |
375 // the properties that changed. | |
376 static void onChanged(DownloadDelta downloadDelta); | |
377 }; | |
378 }; | |
OLD | NEW |