1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
7 [NavigatorProperty="mozDownloadManager",
8 JSImplementation="@mozilla.org/downloads/manager;1",
9 Pref="dom.mozDownloads.enabled"]
10 interface DOMDownloadManager : EventTarget {
11 // This promise returns an array of downloads with all the current
13 Promise getDownloads();
15 // Removes one download from the downloads set. Returns a promise resolved
16 // with the finalized download.
17 Promise remove(DOMDownload download);
19 // Removes all the completed downloads from the set.
20 Promise clearAllDone();
22 // Fires when a new download starts.
23 attribute EventHandler ondownloadstart;
26 [JSImplementation="@mozilla.org/downloads/download;1",
27 Pref="dom.mozDownloads.enabled"]
28 interface DOMDownload : EventTarget {
29 // The full size of the resource.
30 readonly attribute long totalBytes;
32 // The number of bytes that we have currently downloaded.
33 readonly attribute long currentBytes;
35 // The url of the resource.
36 readonly attribute DOMString url;
38 // The path in local storage where the file will end up once the download
40 readonly attribute DOMString path;
42 // The state of the download. Can be any of:
43 // "downloading": The resource is actively transfering.
44 // "stopped" : No network tranfer is happening.
45 // "succeeded" : The resource has been downloaded successfully.
46 // "finalized" : We won't try to download this resource, but the DOM
47 // object is still alive.
48 readonly attribute DOMString state;
50 // The mime type for this resource.
51 readonly attribute DOMString contentType;
53 // The timestamp this download started.
54 readonly attribute Date startTime;
56 // An opaque identifier for this download. All instances of the same
57 // download (eg. in different windows) will have the same id.
58 readonly attribute DOMString id;
60 // A DOM error object, that will be not null when a download is stopped
61 // because something failed.
62 readonly attribute DOMError error;
64 // Pauses the download.
67 // Resumes the download. This resolves only once the download has
71 // This event is triggered anytime a property of the object changes:
72 // - when the transfer progresses, updating currentBytes.
73 // - when the state and/or error attributes change.
74 attribute EventHandler onstatechange;