package webextension_polyfill.downloads;
typedef Static = {
/**
Download a URL. If the URL uses the HTTP[S] protocol, then the request will include all cookies currently set for its
hostname. If both filename
and saveAs
are specified, then the Save As dialog will be displayed,
pre-populated with the specified filename
. If the download started successfully, callback
will be called with the new DownloadItem's downloadId
.
If there was an error starting the download, then callback
will be called with
downloadId=undefined
and chrome.extension.lastError
will contain a descriptive string. The error strings are not guaranteed to remain backwards compatible between releases.
You must not parse it.
**/
function download(options:DownloadOptionsType):js.lib.Promise;
/**
Find DownloadItems. Set query
to the empty object to get all DownloadItems. To get a specific DownloadItem,
set only the id
field.
**/
function search(query:DownloadQuery):js.lib.Promise>;
/**
Pause the download. If the request was successful the download is in a paused state. Otherwise chrome.extension.lastError contains an error message.
The request will fail if the download is not active.
**/
function pause(downloadId:Float):js.lib.Promise;
/**
Resume a paused download. If the request was successful the download is in progress and unpaused.
Otherwise chrome.extension.lastError contains an error message.
The request will fail if the download is not active.
**/
function resume(downloadId:Float):js.lib.Promise;
/**
Cancel a download. When callback
is run, the download is cancelled, completed,
interrupted or doesn't exist anymore.
**/
function cancel(downloadId:Float):js.lib.Promise;
/**
Retrieve an icon for the specified download. For new downloads, file icons are available after the onCreated event has been received. The image returned by this function while a download is
in progress may be different from the image returned after the download is complete.
Icon retrieval is done by querying the underlying operating system or toolkit depending on the platform.
The icon that is returned will therefore depend on a number of factors including state of the download, platform,
registered file types and visual theme. If a file icon cannot be determined, chrome.extension.lastError will contain an error message.
**/
function getFileIcon(downloadId:Float, ?options:GetFileIconOptionsType):js.lib.Promise;
/**
Open the downloaded file.
**/
function open(downloadId:Float):js.lib.Promise;
/**
Show the downloaded file in its folder in a file manager.
**/
function show(downloadId:Float):js.lib.Promise;
function showDefaultFolder():Void;
/**
Erase matching DownloadItems from history
**/
function erase(query:DownloadQuery):js.lib.Promise>;
function removeFile(downloadId:Float):js.lib.Promise;
/**
This event fires with the DownloadItem object when a download begins.
**/
var onCreated : webextension_polyfill.events.Event<(downloadItem:DownloadItem) -> Void>;
/**
Fires with the downloadId
when a download is erased from history.
**/
var onErased : webextension_polyfill.events.Event<(downloadId:Float) -> Void>;
/**
When any of a DownloadItem's properties except bytesReceived
changes,
this event fires with the downloadId
and an object containing the properties that changed.
**/
var onChanged : webextension_polyfill.events.Event<(downloadDelta:OnChangedDownloadDeltaType) -> Void>;
};