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

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

Issue 16924017: A few minor changes to the chrome.downloads extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r213855 Created 7 years, 4 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Use the <code>chrome.downloads</code> API to programmatically initiate, 5 // Use the <code>chrome.downloads</code> API to programmatically initiate,
6 // monitor, manipulate, and search for downloads. 6 // monitor, manipulate, and search for downloads.
7 [permissions=downloads] 7 [permissions=downloads]
8 namespace downloads { 8 namespace downloads {
9 [inline_doc] dictionary HeaderNameValuePair { 9 [inline_doc] dictionary HeaderNameValuePair {
10 // Name of the HTTP header. 10 // Name of the HTTP header.
11 DOMString name; 11 DOMString name;
12 12
13 // Value of the HTTP header. 13 // Value of the HTTP header.
14 DOMString value; 14 DOMString value;
15 }; 15 };
16 16
17 // <dl><dt>uniquify</dt> 17 // <dl><dt>uniquify</dt>
18 // <dd>To avoid duplication, the <code>filename</code> is changed to 18 // <dd>To avoid duplication, the <code>filename</code> is changed to
19 // include a counter before the filename extension.</dd> 19 // include a counter before the filename extension.</dd>
20 // <dt>overwrite</dt> 20 // <dt>overwrite</dt>
21 // <dd>The existing file will be overwritten with the new file.</dd> 21 // <dd>The existing file will be overwritten with the new file.</dd>
22 // <dt>prompt</dt> 22 // <dt>prompt</dt>
23 // <dd>The user will be prompted with a file chooser dialog.</dd> 23 // <dd>The user will be prompted with a file chooser dialog.</dd>
24 // </dl> 24 // </dl>
25 [inline_doc] enum FilenameConflictAction {uniquify, overwrite, prompt}; 25 enum FilenameConflictAction {uniquify, overwrite, prompt};
26 26
27 [inline_doc] dictionary FilenameSuggestion { 27 [inline_doc] dictionary FilenameSuggestion {
28 // The $ref:DownloadItem's new target $ref:DownloadItem.filename, as a path 28 // The $ref:DownloadItem's new target $ref:DownloadItem.filename, as a path
29 // relative to the user's default Downloads directory, possibly containing 29 // relative to the user's default Downloads directory, possibly containing
30 // subdirectories. Absolute paths, empty paths, and paths containing 30 // subdirectories. Absolute paths, empty paths, and paths containing
31 // back-references ".." will be ignored. 31 // back-references ".." will be ignored.
32 DOMString filename; 32 DOMString filename;
33 33
34 // The action to take if <code>filename</code> already exists. 34 // The action to take if <code>filename</code> already exists.
35 FilenameConflictAction? conflict_action; 35 FilenameConflictAction? conflictAction;
36 }; 36 };
37 37
38 [inline_doc] enum HttpMethod {GET, POST}; 38 [inline_doc] enum HttpMethod {GET, POST};
39 39
40 enum InterruptReason {
41 FILE_FAILED,
42 FILE_ACCESS_DENIED,
43 FILE_NO_SPACE,
44 FILE_NAME_TOO_LONG,
45 FILE_TOO_LARGE,
46 FILE_VIRUS_INFECTED,
47 FILE_TRANSIENT_ERROR,
48 FILE_BLOCKED,
49 FILE_SECURITY_CHECK_FAILED,
50 FILE_TOO_SHORT,
51 NETWORK_FAILED,
52 NETWORK_TIMEOUT,
53 NETWORK_DISCONNECTED,
54 NETWORK_SERVER_DOWN,
55 SERVER_FAILED,
56 SERVER_NO_RANGE,
57 SERVER_PRECONDITION,
58 SERVER_BAD_CONTENT,
59 USER_CANCELED,
60 USER_SHUTDOWN,
61 CRASH};
62
40 [inline_doc] dictionary DownloadOptions { 63 [inline_doc] dictionary DownloadOptions {
41 // The URL to download. 64 // The URL to download.
42 DOMString url; 65 DOMString url;
43 66
44 // A file path relative to the Downloads directory to contain the downloaded 67 // A file path relative to the Downloads directory to contain the downloaded
45 // file. Cannot yet contain subdirectories; support for subdirectories will 68 // file, possibly containing subdirectories. Absolute paths, empty paths,
46 // be implemented before this API is released to the stable channel. See 69 // and paths containing back-references ".." will cause an error.
47 // $ref:onDeterminingFilename for how to dynamically suggest a filename 70 // $ref:onDeterminingFilename allows suggesting a filename after the file's
48 // after the file's MIME type and a tentative filename have been determined. 71 // MIME type and a tentative filename have been determined.
49 DOMString? filename; 72 DOMString? filename;
50 73
51 // Use a file-chooser to allow the user to select a filename. 74 // The action to take if <code>filename</code> already exists.
75 FilenameConflictAction? conflictAction;
76
77 // Use a file-chooser to allow the user to select a filename regardless of
78 // whether <code>filename</code> is set or already exists.
52 boolean? saveAs; 79 boolean? saveAs;
53 80
54 // The HTTP method to use if the URL uses the HTTP[S] protocol. 81 // The HTTP method to use if the URL uses the HTTP[S] protocol.
55 HttpMethod? method; 82 HttpMethod? method;
56 83
57 // Extra HTTP headers to send with the request if the URL uses the HTTP[s] 84 // Extra HTTP headers to send with the request if the URL uses the HTTP[s]
58 // protocol. Each header is represented as a dictionary containing the keys 85 // protocol. Each header is represented as a dictionary containing the keys
59 // <code>name</code> and either <code>value</code> or 86 // <code>name</code> and either <code>value</code> or
60 // <code>binaryValue</code>, restricted to those allowed by XMLHttpRequest. 87 // <code>binaryValue</code>, restricted to those allowed by XMLHttpRequest.
61 HeaderNameValuePair[]? headers; 88 HeaderNameValuePair[]? headers;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 enum State {in_progress, interrupted, complete}; 123 enum State {in_progress, interrupted, complete};
97 124
98 // The state of the process of downloading a file. 125 // The state of the process of downloading a file.
99 dictionary DownloadItem { 126 dictionary DownloadItem {
100 // An identifier that is persistent across browser sessions. 127 // An identifier that is persistent across browser sessions.
101 long id; 128 long id;
102 129
103 // Absolute URL. 130 // Absolute URL.
104 DOMString url; 131 DOMString url;
105 132
133 // Absolute URL.
134 DOMString referrer;
135
106 // Absolute local path. 136 // Absolute local path.
107 DOMString filename; 137 DOMString filename;
108 138
109 // False if this download is recorded in the history, true if it is not 139 // False if this download is recorded in the history, true if it is not
110 // recorded. 140 // recorded.
111 boolean incognito; 141 boolean incognito;
112 142
113 // Indication of whether this download is thought to be safe or known to be 143 // Indication of whether this download is thought to be safe or known to be
114 // suspicious. 144 // suspicious.
115 DangerType danger; 145 DangerType danger;
116 146
117 // True if the user has accepted the download's danger.
118 boolean? dangerAccepted;
119
120 // The file's MIME type. 147 // The file's MIME type.
121 DOMString mime; 148 DOMString mime;
122 149
123 // The time when the download began in ISO 8601 format. May be passed 150 // The time when the download began in ISO 8601 format. May be passed
124 // directly to the Date constructor: <code>chrome.downloads.search({}, 151 // directly to the Date constructor: <code>chrome.downloads.search({},
125 // function(items){items.forEach(function(item){console.log(new 152 // function(items){items.forEach(function(item){console.log(new
126 // Date(item.startTime))})})</code> 153 // Date(item.startTime))})})</code>
127 DOMString startTime; 154 DOMString startTime;
128 155
129 // The time when the download ended in ISO 8601 format. May be passed 156 // The time when the download ended in ISO 8601 format. May be passed
130 // directly to the Date constructor: <code>chrome.downloads.search({}, 157 // directly to the Date constructor: <code>chrome.downloads.search({},
131 // function(items){items.forEach(function(item){if (item.endTime) 158 // function(items){items.forEach(function(item){if (item.endTime)
132 // console.log(new Date(item.endTime))})})</code> 159 // console.log(new Date(item.endTime))})})</code>
133 DOMString? endTime; 160 DOMString? endTime;
134 161
162 // Estimated time when the download will complete in ISO 8601 format. May be
163 // passed directly to the Date constructor:
164 // <code>chrome.downloads.search({},
165 // function(items){items.forEach(function(item){if (item.estimatedEndTime)
166 // console.log(new Date(item.estimatedEndTime))})})</code>
167 DOMString? estimatedEndTime;
168
135 // Indicates whether the download is progressing, interrupted, or complete. 169 // Indicates whether the download is progressing, interrupted, or complete.
136 State state; 170 State state;
137 171
138 // True if the download has stopped reading data from the host, but kept the 172 // True if the download has stopped reading data from the host, but kept the
139 // connection open. 173 // connection open.
140 boolean paused; 174 boolean paused;
141 175
142 // Number indicating why a download was interrupted. 176 // True if the download is in progress and paused, or else if it is
143 long? error; 177 // interrupted and can be resumed starting from where it was interrupted.
178 boolean canResume;
179
180 // Why the download was interrupted. Several kinds of HTTP errors may be
181 // grouped under one of the errors beginning with <code>SERVER_</code>.
182 // Errors relating to the network begin with <code>NETWORK_</code>, errors
183 // relating to the process of writing the file to the file system begin with
184 // <code>FILE_</code>, and interruptions initiated by the user begin with
185 // <code>USER_</code>.
186 InterruptReason? error;
144 187
145 // Number of bytes received so far from the host, without considering file 188 // Number of bytes received so far from the host, without considering file
146 // compression. 189 // compression.
147 long bytesReceived; 190 long bytesReceived;
148 191
149 // Number of bytes in the whole file, without considering file compression, 192 // Number of bytes in the whole file, without considering file compression,
150 // or -1 if unknown. 193 // or -1 if unknown.
151 long totalBytes; 194 long totalBytes;
152 195
153 // Number of bytes in the whole file post-decompression, or -1 if unknown. 196 // Number of bytes in the whole file post-decompression, or -1 if unknown.
154 long fileSize; 197 long fileSize;
155 198
156 // Whether the downloaded file still exists. This information may be out of 199 // Whether the downloaded file still exists. This information may be out of
157 // date because Chrome does not automatically watch for file removal. Call 200 // date because Chrome does not automatically watch for file removal. Call
158 // $ref:search() in order to trigger the check for file existence. When the 201 // $ref:search() in order to trigger the check for file existence. When the
159 // existence check completes, if the file has been deleted, then an 202 // existence check completes, if the file has been deleted, then an
160 // $ref:onChanged event will fire. Note that $ref:search() does not wait 203 // $ref:onChanged event will fire. Note that $ref:search() does not wait
161 // for the existence check to finish before returning, so results from 204 // for the existence check to finish before returning, so results from
162 // $ref:search() may not accurately reflect the file system. Also, 205 // $ref:search() may not accurately reflect the file system. Also,
163 // $ref:search() may be called as often as necessary, but will not check for 206 // $ref:search() may be called as often as necessary, but will not check for
164 // file existence any more frequently than once every 10 seconds. 207 // file existence any more frequently than once every 10 seconds.
165 boolean exists; 208 boolean exists;
166 }; 209 };
167 210
168 [inline_doc] dictionary DownloadQuery { 211 [inline_doc] dictionary DownloadQuery {
169 // This space-separated string of search terms that may be grouped using 212 // This array of search terms limits results to $ref:DownloadItem whose
170 // quotation marks limits results to 213 // <code>filename</code> or <code>url</code> contain all of the search terms
171 // $ref:DownloadItem whose <code>filename</code> 214 // that do not begin with a dash '-' and none of the search terms that do
172 // or <code>url</code> contain all of the search terms that do not begin wit h a dash '-' 215 // begin with a dash.
173 // and none of the search terms that do begin with a dash. 216 DOMString[]? query;
174 DOMString? query;
175 217
176 // Limits results to $ref:DownloadItem that 218 // Limits results to $ref:DownloadItem that
177 // started before the given ms since the epoch. 219 // started before the given ms since the epoch.
178 DOMString? startedBefore; 220 DOMString? startedBefore;
179 221
180 // Limits results to $ref:DownloadItem that 222 // Limits results to $ref:DownloadItem that
181 // started after the given ms since the epoch. 223 // started after the given ms since the epoch.
182 DOMString? startedAfter; 224 DOMString? startedAfter;
183 225
184 // Limits results to $ref:DownloadItem that ended before the given ms since the 226 // Limits results to $ref:DownloadItem that ended before the given ms since the
(...skipping 13 matching lines...) Expand all
198 long? totalBytesLess; 240 long? totalBytesLess;
199 241
200 // Limits results to $ref:DownloadItem whose 242 // Limits results to $ref:DownloadItem whose
201 // <code>filename</code> matches the given regular expression. 243 // <code>filename</code> matches the given regular expression.
202 DOMString? filenameRegex; 244 DOMString? filenameRegex;
203 245
204 // Limits results to $ref:DownloadItem whose 246 // Limits results to $ref:DownloadItem whose
205 // <code>url</code> matches the given regular expression. 247 // <code>url</code> matches the given regular expression.
206 DOMString? urlRegex; 248 DOMString? urlRegex;
207 249
208 // Setting this integer limits the number of results. Otherwise, all 250 // The maximum number of matching $ref:DownloadItem returned. Defaults to
209 // matching $ref:DownloadItem will be returned. 251 // 1000. Set to 0 in order to return all matching $ref:DownloadItem. See
252 // $ref:search for how to page through results.
210 long? limit; 253 long? limit;
211 254
212 // Setting this string to a $ref:DownloadItem 255 // Set elements of this array to $ref:DownloadItem properties in order to
213 // property sorts the $ref:DownloadItem prior 256 // sort search results. For example, setting
214 // to applying the above filters. For example, setting 257 // <code>orderBy=['startTime']</code> sorts the $ref:DownloadItem by their
215 // <code>orderBy='startTime'</code> sorts the 258 // start time in ascending order. To specify descending order, prefix with a
216 // $ref:DownloadItem by their start time in 259 // hyphen: '-startTime'.
217 // ascending order. To specify descending order, prefix <code>orderBy</code> 260 DOMString[]? orderBy;
218 // with a hyphen: '-startTime'.
219 DOMString? orderBy;
220 261
221 // The <code>id</code> of the $ref:DownloadItem to query. 262 // The <code>id</code> of the $ref:DownloadItem to query.
222 long? id; 263 long? id;
223 264
224 // Absolute URL. 265 // Absolute URL.
225 DOMString? url; 266 DOMString? url;
226 267
227 // Absolute local path. 268 // Absolute local path.
228 DOMString? filename; 269 DOMString? filename;
229 270
230 // Indication of whether this download is thought to be safe or known to be 271 // Indication of whether this download is thought to be safe or known to be
231 // suspicious. 272 // suspicious.
232 DangerType? danger; 273 DangerType? danger;
233 274
234 // True if the user has accepted the download's danger.
235 boolean? dangerAccepted;
236
237 // The file's MIME type. 275 // The file's MIME type.
238 DOMString? mime; 276 DOMString? mime;
239 277
240 // The time when the download began in ISO 8601 format. 278 // The time when the download began in ISO 8601 format.
241 DOMString? startTime; 279 DOMString? startTime;
242 280
243 // The time when the download ended in ISO 8601 format. 281 // The time when the download ended in ISO 8601 format.
244 DOMString? endTime; 282 DOMString? endTime;
245 283
246 // Indicates whether the download is progressing, interrupted, or complete. 284 // Indicates whether the download is progressing, interrupted, or complete.
247 State? state; 285 State? state;
248 286
249 // True if the download has stopped reading data from the host, but kept the 287 // True if the download has stopped reading data from the host, but kept the
250 // connection open. 288 // connection open.
251 boolean? paused; 289 boolean? paused;
252 290
253 // Number indicating why a download was interrupted. 291 // Why a download was interrupted.
254 long? error; 292 InterruptReason? error;
255 293
256 // Number of bytes received so far from the host, without considering file 294 // Number of bytes received so far from the host, without considering file
257 // compression. 295 // compression.
258 long? bytesReceived; 296 long? bytesReceived;
259 297
260 // Number of bytes in the whole file, without considering file compression, 298 // Number of bytes in the whole file, without considering file compression,
261 // or -1 if unknown. 299 // or -1 if unknown.
262 long? totalBytes; 300 long? totalBytes;
263 301
264 // Number of bytes in the whole file post-decompression, or -1 if unknown. 302 // Number of bytes in the whole file post-decompression, or -1 if unknown.
(...skipping 26 matching lines...) Expand all
291 329
292 // The change in <code>url</code>, if any. 330 // The change in <code>url</code>, if any.
293 StringDelta? url; 331 StringDelta? url;
294 332
295 // The change in <code>filename</code>, if any. 333 // The change in <code>filename</code>, if any.
296 StringDelta? filename; 334 StringDelta? filename;
297 335
298 // The change in <code>danger</code>, if any. 336 // The change in <code>danger</code>, if any.
299 StringDelta? danger; 337 StringDelta? danger;
300 338
301 // The change in <code>dangerAccepted</code>, if any.
302 BooleanDelta? dangerAccepted;
303
304 // The change in <code>mime</code>, if any. 339 // The change in <code>mime</code>, if any.
305 StringDelta? mime; 340 StringDelta? mime;
306 341
307 // The change in <code>startTime</code>, if any. 342 // The change in <code>startTime</code>, if any.
308 StringDelta? startTime; 343 StringDelta? startTime;
309 344
310 // The change in <code>endTime</code>, if any. 345 // The change in <code>endTime</code>, if any.
311 StringDelta? endTime; 346 StringDelta? endTime;
312 347
313 // The change in <code>state</code>, if any. 348 // The change in <code>state</code>, if any.
314 StringDelta? state; 349 StringDelta? state;
315 350
351 // The change in <code>canResume</code>, if any.
352 BooleanDelta? canResume;
353
316 // The change in <code>paused</code>, if any. 354 // The change in <code>paused</code>, if any.
317 BooleanDelta? paused; 355 BooleanDelta? paused;
318 356
319 // The change in <code>error</code>, if any. 357 // The change in <code>error</code>, if any.
320 LongDelta? error; 358 StringDelta? error;
321 359
322 // The change in <code>totalBytes</code>, if any. 360 // The change in <code>totalBytes</code>, if any.
323 LongDelta? totalBytes; 361 LongDelta? totalBytes;
324 362
325 // The change in <code>fileSize</code>, if any. 363 // The change in <code>fileSize</code>, if any.
326 LongDelta? fileSize; 364 LongDelta? fileSize;
327 365
328 // The change in <code>exists</code>, if any. 366 // The change in <code>exists</code>, if any.
329 BooleanDelta? exists; 367 BooleanDelta? exists;
330 }; 368 };
(...skipping 22 matching lines...) Expand all
353 // <code>downloadId</code>. If there was an error starting the download, 391 // <code>downloadId</code>. If there was an error starting the download,
354 // then <code>callback</code> will be called with 392 // then <code>callback</code> will be called with
355 // <code>downloadId=undefined</code> and $ref:runtime.lastError will contain 393 // <code>downloadId=undefined</code> and $ref:runtime.lastError will contain
356 // a descriptive string. The error strings are not guaranteed to remain 394 // a descriptive string. The error strings are not guaranteed to remain
357 // backwards compatible between releases. Extensions must not parse it. 395 // backwards compatible between releases. Extensions must not parse it.
358 // |options|: What to download and how. 396 // |options|: What to download and how.
359 // |callback|: Called with the id of the new $ref:DownloadItem. 397 // |callback|: Called with the id of the new $ref:DownloadItem.
360 static void download(DownloadOptions options, 398 static void download(DownloadOptions options,
361 optional DownloadCallback callback); 399 optional DownloadCallback callback);
362 400
363 // Find $ref:DownloadItem. Set 401 // Find $ref:DownloadItem. Set <code>query</code> to the empty object to get
364 // <code>query</code> to the empty object to get all 402 // all $ref:DownloadItem. To get a specific $ref:DownloadItem, set only the
365 // $ref:DownloadItem. To get a specific 403 // <code>id</code> field. To page through a large number of items, set
366 // $ref:DownloadItem, set only the <code>id</code> 404 // <code>orderBy: ['-startTime']</code>, set <code>limit</code> to the
367 // field. 405 // number of items per page, and set <code>startedAfter</code> to the
406 // <code>startTime</code> of the last item from the last page.
368 static void search(DownloadQuery query, SearchCallback callback); 407 static void search(DownloadQuery query, SearchCallback callback);
369 408
370 // Pause the download. If the request was successful the download is in a 409 // Pause the download. If the request was successful the download is in a
371 // paused state. Otherwise 410 // paused state. Otherwise $ref:runtime.lastError contains an error message.
372 // $ref:runtime.lastError 411 // The request will fail if the download is not active.
373 // contains an error message. The request will fail if the download is not
374 // active.
375 // |downloadId|: The id of the download to pause. 412 // |downloadId|: The id of the download to pause.
376 // |callback|: Called when the pause request is completed. 413 // |callback|: Called when the pause request is completed.
377 static void pause(long downloadId, optional NullCallback callback); 414 static void pause(long downloadId, optional NullCallback callback);
378 415
379 // Resume a paused download. If the request was successful the download is 416 // Resume a paused download. If the request was successful the download is
380 // in progress and unpaused. Otherwise 417 // in progress and unpaused. Otherwise $ref:runtime.lastError contains an
381 // $ref:runtime.lastError 418 // error message. The request will fail if the download is not active.
382 // contains an error message. The request will fail if the download is not
383 // active.
384 // |downloadId|: The id of the download to resume. 419 // |downloadId|: The id of the download to resume.
385 // |callback|: Called when the resume request is completed. 420 // |callback|: Called when the resume request is completed.
386 static void resume(long downloadId, optional NullCallback callback); 421 static void resume(long downloadId, optional NullCallback callback);
387 422
388 // Cancel a download. When <code>callback</code> is run, the download is 423 // Cancel a download. When <code>callback</code> is run, the download is
389 // cancelled, completed, interrupted or doesn't exist anymore. 424 // cancelled, completed, interrupted or doesn't exist anymore.
390 // |downloadId|: The id of the download to cancel. 425 // |downloadId|: The id of the download to cancel.
391 // |callback|: Called when the cancel request is completed. 426 // |callback|: Called when the cancel request is completed.
392 static void cancel(long downloadId, optional NullCallback callback); 427 static void cancel(long downloadId, optional NullCallback callback);
393 428
394 // Retrieve an icon for the specified download. For new downloads, file 429 // Retrieve an icon for the specified download. For new downloads, file
395 // icons are available after the $ref:onCreated 430 // icons are available after the $ref:onCreated event has been received. The
396 // event has been received. The image returned by this function while a 431 // image returned by this function while a download is in progress may be
397 // download is in progress may be different from the image returned after 432 // different from the image returned after the download is complete. Icon
398 // the download is complete. Icon retrieval is done by querying the 433 // retrieval is done by querying the underlying operating system or toolkit
399 // underlying operating system or toolkit depending on the platform. The 434 // depending on the platform. The icon that is returned will therefore
400 // icon that is returned will therefore depend on a number of factors 435 // depend on a number of factors including state of the download, platform,
401 // including state of the download, platform, registered file types and 436 // registered file types and visual theme. If a file icon cannot be
402 // visual theme. If a file icon cannot be determined, 437 // determined, $ref:runtime.lastError will contain an error message.
403 // $ref:runtime.lastError
404 // will contain an error message.
405 // |downloadId|: The identifier for the download. 438 // |downloadId|: The identifier for the download.
406 // |callback|: A URL to an image that represents the download. 439 // |callback|: A URL to an image that represents the download.
407 static void getFileIcon(long downloadId, 440 static void getFileIcon(long downloadId,
408 optional GetFileIconOptions options, 441 optional GetFileIconOptions options,
409 GetFileIconCallback callback); 442 GetFileIconCallback callback);
410 443
411 // Open the downloaded file now if the $ref:DownloadItem is complete; 444 // Open the downloaded file now if the $ref:DownloadItem is complete;
412 // returns an error through $ref:runtime.lastError otherwise. Requires the 445 // otherwise returns an error through $ref:runtime.lastError. Requires the
413 // <code>"downloads.open"</code> permission in addition to the 446 // <code>"downloads.open"</code> permission in addition to the
414 // <code>"downloads"</code> permission. An $ref:onChanged event will fire 447 // <code>"downloads"</code> permission. An $ref:onChanged event will fire
415 // when the item is opened for the first time. 448 // when the item is opened for the first time.
416 // |downloadId|: The identifier for the downloaded file. 449 // |downloadId|: The identifier for the downloaded file.
417 static void open(long downloadId); 450 static void open(long downloadId);
418 451
419 // Show the downloaded file in its folder in a file manager. 452 // Show the downloaded file in its folder in a file manager.
420 // |downloadId|: The identifier for the downloaded file. 453 // |downloadId|: The identifier for the downloaded file.
421 static void show(long downloadId); 454 static void show(long downloadId);
422 455
423 // Erase matching $ref:DownloadItem from history. An $ref:onErased event 456 // Show the default Downloads folder in a file manager.
424 // will fire for each $ref:DownloadItem that matches <code>query</code>, 457 static void showDefaultFolder();
425 // then <code>callback</code> will be called. 458
459 // Erase matching $ref:DownloadItem from history without deleting the
460 // downloaded file. An $ref:onErased event will fire for each
461 // $ref:DownloadItem that matches <code>query</code>, then
462 // <code>callback</code> will be called.
426 static void erase(DownloadQuery query, optional EraseCallback callback); 463 static void erase(DownloadQuery query, optional EraseCallback callback);
427 464
465 // Remove the downloaded file if it exists and the $ref:DownloadItem is
466 // complete; otherwise return an error through $ref:runtime.lastError.
467 static void removeFile(long downloadId, optional NullCallback callback);
468
428 // Prompt the user to accept a dangerous download. Does not automatically 469 // Prompt the user to accept a dangerous download. Does not automatically
429 // accept dangerous downloads. If the download is accepted, then an 470 // accept dangerous downloads. If the download is accepted, then an
430 // $ref:onChanged event will fire, otherwise nothing will happen. When all 471 // $ref:onChanged event will fire, otherwise nothing will happen. When all
431 // the data is fetched into a temporary file and either the download is not 472 // the data is fetched into a temporary file and either the download is not
432 // dangerous or the danger has been accepted, then the temporary file is 473 // dangerous or the danger has been accepted, then the temporary file is
433 // renamed to the target filename, the |state| changes to 'complete', and 474 // renamed to the target filename, the |state| changes to 'complete', and
434 // $ref:onChanged fires. 475 // $ref:onChanged fires.
435 // |downloadId|: The identifier for the $ref:DownloadItem. 476 // |downloadId|: The identifier for the $ref:DownloadItem.
436 static void acceptDanger(long downloadId); 477 // |callback|: Called when the danger prompt dialog closes.
478 static void acceptDanger(long downloadId, optional NullCallback callback);
437 479
438 // Initiate dragging the downloaded file to another application. 480 // Initiate dragging the downloaded file to another application. Call in a
481 // javascript <code>ondragstart</code> handler.
439 static void drag(long downloadId); 482 static void drag(long downloadId);
440 }; 483 };
441 484
442 interface Events { 485 interface Events {
443 // This event fires with the $ref:DownloadItem 486 // This event fires with the $ref:DownloadItem object when a download
444 // object when a download begins. 487 // begins.
445 static void onCreated(DownloadItem downloadItem); 488 static void onCreated(DownloadItem downloadItem);
446 489
447 // Fires with the <code>downloadId</code> when a download is erased from 490 // Fires with the <code>downloadId</code> when a download is erased from
448 // history. 491 // history.
449 // |downloadId|: The <code>id</code> of the $ref:DownloadItem that was 492 // |downloadId|: The <code>id</code> of the $ref:DownloadItem that was
450 // erased. 493 // erased.
451 static void onErased(long downloadId); 494 static void onErased(long downloadId);
452 495
453 // When any of a $ref:DownloadItem's properties except 496 // When any of a $ref:DownloadItem's properties except
454 // <code>bytesReceived</code> changes, this event fires with the 497 // <code>bytesReceived</code> and <code>estimatedEndTime</code> changes,
455 // <code>downloadId</code> and an object containing the properties that 498 // this event fires with the <code>downloadId</code> and an object
456 // changed. 499 // containing the properties that changed.
457 static void onChanged(DownloadDelta downloadDelta); 500 static void onChanged(DownloadDelta downloadDelta);
458 501
459 // During the filename determination process, extensions will be given the 502 // During the filename determination process, extensions will be given the
460 // opportunity to override the target $ref:DownloadItem.filename. Each 503 // opportunity to override the target $ref:DownloadItem.filename. Each
461 // extension may not register more than one listener for this event. Each 504 // extension may not register more than one listener for this event. Each
462 // listener must call <code>suggest</code> exactly once, either 505 // listener must call <code>suggest</code> exactly once, either
463 // synchronously or asynchronously. If the listener calls 506 // synchronously or asynchronously. If the listener calls
464 // <code>suggest</code> asynchronously, then it must return 507 // <code>suggest</code> asynchronously, then it must return
465 // <code>true</code>. If the listener neither calls <code>suggest</code> 508 // <code>true</code>. If the listener neither calls <code>suggest</code>
466 // synchronously nor returns <code>true</code>, then <code>suggest</code> 509 // synchronously nor returns <code>true</code>, then <code>suggest</code>
467 // will be called automatically. The $ref:DownloadItem will not complete 510 // will be called automatically. The $ref:DownloadItem will not complete
468 // until all listeners have called <code>suggest</code>. Listeners may call 511 // until all listeners have called <code>suggest</code>. Listeners may call
469 // <code>suggest</code> without any arguments in order to allow the download 512 // <code>suggest</code> without any arguments in order to allow the download
470 // to use <code>downloadItem.filename</code> for its filename, or pass a 513 // to use <code>downloadItem.filename</code> for its filename, or pass a
471 // <code>suggestion</code> object to <code>suggest</code> in order to 514 // <code>suggestion</code> object to <code>suggest</code> in order to
472 // override the target filename. If more than one extension overrides the 515 // override the target filename. If more than one extension overrides the
473 // filename, then the last extension installed whose listener passes a 516 // filename, then the last extension installed whose listener passes a
474 // <code>suggestion</code> object to <code>suggest</code> wins. In order to 517 // <code>suggestion</code> object to <code>suggest</code> wins. In order to
475 // avoid confusion regarding which extension will win, users should not 518 // avoid confusion regarding which extension will win, users should not
476 // install extensions that may conflict. If the download is initiated by 519 // install extensions that may conflict. If the download is initiated by
477 // $ref:download and the target filename is known before the MIME type and 520 // $ref:download and the target filename is known before the MIME type and
478 // tentative filename have been determined, pass <code>filename</code> to 521 // tentative filename have been determined, pass <code>filename</code> to
479 // $ref:download instead. 522 // $ref:download instead.
480 [maxListeners=1] static void onDeterminingFilename( 523 [maxListeners=1] static void onDeterminingFilename(
481 DownloadItem downloadItem, SuggestFilenameCallback suggest); 524 DownloadItem downloadItem, SuggestFilenameCallback suggest);
482 }; 525 };
483 }; 526 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698