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 [ | |
6 { | |
7 "namespace": "experimental.downloads", | |
8 "events": [ | |
9 { | |
10 "name": "onCreated", | |
11 "type": "function", | |
12 "nodoc": "true", | |
13 "description": "This event fires with the DownloadItem object when a dow
nload begins.", | |
14 "parameters": [ | |
15 {"name": "downloadItem", "$ref": "DownloadItem"} | |
16 ] | |
17 }, | |
18 { | |
19 "name": "onChanged", | |
20 "type": "function", | |
21 "nodoc": "true", | |
22 "description": "When any of a DownloadItem's properties except <code>byt
esReceived</code> changes, this event fires with the download id and an object c
ontaining the properties that changed.", | |
23 "parameters": [ | |
24 {"name": "downloadDelta", "$ref": "DownloadDelta"} | |
25 ] | |
26 }, | |
27 { | |
28 "name": "onErased", | |
29 "type": "function", | |
30 "nodoc": "true", | |
31 "description": "Fires with the download id when a download is erased fro
m history.", | |
32 "parameters": [ | |
33 {"type": "integer", "name": "downloadId"} | |
34 ] | |
35 } | |
36 ], | |
37 "properties": { | |
38 "STATE_IN_PROGRESS": { | |
39 "type": "string", | |
40 "nodoc": "true", | |
41 "value": "in_progress", | |
42 "description": "The download is currently receiving data from the server
." | |
43 }, | |
44 "STATE_INTERRUPTED": { | |
45 "type": "string", | |
46 "nodoc": "true", | |
47 "value": "interrupted", | |
48 "description": "An error broke the connection with the file host." | |
49 }, | |
50 "STATE_COMPLETE": { | |
51 "type": "string", | |
52 "nodoc": "true", | |
53 "value": "complete", | |
54 "description": "The download has completed." | |
55 }, | |
56 "DANGER_SAFE": { | |
57 "type": "string", | |
58 "nodoc": "true", | |
59 "value": "safe", | |
60 "description": "The file has been determined to present no known danger
to the user's computer." | |
61 }, | |
62 "DANGER_FILE": { | |
63 "type": "string", | |
64 "nodoc": "true", | |
65 "value": "file", | |
66 "description": "The download's filename is suspicious." | |
67 }, | |
68 "DANGER_URL": { | |
69 "type": "string", | |
70 "nodoc": "true", | |
71 "value": "url", | |
72 "description": "The download's URL is malicious." | |
73 }, | |
74 "DANGER_CONTENT": { | |
75 "type": "string", | |
76 "nodoc": "true", | |
77 "value": "content", | |
78 "description": "The download's content is malicious." | |
79 }, | |
80 "DANGER_UNCOMMON": { | |
81 "type": "string", | |
82 "value": "uncommon", | |
83 "description": "The download is not commonly downloaded and could be dan
gerous." | |
84 }, | |
85 "ERROR_GENERIC": { | |
86 "type": "string", | |
87 "value": "I'm afraid I can't do that.", | |
88 "description": "Generic error." | |
89 }, | |
90 "ERROR_INVALID_URL": { | |
91 "type": "string", | |
92 "value": "Invalid URL.", | |
93 "description": "The URL was invalid." | |
94 }, | |
95 "ERROR_INVALID_OPERATION": { | |
96 "type": "string", | |
97 "nodoc": "true", | |
98 "value": "Invalid operation.", | |
99 "description": "The requested operation cannot be performed at this time
. This maybe due to the download being in a state where the requested operation
is not allowed." | |
100 } | |
101 }, | |
102 "types": [ | |
103 { | |
104 "id": "HttpHeaders", | |
105 "type": "array", | |
106 "description": "An array of HTTP headers. Each header is represented as
a dictionary containing the keys <code>name</code> and either <code>value</code>
or <code>binaryValue</code>.", | |
107 "items": { | |
108 "type": "object", | |
109 "properties": { | |
110 "name": {"type": "string", "description": "Name of the HTTP header."
}, | |
111 "value": {"type": "string", "optional": true, "description": "Value
of the HTTP header if it can be represented by UTF-8."}, | |
112 "binaryValue": { | |
113 "type": "array", | |
114 "optional": true, | |
115 "description": "Value of the HTTP header if it cannot be represent
ed by UTF-8, stored as individual byte values (0..255).", | |
116 "items": {"type": "integer"} | |
117 } | |
118 } | |
119 } | |
120 }, | |
121 { | |
122 "id": "DownloadDangerType", | |
123 "description": "String indicating whether a download is known to be safe
or is considered dangerous. The values correspond to the <code>DANGER_SAFE</cod
e>, <code>DANGER_FILE</code>, <code>DANGER_URL</code>, <code>DANGER_CONTENT</cod
e>, and <code>DANGER_UNCOMMON</code> properties.", | |
124 "type": "string", | |
125 "enum": ["safe", "file", "url", "content", "uncommon"] | |
126 }, | |
127 { | |
128 "id": "DownloadItem", | |
129 "type": "object", | |
130 "nodoc": "true", | |
131 "description": "The state of a file as it is downloaded from the interne
t.", | |
132 "properties": { | |
133 "id": { | |
134 "type": "integer", | |
135 "description": "An identifier that is persistent across browser sess
ions." | |
136 }, | |
137 "url": { | |
138 "type": "string", | |
139 "description": "absolute URL" | |
140 }, | |
141 "filename": { | |
142 "type": "string", | |
143 "description": "absolute local path" | |
144 }, | |
145 "danger": { | |
146 "$ref": "DownloadDangerType", | |
147 "description": "Indication of whether this download is thought to be
safe or known to be suspicious.", | |
148 "optional": true | |
149 }, | |
150 "dangerAccepted": { | |
151 "type": "boolean", | |
152 "description": "true if the user has accepted the download's danger.
", | |
153 "optional": true | |
154 }, | |
155 "mime": { | |
156 "type": "string", | |
157 "description": "The file's MIME type." | |
158 }, | |
159 "startTime": { | |
160 "type": "integer", | |
161 "description": "Number of milliseconds between the unix epoch and wh
en this download began." | |
162 }, | |
163 "endTime": { | |
164 "type": "integer", | |
165 "description": "Number of milliseconds between the unix epoch and wh
en this download ended.", | |
166 "optional": true | |
167 }, | |
168 "state": { | |
169 "type": "string", | |
170 "description": "Indicates whether the download is progressing, inter
rupted, or complete.", | |
171 "enum": ["in_progress", "complete", "interrupted"] | |
172 }, | |
173 "paused": { | |
174 "type": "boolean", | |
175 "description": "true if the download has stopped reading data from t
he host, but kept the connection open." | |
176 }, | |
177 "error": { | |
178 "type": "integer", | |
179 "description": "Number indicating why a download was interrupted.", | |
180 "optional": true | |
181 }, | |
182 "bytesReceived": { | |
183 "type": "integer", | |
184 "description": "Number of bytes received so far from the host, witho
ut considering file compression." | |
185 }, | |
186 "totalBytes": { | |
187 "type": "integer", | |
188 "description": "Number of bytes in the whole file, without consideri
ng file compression, or -1 if unknown." | |
189 }, | |
190 "fileSize": { | |
191 "type": "integer", | |
192 "description": "Number of bytes in the whole file post-decompression
, or -1 if unknown." | |
193 } | |
194 } | |
195 }, | |
196 { | |
197 "id": "DownloadQuery", | |
198 "type": "object", | |
199 "nodoc": "true", | |
200 "description": "", | |
201 "properties": { | |
202 "query": { | |
203 "type": "string", | |
204 "description": "This space-separated string of search terms that may
be grouped using quotation marks limits results to downloads whose filename or
url contain all of the search terms that do not begin with a dash ‘-’ and none o
f the search terms that do begin with a dash.", | |
205 "optional": true | |
206 }, | |
207 "startedBefore": { | |
208 "type": "integer", | |
209 "description": "Limits results to downloads that started before the
given ms since the epoch.", | |
210 "optional": true | |
211 }, | |
212 "startedAfter": { | |
213 "type": "integer", | |
214 "description": "Limits results to downloads that started after the g
iven ms since the epoch.", | |
215 "optional": true | |
216 }, | |
217 "endedBefore": { | |
218 "type": "integer", | |
219 "description": "Limits results to downloads that ended before the gi
ven ms since the epoch.", | |
220 "optional": true | |
221 }, | |
222 "endedAfter": { | |
223 "type": "integer", | |
224 "description": "Limits results to downloads that ended after the giv
en ms since the epoch.", | |
225 "optional": true | |
226 }, | |
227 "totalBytesGreater": { | |
228 "type": "integer", | |
229 "description": "Limits results to downloads whose totalBytes is grea
ter than the given integer.", | |
230 "optional": true | |
231 }, | |
232 "totalBytesLess": { | |
233 "type": "integer", | |
234 "description": "Limits results to downloads whose totalBytes is less
than the given integer.", | |
235 "optional": true | |
236 }, | |
237 "filenameRegex": { | |
238 "type": "string", | |
239 "description": "Limits results to downloads whose filename matches t
he given regular expression.", | |
240 "optional": true | |
241 }, | |
242 "urlRegex": { | |
243 "type": "string", | |
244 "description": "Limits results to downloads whose url matches the gi
ven regular expression.", | |
245 "optional": true | |
246 }, | |
247 "limit": { | |
248 "type": "integer", | |
249 "optional": true, | |
250 "description": "Setting this integer limits the number of results. O
therwise, all matching DownloadItems will be returned." | |
251 }, | |
252 "orderBy": { | |
253 "type": "string", | |
254 "optional": true, | |
255 "description": "Setting this string to a DownloadItem property sorts
the DownloadItems prior to applying the above filters. For example, setting <co
de>orderBy=”startTime”</code> sorts the DownloadItems by their start time in asc
ending order. To specify descending order, prefix <code>orderBy</code> with a hy
phen: “-startTime”." | |
256 }, | |
257 "id": { | |
258 "type": "integer", | |
259 "optional": true, | |
260 "description": "An identifier that is persistent across browser sess
ions." | |
261 }, | |
262 "url": { | |
263 "type": "string", | |
264 "optional": true, | |
265 "description": "absolute URL" | |
266 }, | |
267 "filename": { | |
268 "type": "string", | |
269 "optional": true, | |
270 "description": "absolute local path" | |
271 }, | |
272 "danger": { | |
273 "$ref": "DownloadDangerType", | |
274 "description": "Indication of whether this download is thought to be
safe or known to be suspicious.", | |
275 "optional": true | |
276 }, | |
277 "dangerAccepted": { | |
278 "type": "boolean", | |
279 "optional": true, | |
280 "description": "true if the user has accepted the download's danger.
" | |
281 }, | |
282 "mime": { | |
283 "type": "string", | |
284 "optional": true, | |
285 "description": "The file's MIME type." | |
286 }, | |
287 "startTime": { | |
288 "type": "integer", | |
289 "optional": true, | |
290 "description": "Number of milliseconds between the unix epoch and wh
en this download began." | |
291 }, | |
292 "endTime": { | |
293 "type": "integer", | |
294 "description": "Number of milliseconds between the unix epoch and wh
en this download ended.", | |
295 "optional": true | |
296 }, | |
297 "state": { | |
298 "type": "string", | |
299 "optional": true, | |
300 "description": "Indicates whether the download is progressing, inter
rupted, or complete.", | |
301 "enum": ["in_progress", "complete", "interrupted"] | |
302 }, | |
303 "paused": { | |
304 "type": "boolean", | |
305 "optional": true, | |
306 "description": "true if the download has stopped reading data from t
he host, but kept the connection open." | |
307 }, | |
308 "error": { | |
309 "type": "integer", | |
310 "description": "Number indicating why a download was interrupted.", | |
311 "optional": true | |
312 }, | |
313 "bytesReceived": { | |
314 "type": "integer", | |
315 "optional": true, | |
316 "description": "Number of bytes received so far from the host, witho
ut considering file compression." | |
317 }, | |
318 "totalBytes": { | |
319 "type": "integer", | |
320 "optional": true, | |
321 "description": "Number of bytes in the whole file, without consideri
ng file compression, or -1 if unknown." | |
322 }, | |
323 "fileSize": { | |
324 "type": "integer", | |
325 "optional": true, | |
326 "description": "Number of bytes in the whole file post-decompression
, or -1 if unknown." | |
327 } | |
328 } | |
329 }, | |
330 { | |
331 "id": "DownloadBooleanDiff", | |
332 "type": "object", | |
333 "nodoc": "true", | |
334 "description": "Encapsulates a change in a boolean DownloadItem field.", | |
335 "properties": { | |
336 "old": { | |
337 "type": "boolean", | |
338 "optional": true | |
339 }, | |
340 "new": { | |
341 "type": "boolean", | |
342 "optional": true | |
343 } | |
344 } | |
345 }, | |
346 { | |
347 "id": "DownloadIntegerDiff", | |
348 "type": "object", | |
349 "nodoc": "true", | |
350 "description": "Encapsulates a change in an integer DownloadItem field."
, | |
351 "properties": { | |
352 "old": { | |
353 "type": "integer", | |
354 "optional": true | |
355 }, | |
356 "new": { | |
357 "type": "integer", | |
358 "optional": true | |
359 } | |
360 } | |
361 }, | |
362 { | |
363 "id": "DownloadStringDiff", | |
364 "type": "object", | |
365 "nodoc": "true", | |
366 "description": "Encapsulates a change in a string DownloadItem field.", | |
367 "properties": { | |
368 "old": { | |
369 "type": "string", | |
370 "optional": true | |
371 }, | |
372 "new": { | |
373 "type": "string", | |
374 "optional": true | |
375 } | |
376 } | |
377 }, | |
378 { | |
379 "id": "DownloadDelta", | |
380 "type": "object", | |
381 "nodoc": "true", | |
382 "description": "Encapsulates a change in a DownloadItem.", | |
383 "properties": { | |
384 "id": { | |
385 "type": "integer", | |
386 "description": "An identifier that is persistent across browser sess
ions." | |
387 }, | |
388 "url": { | |
389 "$ref": "DownloadStringDiff", | |
390 "optional": true | |
391 }, | |
392 "filename": { | |
393 "$ref": "DownloadStringDiff", | |
394 "optional": true | |
395 }, | |
396 "danger": { | |
397 "$ref": "DownloadStringDiff", | |
398 "optional": true | |
399 }, | |
400 "dangerAccepted": { | |
401 "$ref": "DownloadBooleanDiff", | |
402 "optional": true | |
403 }, | |
404 "mime": { | |
405 "$ref": "DownloadStringDiff", | |
406 "optional": true | |
407 }, | |
408 "startTime": { | |
409 "$ref": "DownloadIntegerDiff", | |
410 "optional": true | |
411 }, | |
412 "endTime": { | |
413 "$ref": "DownloadIntegerDiff", | |
414 "optional": true | |
415 }, | |
416 "state": { | |
417 "$ref": "DownloadStringDiff", | |
418 "optional": true | |
419 }, | |
420 "paused": { | |
421 "$ref": "DownloadBooleanDiff", | |
422 "optional": true | |
423 }, | |
424 "error": { | |
425 "$ref": "DownloadIntegerDiff", | |
426 "optional": true | |
427 }, | |
428 "bytesReceived": { | |
429 "$ref": "DownloadIntegerDiff", | |
430 "optional": true | |
431 }, | |
432 "totalBytes": { | |
433 "$ref": "DownloadIntegerDiff", | |
434 "optional": true | |
435 }, | |
436 "fileSize": { | |
437 "$ref": "DownloadIntegerDiff", | |
438 "optional": true | |
439 } | |
440 } | |
441 } | |
442 ], | |
443 "functions": [ | |
444 { | |
445 "name": "download", | |
446 "type": "function", | |
447 "description": "Download a URL. If the URL uses the HTTP[S] protocol, th
en the request will include all cookies currently set for its hostname. If the d
ownload started successfully, <code>callback</code> will be called with the new
DownloadItem’s <code>downloadId</code>. If there was an error starting the downl
oad, then <code>callback</code> will be called with <code>downloadId=undefined</
code> and <code>chrome.extension.lastError</code> will be set. If both <code>fil
ename</code> and <code>saveAs</code> are specified, then the Save As dialog will
be displayed, pre-populated with the specified <code>filename</code>.", | |
448 "parameters": [ | |
449 { | |
450 "type": "object", | |
451 "name": "options", | |
452 "properties": { | |
453 "url": { | |
454 "type": "string", | |
455 "description": "The URL to download.", | |
456 "minLength": 1 | |
457 }, | |
458 "filename": { | |
459 "type": "string", | |
460 "description": "A file path relative to the Downloads directory
to contain the downloaded file.", | |
461 "optional": true | |
462 }, | |
463 "saveAs": { | |
464 "type": "boolean", | |
465 "optional": true, | |
466 "description": "Use a file-chooser to allow the user to select a
filename." | |
467 }, | |
468 "method": { | |
469 "type": "string", | |
470 "description": "The HTTP method to use if the URL uses the HTTP[
S] protocol.", | |
471 "optional": true, | |
472 "enum": ["GET", "POST"] | |
473 }, | |
474 "headers": { | |
475 "$ref": "HttpHeaders", | |
476 "description": "Extra HTTP headers to send with the request if t
he URL uses the HTTP[s] protocol, restricted to those allowed by XMLHttpRequest.
", | |
477 "optional": true | |
478 }, | |
479 "body": { | |
480 "type": "string", | |
481 "description": "post body", | |
482 "optional": true | |
483 } | |
484 } | |
485 }, | |
486 { | |
487 "type": "function", | |
488 "name": "callback", | |
489 "optional": true, | |
490 "parameters": [ | |
491 { | |
492 "name": "downloadId", | |
493 "type": "integer", | |
494 "description": "If not null, the identifier of the resulting Dow
nload Item." | |
495 } | |
496 ] | |
497 } | |
498 ] | |
499 }, | |
500 { | |
501 "name": "search", | |
502 "type": "function", | |
503 "nodoc": "true", | |
504 "description": "Find DownloadItems. Set <code>query</code> to the empty
object to get all DownloadItems. To get a specific DownloadItem, set only the <c
ode>id</code> field.", | |
505 "parameters": [ | |
506 {"name": "query", "$ref": "DownloadQuery"}, | |
507 { | |
508 "name": "callback", | |
509 "type": "function", | |
510 "optional": true, | |
511 "parameters": [ | |
512 {"name": "items", "type": "array"} | |
513 ] | |
514 } | |
515 ] | |
516 }, | |
517 { | |
518 "name": "erase", | |
519 "type": "function", | |
520 "nodoc": "true", | |
521 "description": "Erase matching DownloadItems from history", | |
522 "parameters": [ | |
523 {"name": "query", "$ref": "DownloadQuery"}, | |
524 { | |
525 "name": "callback", | |
526 "type": "function", | |
527 "optional": true, | |
528 "parameters": [ | |
529 { | |
530 "name": "ids", | |
531 "type": "array", | |
532 "description": "The identifiers of the downloads that were erase
d." | |
533 } | |
534 ] | |
535 } | |
536 ] | |
537 }, | |
538 { | |
539 "name": "setDestination", | |
540 "type": "function", | |
541 "nodoc": "true", | |
542 "description": "Move the file to Downloads/relativePath instead of the D
ownloads directory if it has completed and pass true to callback. If <code>relat
ivePath</code> specifies a directory that does not exist then it will be created
. If it has not completed, store <code>relativePath</code> such that the file wi
ll be moved there when it completes and pass true to callback without waiting fo
r the download to complete. Does nothing if the download is cancelled or if <cod
e>downloadId</code> does not reference an existing DownloadItem, but pass false
to callback. If the file could not be moved, then the DownloadItem will transiti
on to STATE_INTERRUPTED, its <code>error</code> property will be set accordingly
, false will be passed to callback, and the OnChanged event will fire.", | |
543 "parameters": [ | |
544 {"name": "id", "type": "integer"}, | |
545 {"name": "relativePath", "type": "string"} | |
546 ] | |
547 }, | |
548 { | |
549 "name": "acceptDanger", | |
550 "type": "function", | |
551 "nodoc": "true", | |
552 "description": "Accept a dangerous download. If a download is dangerous,
then it will not transition to the completed state until this function is calle
d.", | |
553 "parameters": [ | |
554 {"name": "id", "type": "integer"} | |
555 ] | |
556 }, | |
557 { | |
558 "name": "show", | |
559 "type": "function", | |
560 "nodoc": "true", | |
561 "description": "Show the downloaded file in its folder.", | |
562 "parameters": [ | |
563 {"name": "id", "type": "integer"} | |
564 ] | |
565 }, | |
566 { | |
567 "name": "drag", | |
568 "type": "function", | |
569 "nodoc": "true", | |
570 "description": "Drag the file to another application", | |
571 "parameters": [ | |
572 {"name": "id", "type": "integer"} | |
573 ] | |
574 }, | |
575 { | |
576 "name": "pause", | |
577 "type": "function", | |
578 "nodoc": "true", | |
579 "description": "Pause the download.", | |
580 "parameters": [ | |
581 {"name": "id", "type": "integer"}, | |
582 { | |
583 "name": "callback", | |
584 "type": "function", | |
585 "optional": true, | |
586 "parameters": [], | |
587 "description": "Called when the pause request is completed. If the r
equest was successful the download is in a paused state. Otherwise chrome.extens
ion.lastError contains an error message. The request will fail if the download i
s not active." | |
588 } | |
589 ] | |
590 }, | |
591 { | |
592 "name": "resume", | |
593 "type": "function", | |
594 "nodoc": "true", | |
595 "description": "Resume a paused download.", | |
596 "parameters": [ | |
597 {"name": "id", "type": "integer"}, | |
598 { | |
599 "name": "callback", | |
600 "type": "function", | |
601 "optional": true, | |
602 "parameters": [], | |
603 "description": "Called when the resume request is completed. If the
request was successful the download is in progress and unpaused. Otherwise chrom
e.extension.lastError contains an error message. The request will fail if the do
wnload is not active." | |
604 } | |
605 ] | |
606 }, | |
607 { | |
608 "name": "cancel", | |
609 "type": "function", | |
610 "nodoc": "true", | |
611 "description": "Cancel a download.", | |
612 "parameters": [ | |
613 {"name": "id", "type": "integer"}, | |
614 { | |
615 "name": "callback", | |
616 "type": "function", | |
617 "optional": true, | |
618 "parameters": [], | |
619 "description": "Called when the request is completed. The download i
s cancelled, completed, interrupted or doesn't exist anymore." | |
620 } | |
621 ] | |
622 }, | |
623 { | |
624 "name": "getFileIcon", | |
625 "type": "function", | |
626 "nodoc": "true", | |
627 "description": "Retrieve an icon for the specified download. For new dow
nloads, file icons are available after the onCreated event has been received. Th
e image returned by this function while a download is in progress may be differe
nt from the image returned after the download is complete. Icon retrieval is don
e by querying the underlying operating system or toolkit depending on the platfo
rm. The icon that is returned will therefore depend on a number of factors inclu
ding state of the download, platform, registered file types and visual theme.", | |
628 "parameters": [ | |
629 { | |
630 "type": "integer", | |
631 "name": "id", | |
632 "description": "The identifier for the download." | |
633 }, | |
634 { | |
635 "type": "object", | |
636 "name": "options", | |
637 "properties": { | |
638 "size": { | |
639 "type": "integer", | |
640 "description": "The size of the icon. The returned icon will be
square with dimensions size * size pixels. The default size for the icon is 32
x32 pixels.", | |
641 "enum": [16, 32], | |
642 "optional": true | |
643 } | |
644 } | |
645 }, | |
646 { | |
647 "name": "callback", | |
648 "type": "function", | |
649 "parameters": [ | |
650 { | |
651 "name": "iconURL", | |
652 "type": "string", | |
653 "description": "A URL to an image that represents the download.
If a file icon cannot be determined, chrome.extension.lastError will contain an
error message." | |
654 } | |
655 ] | |
656 } | |
657 ] | |
658 } | |
659 ] | |
660 } | |
661 ] | |
OLD | NEW |