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

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

Powered by Google App Engine
This is Rietveld 408576698