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. | |
mkearney1
2013/02/05 22:00:02
Should this link to filename? I can't see the stag
benjhayden
2013/02/21 22:29:33
Done.
| |
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 | |
Matt Perry
2013/02/04 22:30:19
How do we handle path separators in a cross-platfo
benjhayden
2013/02/05 15:08:05
FilePath allows either / or \ as a path separator
| |
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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 | 402 |
390 // Show the downloaded file in its folder in a file manager. | 403 // Show the downloaded file in its folder in a file manager. |
391 // |downloadId|: The identifier for the downloaded file. | 404 // |downloadId|: The identifier for the downloaded file. |
392 static void show(long downloadId); | 405 static void show(long downloadId); |
393 | 406 |
394 // Erase matching $ref:DownloadItem from history. An $ref:onErased event | 407 // Erase matching $ref:DownloadItem from history. An $ref:onErased event |
395 // will fire for each $ref:DownloadItem that matches <code>query</code>, | 408 // will fire for each $ref:DownloadItem that matches <code>query</code>, |
396 // then <code>callback</code> will be called. | 409 // then <code>callback</code> will be called. |
397 static void erase(DownloadQuery query, optional EraseCallback callback); | 410 static void erase(DownloadQuery query, optional EraseCallback callback); |
398 | 411 |
399 // TODO(benjhayden) Comment. | |
400 [nodoc] static void setDestination(long downloadId, DOMString relativePath); | |
401 | |
402 // Prompt the user to accept a dangerous download. Does not automatically | 412 // Prompt the user to accept a dangerous download. Does not automatically |
403 // accept dangerous downloads. If the download is accepted, then an | 413 // accept dangerous downloads. If the download is accepted, then an |
404 // $ref:onChanged event will fire, otherwise nothing will happen. When all | 414 // $ref:onChanged event will fire, otherwise nothing will happen. When all |
405 // the data is fetched into a temporary file and either the download is not | 415 // the data is fetched into a temporary file and either the download is not |
406 // dangerous or the danger has been accepted, then the temporary file is | 416 // dangerous or the danger has been accepted, then the temporary file is |
407 // renamed to the target filename, the |state| changes to 'complete', and | 417 // renamed to the target filename, the |state| changes to 'complete', and |
408 // $ref:onChanged fires. | 418 // $ref:onChanged fires. |
409 // |downloadId|: The identifier for the $ref:DownloadItem. | 419 // |downloadId|: The identifier for the $ref:DownloadItem. |
410 static void acceptDanger(long downloadId); | 420 static void acceptDanger(long downloadId); |
411 | 421 |
412 // Initiate dragging the downloaded file to another application. | 422 // Initiate dragging the downloaded file to another application. |
413 static void drag(long downloadId); | 423 static void drag(long downloadId); |
414 }; | 424 }; |
415 | 425 |
416 interface Events { | 426 interface Events { |
417 // This event fires with the $ref:DownloadItem | 427 // This event fires with the $ref:DownloadItem |
418 // object when a download begins. | 428 // object when a download begins. |
419 static void onCreated(DownloadItem downloadItem); | 429 static void onCreated(DownloadItem downloadItem); |
420 | 430 |
421 // Fires with the <code>downloadId</code> when a download is erased from | 431 // Fires with the <code>downloadId</code> when a download is erased from |
422 // history. | 432 // history. |
423 // |downloadId|: The <code>id</code> of the $ref:DownloadItem that was erase d. | 433 // |downloadId|: The <code>id</code> of the $ref:DownloadItem that was erase d. |
424 static void onErased(long downloadId); | 434 static void onErased(long downloadId); |
425 | 435 |
426 // When any of a $ref:DownloadItem's properties | 436 // When any of a $ref:DownloadItem's properties |
427 // except <code>bytesReceived</code> changes, this event fires with the | 437 // except <code>bytesReceived</code> changes, this event fires with the |
428 // <code>downloadId</code> and an object containing the properties that chan ged. | 438 // <code>downloadId</code> and an object containing the properties that chan ged. |
429 static void onChanged(DownloadDelta downloadDelta); | 439 static void onChanged(DownloadDelta downloadDelta); |
440 | |
441 // During the filename determination process, extensions will be given the | |
442 // opportunity to override the target filename. Handlers may return null in | |
mkearney1
2013/02/05 22:00:02
Should target filename be a link?
benjhayden
2013/02/21 22:29:33
Done.
| |
443 // order to allow the target filename to be used, or return a | |
444 // $ref:FilenameDetermination object in order to override the target | |
445 // filename. If more than one extension overrides the filename, then the | |
446 // last handler registered in the last extension installed that returns a | |
447 // $ref:FilenameDetermination object wins. Users should not install | |
448 // extensions that may conflict. | |
449 static void onDeterminingFilename(DownloadItem downloadItem); | |
Matt Perry
2013/02/04 22:30:19
Does this really need to be a synchronous API? Wha
benjhayden
2013/02/05 15:08:05
The download system does already start writing to
Randy Smith (Not in Mondays)
2013/02/05 16:40:41
I'd like to second this point--this type of race s
Matt Perry
2013/02/05 20:49:39
OK, sounds like this won't work.
benjhayden
2013/02/05 21:12:19
I am planning on augmenting the onDeterminingFilen
Matt Perry
2013/02/05 21:57:10
I see. In that case, I'd prefer we always use the
benjhayden
2013/02/21 22:29:33
Done.
| |
430 }; | 450 }; |
431 }; | 451 }; |
OLD | NEW |