Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: chrome/common/extensions/api/downloads.idl

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

Powered by Google App Engine
This is Rietveld 408576698