OLD | NEW |
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 [permissions=downloads] | 5 [permissions=downloads] |
6 namespace downloads { | 6 namespace downloads { |
7 [inline_doc] dictionary HeaderNameValuePair { | 7 [inline_doc] dictionary HeaderNameValuePair { |
8 // Name of the HTTP header. | 8 // Name of the HTTP header. |
9 DOMString name; | 9 DOMString name; |
10 | 10 |
11 // Value of the HTTP header. | 11 // Value of the HTTP header. |
12 DOMString value; | 12 DOMString value; |
13 }; | 13 }; |
14 | 14 |
| 15 // $ref:onDeterminingFilename handlers may return a FilenameDetermination |
| 16 // object in order to override a download's target filename. |
| 17 dictionary FilenameDetermination { |
| 18 // The download's new target filename, as a path relative to the user's |
| 19 // default Downloads directory, possibly containing subdirectories. Absolute |
| 20 // paths, empty paths, and paths containing back-references ".." will be |
| 21 // ignored. |
| 22 DOMString filename; |
| 23 |
| 24 // Whether to overwrite any existing files. |
| 25 boolean? overwrite; |
| 26 }; |
| 27 |
15 [inline_doc] enum HttpMethod {GET, POST}; | 28 [inline_doc] enum HttpMethod {GET, POST}; |
16 | 29 |
17 [inline_doc] dictionary DownloadOptions { | 30 [inline_doc] dictionary DownloadOptions { |
18 // The URL to download. | 31 // The URL to download. |
19 DOMString url; | 32 DOMString url; |
20 | 33 |
21 // A file path relative to the Downloads directory to contain the downloaded | 34 // A file path relative to the Downloads directory to contain the downloaded |
22 // file. | 35 // file. |
23 DOMString? filename; | 36 DOMString? filename; |
24 | 37 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 | 399 |
387 // Show the downloaded file in its folder in a file manager. | 400 // Show the downloaded file in its folder in a file manager. |
388 // |downloadId|: The identifier for the downloaded file. | 401 // |downloadId|: The identifier for the downloaded file. |
389 static void show(long downloadId); | 402 static void show(long downloadId); |
390 | 403 |
391 // Erase matching $ref:DownloadItem from history. An $ref:onErased event | 404 // Erase matching $ref:DownloadItem from history. An $ref:onErased event |
392 // will fire for each $ref:DownloadItem that matches <code>query</code>, | 405 // will fire for each $ref:DownloadItem that matches <code>query</code>, |
393 // then <code>callback</code> will be called. | 406 // then <code>callback</code> will be called. |
394 static void erase(DownloadQuery query, optional EraseCallback callback); | 407 static void erase(DownloadQuery query, optional EraseCallback callback); |
395 | 408 |
396 // TODO(benjhayden) Comment. | |
397 [nodoc] static void setDestination(long downloadId, DOMString relativePath); | |
398 | |
399 // Prompt the user to accept a dangerous download. Does not automatically | 409 // Prompt the user to accept a dangerous download. Does not automatically |
400 // accept dangerous downloads. If the download is accepted, then an | 410 // accept dangerous downloads. If the download is accepted, then an |
401 // $ref:onChanged event will fire, otherwise nothing will happen. When all | 411 // $ref:onChanged event will fire, otherwise nothing will happen. When all |
402 // the data is fetched into a temporary file and either the download is not | 412 // the data is fetched into a temporary file and either the download is not |
403 // dangerous or the danger has been accepted, then the temporary file is | 413 // dangerous or the danger has been accepted, then the temporary file is |
404 // renamed to the target filename, the |state| changes to 'complete', and | 414 // renamed to the target filename, the |state| changes to 'complete', and |
405 // $ref:onChanged fires. | 415 // $ref:onChanged fires. |
406 // |downloadId|: The identifier for the $ref:DownloadItem. | 416 // |downloadId|: The identifier for the $ref:DownloadItem. |
407 static void acceptDanger(long downloadId); | 417 static void acceptDanger(long downloadId); |
408 | 418 |
409 // Initiate dragging the downloaded file to another application. | 419 // Initiate dragging the downloaded file to another application. |
410 static void drag(long downloadId); | 420 static void drag(long downloadId); |
411 }; | 421 }; |
412 | 422 |
413 interface Events { | 423 interface Events { |
414 // This event fires with the $ref:DownloadItem | 424 // This event fires with the $ref:DownloadItem |
415 // object when a download begins. | 425 // object when a download begins. |
416 static void onCreated(DownloadItem downloadItem); | 426 static void onCreated(DownloadItem downloadItem); |
417 | 427 |
418 // Fires with the <code>downloadId</code> when a download is erased from | 428 // Fires with the <code>downloadId</code> when a download is erased from |
419 // history. | 429 // history. |
420 // |downloadId|: The <code>id</code> of the $ref:DownloadItem that was erase
d. | 430 // |downloadId|: The <code>id</code> of the $ref:DownloadItem that was erase
d. |
421 static void onErased(long downloadId); | 431 static void onErased(long downloadId); |
422 | 432 |
423 // When any of a $ref:DownloadItem's properties | 433 // When any of a $ref:DownloadItem's properties |
424 // except <code>bytesReceived</code> changes, this event fires with the | 434 // except <code>bytesReceived</code> changes, this event fires with the |
425 // <code>downloadId</code> and an object containing the properties that chan
ged. | 435 // <code>downloadId</code> and an object containing the properties that chan
ged. |
426 static void onChanged(DownloadDelta downloadDelta); | 436 static void onChanged(DownloadDelta downloadDelta); |
| 437 |
| 438 // During the filename determination process, extensions will be given the |
| 439 // opportunity to override the target filename. Handlers may return null in |
| 440 // order to allow the target filename to be used, or return a |
| 441 // $ref:FilenameDetermination object in order to override the target |
| 442 // filename. If more than one extension overrides the filename, then one |
| 443 // extension will win. There is no way to predict or choose which extension |
| 444 // will win. Users should be careful to not install extensions that may |
| 445 // conflict. |
| 446 static void onDeterminingFilename(DownloadItem downloadItem); |
427 }; | 447 }; |
428 }; | 448 }; |
OLD | NEW |