2013-12-20 13:43:46 -08: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 11:53:05 -08: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
|
|
|
|
// we will *STOP* using the pref and use the function like DOMDownload
|
|
|
|
// and DownloadEvent.
|
|
|
|
//
|
|
|
|
[NoInterfaceObject,
|
|
|
|
NavigatorProperty="mozDownloadManager",
|
2013-12-20 13:43:46 -08:00
|
|
|
JSImplementation="@mozilla.org/downloads/manager;1",
|
2014-01-23 05:22:24 -08:00
|
|
|
Pref="dom.mozDownloads.enabled"]
|
2013-12-20 13:43:46 -08:00
|
|
|
interface DOMDownloadManager : EventTarget {
|
|
|
|
// This promise returns an array of downloads with all the current
|
|
|
|
// download objects.
|
|
|
|
Promise getDownloads();
|
|
|
|
|
|
|
|
// Removes one download from the downloads set. Returns a promise resolved
|
|
|
|
// with the finalized download.
|
|
|
|
Promise remove(DOMDownload download);
|
|
|
|
|
|
|
|
// Removes all the completed downloads from the set.
|
|
|
|
Promise clearAllDone();
|
|
|
|
|
|
|
|
// Fires when a new download starts.
|
|
|
|
attribute EventHandler ondownloadstart;
|
|
|
|
};
|
|
|
|
|
|
|
|
[JSImplementation="@mozilla.org/downloads/download;1",
|
2014-01-24 11:53:05 -08:00
|
|
|
Func="Navigator::HasDownloadsSupport"]
|
2013-12-20 13:43:46 -08:00
|
|
|
interface DOMDownload : EventTarget {
|
|
|
|
// The full size of the resource.
|
2014-02-25 15:38:56 -08:00
|
|
|
readonly attribute long long totalBytes;
|
2013-12-20 13:43:46 -08:00
|
|
|
|
|
|
|
// The number of bytes that we have currently downloaded.
|
2014-02-25 15:38:56 -08:00
|
|
|
readonly attribute long long currentBytes;
|
2013-12-20 13:43:46 -08:00
|
|
|
|
|
|
|
// The url of the resource.
|
|
|
|
readonly attribute DOMString url;
|
|
|
|
|
2014-05-21 14:07:51 -07:00
|
|
|
// The path in local storage where the file will end up once the download
|
2013-12-20 13:43:46 -08:00
|
|
|
// is complete.
|
|
|
|
readonly attribute DOMString path;
|
|
|
|
|
2014-01-24 11:53:05 -08:00
|
|
|
// The state of the download.
|
|
|
|
readonly attribute DownloadState state;
|
2013-12-20 13:43:46 -08: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-08 16:21:46 -08:00
|
|
|
readonly attribute DOMError? error;
|
2013-12-20 13:43:46 -08:00
|
|
|
|
|
|
|
// Pauses the download.
|
|
|
|
Promise pause();
|
|
|
|
|
|
|
|
// Resumes the download. This resolves only once the download has
|
|
|
|
// succeeded.
|
|
|
|
Promise resume();
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
};
|