2013-12-20 21:43:46 +00:00
|
|
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2014-01-24 19:53:05 +00:00
|
|
|
// Represents the state of a download.
|
|
|
|
// "downloading": The resource is actively transfering.
|
|
|
|
// "stopped" : No network tranfer is happening.
|
|
|
|
// "succeeded" : The resource has been downloaded successfully.
|
|
|
|
// "finalized" : We won't try to download this resource, but the DOM
|
|
|
|
// object is still alive.
|
|
|
|
enum DownloadState {
|
|
|
|
"downloading",
|
|
|
|
"stopped",
|
|
|
|
"succeeded",
|
|
|
|
"finalized"
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// XXXTODO: When we have a generic way to do feature detection in marketplace
|
2014-05-25 18:31:11 +00:00
|
|
|
// we will *STOP* using the pref and use CheckPermissions like
|
|
|
|
// DOMDownload and DownloadEvent.
|
2014-01-24 19:53:05 +00:00
|
|
|
//
|
|
|
|
[NoInterfaceObject,
|
|
|
|
NavigatorProperty="mozDownloadManager",
|
2013-12-20 21:43:46 +00:00
|
|
|
JSImplementation="@mozilla.org/downloads/manager;1",
|
2014-01-23 13:22:24 +00:00
|
|
|
Pref="dom.mozDownloads.enabled"]
|
2013-12-20 21:43:46 +00:00
|
|
|
interface DOMDownloadManager : EventTarget {
|
|
|
|
// This promise returns an array of downloads with all the current
|
|
|
|
// download objects.
|
2014-08-01 03:50:30 +00:00
|
|
|
Promise<sequence<DOMDownload>> getDownloads();
|
2013-12-20 21:43:46 +00:00
|
|
|
|
|
|
|
// Removes one download from the downloads set. Returns a promise resolved
|
|
|
|
// with the finalized download.
|
2014-08-01 03:50:30 +00:00
|
|
|
Promise<DOMDownload> remove(DOMDownload download);
|
2013-12-20 21:43:46 +00:00
|
|
|
|
2014-08-01 03:50:30 +00:00
|
|
|
// Removes all the completed downloads from the set. Returns an
|
|
|
|
// array of the completed downloads that were removed.
|
|
|
|
Promise<sequence<DOMDownload>> clearAllDone();
|
2013-12-20 21:43:46 +00:00
|
|
|
|
|
|
|
// Fires when a new download starts.
|
|
|
|
attribute EventHandler ondownloadstart;
|
|
|
|
};
|
|
|
|
|
|
|
|
[JSImplementation="@mozilla.org/downloads/download;1",
|
2014-05-25 18:31:11 +00:00
|
|
|
Pref="dom.mozDownloads.enabled",
|
|
|
|
CheckPermissions="downloads"]
|
2013-12-20 21:43:46 +00:00
|
|
|
interface DOMDownload : EventTarget {
|
|
|
|
// The full size of the resource.
|
2014-02-25 23:38:56 +00:00
|
|
|
readonly attribute long long totalBytes;
|
2013-12-20 21:43:46 +00:00
|
|
|
|
|
|
|
// The number of bytes that we have currently downloaded.
|
2014-02-25 23:38:56 +00:00
|
|
|
readonly attribute long long currentBytes;
|
2013-12-20 21:43:46 +00:00
|
|
|
|
|
|
|
// The url of the resource.
|
|
|
|
readonly attribute DOMString url;
|
|
|
|
|
2014-05-21 21:13:24 +00:00
|
|
|
// The full path in local storage where the file will end up once the download
|
2013-12-20 21:43:46 +00:00
|
|
|
// is complete.
|
|
|
|
readonly attribute DOMString path;
|
|
|
|
|
2014-05-21 21:13:24 +00:00
|
|
|
// The DeviceStorage volume name on which the file is being downloaded.
|
|
|
|
readonly attribute DOMString storageName;
|
|
|
|
|
|
|
|
// The DeviceStorage path on the volume with 'storageName' of the file being
|
|
|
|
// downloaded.
|
|
|
|
readonly attribute DOMString storagePath;
|
|
|
|
|
2014-01-24 19:53:05 +00:00
|
|
|
// The state of the download.
|
|
|
|
readonly attribute DownloadState state;
|
2013-12-20 21:43:46 +00:00
|
|
|
|
|
|
|
// The mime type for this resource.
|
|
|
|
readonly attribute DOMString contentType;
|
|
|
|
|
|
|
|
// The timestamp this download started.
|
|
|
|
readonly attribute Date startTime;
|
|
|
|
|
|
|
|
// An opaque identifier for this download. All instances of the same
|
|
|
|
// download (eg. in different windows) will have the same id.
|
|
|
|
readonly attribute DOMString id;
|
|
|
|
|
|
|
|
// A DOM error object, that will be not null when a download is stopped
|
|
|
|
// because something failed.
|
2014-01-09 00:21:46 +00:00
|
|
|
readonly attribute DOMError? error;
|
2013-12-20 21:43:46 +00:00
|
|
|
|
|
|
|
// Pauses the download.
|
2014-08-01 03:50:30 +00:00
|
|
|
Promise<DOMDownload> pause();
|
2013-12-20 21:43:46 +00:00
|
|
|
|
|
|
|
// Resumes the download. This resolves only once the download has
|
|
|
|
// succeeded.
|
2014-08-01 03:50:30 +00:00
|
|
|
Promise<DOMDownload> resume();
|
2013-12-20 21:43:46 +00:00
|
|
|
|
|
|
|
// This event is triggered anytime a property of the object changes:
|
|
|
|
// - when the transfer progresses, updating currentBytes.
|
|
|
|
// - when the state and/or error attributes change.
|
|
|
|
attribute EventHandler onstatechange;
|
|
|
|
};
|