[ { "namespace": "manifest", "types": [ { "$extend": "Permission", "choices": [{ "type": "string", "enum": [ "downloads", "downloads.open", "downloads.shelf" ] }] } ] }, { "namespace": "downloads", "permissions": ["downloads"], "types": [ { "id": "FilenameConflictAction", "type": "string", "enum": [ "uniquify", "overwrite", "prompt" ] }, { "id": "InterruptReason", "type": "string", "enum": [ "FILE_FAILED", "FILE_ACCESS_DENIED", "FILE_NO_SPACE", "FILE_NAME_TOO_LONG", "FILE_TOO_LARGE", "FILE_VIRUS_INFECTED", "FILE_TRANSIENT_ERROR", "FILE_BLOCKED", "FILE_SECURITY_CHECK_FAILED", "FILE_TOO_SHORT", "NETWORK_FAILED", "NETWORK_TIMEOUT", "NETWORK_DISCONNECTED", "NETWORK_SERVER_DOWN", "NETWORK_INVALID_REQUEST", "SERVER_FAILED", "SERVER_NO_RANGE", "SERVER_BAD_CONTENT", "SERVER_UNAUTHORIZED", "SERVER_CERT_PROBLEM", "SERVER_FORBIDDEN", "USER_CANCELED", "USER_SHUTDOWN", "CRASH" ] }, { "id": "DangerType", "type": "string", "enum": [ "file", "url", "content", "uncommon", "host", "unwanted", "safe", "accepted" ], "description": "
file
The download's filename is suspicious.
url
The download's URL is known to be malicious.
content
The downloaded file is known to be malicious.
uncommon
The download's URL is not commonly downloaded and could be dangerous.
safe
The download presents no known danger to the user's computer.
These string constants will never change, however the set of DangerTypes may change." }, { "id": "State", "type": "string", "enum": [ "in_progress", "interrupted", "complete" ], "description": "
in_progress
The download is currently receiving data from the server.
interrupted
An error broke the connection with the file host.
complete
The download completed successfully.
These string constants will never change, however the set of States may change." }, { "id": "DownloadItem", "type": "object", "properties": { "id": { "description": "An identifier that is persistent across browser sessions.", "type": "integer" }, "url": { "description": "Absolute URL.", "type": "string" }, "referrer": { "type": "string" }, "filename": { "description": "Absolute local path.", "type": "string" }, "incognito": { "description": "False if this download is recorded in the history, true if it is not recorded.", "type": "boolean" }, "danger": { "$ref": "DangerType", "description": "Indication of whether this download is thought to be safe or known to be suspicious." }, "mime": { "description": "The file's MIME type.", "type": "string" }, "startTime": { "description": "Number of milliseconds between the unix epoch and when this download began.", "type": "string" }, "endTime": { "description": "Number of milliseconds between the unix epoch and when this download ended.", "optional": true, "type": "string" }, "estimatedEndTime": { "type": "string", "optional": true }, "state": { "$ref": "State", "description": "Indicates whether the download is progressing, interrupted, or complete." }, "paused": { "description": "True if the download has stopped reading data from the host, but kept the connection open.", "type": "boolean" }, "canResume": { "type": "boolean" }, "error": { "description": "Number indicating why a download was interrupted.", "optional": true, "$ref": "InterruptReason" }, "bytesReceived": { "description": "Number of bytes received so far from the host, without considering file compression.", "type": "number" }, "totalBytes": { "description": "Number of bytes in the whole file, without considering file compression, or -1 if unknown.", "type": "number" }, "fileSize": { "description": "Number of bytes in the whole file post-decompression, or -1 if unknown.", "type": "number" }, "exists": { "type": "boolean" }, "byExtensionId": { "type": "string", "optional": true }, "byExtensionName": { "type": "string", "optional": true } } }, { "id": "StringDelta", "type": "object", "properties": { "current": { "optional": true, "type": "string" }, "previous": { "optional": true, "type": "string" } } }, { "id": "DoubleDelta", "type": "object", "properties": { "current": { "optional": true, "type": "number" }, "previous": { "optional": true, "type": "number" } } }, { "id": "BooleanDelta", "type": "object", "properties": { "current": { "optional": true, "type": "boolean" }, "previous": { "optional": true, "type": "boolean" } } }, { "id": "DownloadTime", "description": "A time specified as a Date object, a number or string representing milliseconds since the epoch, or an ISO 8601 string", "choices": [ { "type": "string", "pattern": "^[1-9]\\d*$" }, { "$ref": "extensionTypes.Date" } ] }, { "id": "DownloadQuery", "description": "Parameters that combine to specify a predicate that can be used to select a set of downloads. Used for example in search() and erase()", "type": "object", "properties": { "query": { "description": "This array of search terms limits results to DownloadItems whose filename or url contain all of the search terms that do not begin with a dash '-' and none of the search terms that do begin with a dash.", "optional": true, "type": "array", "items": { "type": "string" } }, "startedBefore": { "description": "Limits results to downloads that started before the given ms since the epoch.", "optional": true, "$ref": "DownloadTime" }, "startedAfter": { "description": "Limits results to downloads that started after the given ms since the epoch.", "optional": true, "$ref": "DownloadTime" }, "endedBefore": { "description": "Limits results to downloads that ended before the given ms since the epoch.", "optional": true, "$ref": "DownloadTime" }, "endedAfter": { "description": "Limits results to downloads that ended after the given ms since the epoch.", "optional": true, "$ref": "DownloadTime" }, "totalBytesGreater": { "description": "Limits results to downloads whose totalBytes is greater than the given integer.", "optional": true, "type": "number" }, "totalBytesLess": { "description": "Limits results to downloads whose totalBytes is less than the given integer.", "optional": true, "type": "number" }, "filenameRegex": { "description": "Limits results to DownloadItems whose filename matches the given regular expression.", "optional": true, "type": "string" }, "urlRegex": { "description": "Limits results to DownloadItems whose url matches the given regular expression.", "optional": true, "type": "string" }, "limit": { "description": "Setting this integer limits the number of results. Otherwise, all matching DownloadItems will be returned.", "optional": true, "type": "integer" }, "orderBy": { "description": "Setting elements of this array to DownloadItem properties in order to sort the search results. For example, setting orderBy='startTime' sorts the DownloadItems by their start time in ascending order. To specify descending order, prefix orderBy with a hyphen: '-startTime'.", "optional": true, "type": "array", "items": { "type": "string" } }, "id": { "type": "integer", "optional": true }, "url": { "description": "Absolute URL.", "optional": true, "type": "string" }, "filename": { "description": "Absolute local path.", "optional": true, "type": "string" }, "danger": { "$ref": "DangerType", "description": "Indication of whether this download is thought to be safe or known to be suspicious.", "optional": true }, "mime": { "description": "The file's MIME type.", "optional": true, "type": "string" }, "startTime": { "optional": true, "type": "string" }, "endTime": { "optional": true, "type": "string" }, "state": { "$ref": "State", "description": "Indicates whether the download is progressing, interrupted, or complete.", "optional": true }, "paused": { "description": "True if the download has stopped reading data from the host, but kept the connection open.", "optional": true, "type": "boolean" }, "error": { "description": "Why a download was interrupted.", "optional": true, "$ref": "InterruptReason" }, "bytesReceived": { "description": "Number of bytes received so far from the host, without considering file compression.", "optional": true, "type": "number" }, "totalBytes": { "description": "Number of bytes in the whole file, without considering file compression, or -1 if unknown.", "optional": true, "type": "number" }, "fileSize": { "description": "Number of bytes in the whole file post-decompression, or -1 if unknown.", "optional": true, "type": "number" }, "exists": { "type": "boolean", "optional": true } } } ], "functions": [ { "name": "download", "type": "function", "async": "callback", "description": "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.", "parameters": [ { "description": "What to download and how.", "name": "options", "type": "object", "properties": { "url": { "description": "The URL to download.", "type": "string", "format": "url" }, "filename": { "description": "A file path relative to the Downloads directory to contain the downloaded file.", "optional": true, "type": "string" }, "conflictAction": { "$ref": "FilenameConflictAction", "optional": true }, "saveAs": { "description": "Use a file-chooser to allow the user to select a filename.", "optional": true, "type": "boolean" }, "method": { "description": "The HTTP method to use if the URL uses the HTTP[S] protocol.", "enum": [ "GET", "POST" ], "optional": true, "type": "string" }, "headers": { "optional": true, "type": "array", "description": "Extra HTTP headers to send with the request if the URL uses the HTTP[s] protocol. Each header is represented as a dictionary containing the keys name and either value or binaryValue, restricted to those allowed by XMLHttpRequest.", "items": { "type": "object", "properties": { "name": { "description": "Name of the HTTP header.", "type": "string" }, "value": { "description": "Value of the HTTP header.", "type": "string" } } } }, "body": { "description": "Post body.", "optional": true, "type": "string" } } }, { "name": "callback", "type": "function", "optional": true, "parameters": [ { "name": "downloadId", "type": "integer" } ] } ] }, { "name": "search", "type": "function", "async": "callback", "description": "Find DownloadItems. Set query to the empty object to get all DownloadItems. To get a specific DownloadItem, set only the id field.", "parameters": [ { "name": "query", "$ref": "DownloadQuery" }, { "name": "callback", "type": "function", "parameters": [ { "items": { "$ref": "DownloadItem" }, "name": "results", "type": "array" } ] } ] }, { "name": "pause", "type": "function", "async": "callback", "description": "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.", "parameters": [ { "description": "The id of the download to pause.", "name": "downloadId", "type": "integer" }, { "name": "callback", "optional": true, "parameters": [], "type": "function" } ] }, { "name": "resume", "type": "function", "async": "callback", "description": "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.", "parameters": [ { "description": "The id of the download to resume.", "name": "downloadId", "type": "integer" }, { "name": "callback", "optional": true, "parameters": [], "type": "function" } ] }, { "name": "cancel", "type": "function", "async": "callback", "description": "Cancel a download. When callback is run, the download is cancelled, completed, interrupted or doesn't exist anymore.", "parameters": [ { "description": "The id of the download to cancel.", "name": "downloadId", "type": "integer" }, { "name": "callback", "optional": true, "parameters": [], "type": "function" } ] }, { "name": "getFileIcon", "type": "function", "async": "callback", "description": "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.", "parameters": [ { "description": "The identifier for the download.", "name": "downloadId", "type": "integer" }, { "name": "options", "optional": true, "properties": { "size": { "description": "The size of the icon. The returned icon will be square with dimensions size * size pixels. The default size for the icon is 32x32 pixels.", "optional": true, "minimum": 1, "maximum": 127, "type": "integer" } }, "type": "object" }, { "name": "callback", "parameters": [ { "name": "iconURL", "optional": true, "type": "string" } ], "type": "function" } ] }, { "name": "open", "type": "function", "async": "callback", "description": "Open the downloaded file.", "permissions": ["downloads.open"], "parameters": [ { "name": "downloadId", "type": "integer" }, { "name": "callback", "type": "function", "optional": true, "parameters": [] } ] }, { "name": "show", "type": "function", "description": "Show the downloaded file in its folder in a file manager.", "async": "callback", "parameters": [ { "name": "downloadId", "type": "integer" }, { "name": "callback", "type": "function", "optional": true, "parameters": [ { "name": "success", "type": "boolean" } ] } ] }, { "name": "showDefaultFolder", "type": "function", "parameters": [] }, { "name": "erase", "type": "function", "async": "callback", "description": "Erase matching DownloadItems from history", "parameters": [ { "name": "query", "$ref": "DownloadQuery" }, { "name": "callback", "type": "function", "optional": true, "parameters": [ { "items": { "type": "integer" }, "name": "erasedIds", "type": "array" } ] } ] }, { "name": "removeFile", "async": "callback", "type": "function", "parameters": [ { "name": "downloadId", "type": "integer" }, { "name": "callback", "type": "function", "optional": true, "parameters": [ ] } ] }, { "description": "Prompt the user to either accept or cancel a dangerous download. acceptDanger() does not automatically accept dangerous downloads.", "name": "acceptDanger", "unsupported": true, "parameters": [ { "name": "downloadId", "type": "integer" }, { "name": "callback", "type": "function", "optional": true, "parameters": [ ] } ], "type": "function" }, { "description": "Initiate dragging the file to another application.", "name": "drag", "unsupported": true, "parameters": [ { "name": "downloadId", "type": "integer" } ], "type": "function" }, { "name": "setShelfEnabled", "type": "function", "unsupported": true, "parameters": [ { "name": "enabled", "type": "boolean" } ] } ], "events": [ { "description": "This event fires with the DownloadItem object when a download begins.", "name": "onCreated", "parameters": [ { "$ref": "DownloadItem", "name": "downloadItem" } ], "type": "function" }, { "description": "Fires with the downloadId when a download is erased from history.", "name": "onErased", "parameters": [ { "name": "downloadId", "description": "The id of the DownloadItem that was erased.", "type": "integer" } ], "type": "function" }, { "name": "onChanged", "description": "When any of a DownloadItem's properties except bytesReceived changes, this event fires with the downloadId and an object containing the properties that changed.", "parameters": [ { "name": "downloadDelta", "type": "object", "properties": { "id": { "description": "The id of the DownloadItem that changed.", "type": "integer" }, "url": { "description": "Describes a change in a DownloadItem's url.", "optional": true, "$ref": "StringDelta" }, "filename": { "description": "Describes a change in a DownloadItem's filename.", "optional": true, "$ref": "StringDelta" }, "danger": { "description": "Describes a change in a DownloadItem's danger.", "optional": true, "$ref": "StringDelta" }, "mime": { "description": "Describes a change in a DownloadItem's mime.", "optional": true, "$ref": "StringDelta" }, "startTime": { "description": "Describes a change in a DownloadItem's startTime.", "optional": true, "$ref": "StringDelta" }, "endTime": { "description": "Describes a change in a DownloadItem's endTime.", "optional": true, "$ref": "StringDelta" }, "state": { "description": "Describes a change in a DownloadItem's state.", "optional": true, "$ref": "StringDelta" }, "canResume": { "optional": true, "$ref": "BooleanDelta" }, "paused": { "description": "Describes a change in a DownloadItem's paused.", "optional": true, "$ref": "BooleanDelta" }, "error": { "description": "Describes a change in a DownloadItem's error.", "optional": true, "$ref": "StringDelta" }, "totalBytes": { "description": "Describes a change in a DownloadItem's totalBytes.", "optional": true, "$ref": "DoubleDelta" }, "fileSize": { "description": "Describes a change in a DownloadItem's fileSize.", "optional": true, "$ref": "DoubleDelta" }, "exists": { "optional": true, "$ref": "BooleanDelta" } } } ], "type": "function" } ] } ]