From 9dd1ea8927bf3b722484b6c141a4acae5ff378fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Mon, 24 Aug 2015 01:23:52 +0200 Subject: [PATCH] Added/Updated downloads, enterprise.platformKeys, events, extension, extensionTypes, fileBrowserHandler, fileSystemProvider /w docs --- chrome/chrome.d.ts | 3339 ++++++++++++++++++++++++++++---------------- 1 file changed, 2120 insertions(+), 1219 deletions(-) diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index b53a155394..7238443484 100755 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -1487,7 +1487,7 @@ declare module chrome.declarativeContent { /** Matches if the scheme of the URL is equal to any of the schemes specified in the array. */ schemes?: string[]; /** Matches if the port of the URL is contained in any of the specified port lists. For example [80, 443, [1000, 1200]] matches all requests on port 80, 443 and in the range 1000-1200. */ - port?: number[]; + port?: any[]; } /** Matches the state of a web page by various criteria. */ @@ -1845,7 +1845,7 @@ declare module chrome.devtools.panels { addListener(callback: (action: string, queryString?: string) => void): void; } - /** Represents a panel created by extension. */ + /** Represents a panel created by extension. */ interface ExtensionPanel { /** * Appends a button to the status bar of the panel. @@ -1870,7 +1870,7 @@ declare module chrome.devtools.panels { addListener(callback: () => void): void; } - /** A button created by the extension. */ + /** A button created by the extension. */ interface Button { /** * Updates the attributes of the button. If some of the arguments are omitted or null, the corresponding attributes are not updated. @@ -1909,7 +1909,7 @@ declare module chrome.devtools.panels { /** * Since Chrome 41. * Represents the Sources panel. - */ + */ interface SourcesPanel { /** * Creates a pane within panel's sidebar. @@ -1941,7 +1941,7 @@ declare module chrome.devtools.panels { addListener(callback: () => void): void; } - /** A sidebar created by the extension. */ + /** A sidebar created by the extension. */ interface ExtensionSidebarPane { /** * Sets the height of the sidebar. @@ -1993,7 +1993,7 @@ declare module chrome.devtools.panels { onHidden: ExtensionSidebarPaneHiddenEvent; } - /** Elements panel. */ + /** Elements panel. */ var elements: ElementsPanel; /** * Since Chrome 38. @@ -2010,7 +2010,7 @@ declare module chrome.devtools.panels { * If you specify the callback parameter, it should be a function that looks like this: * function( ExtensionPanel panel) {...}; * Parameter panel: An ExtensionPanel object representing the created panel. - */ + */ export function create(title: string, iconPath: string, pagePath: string, callback?: (panel: ExtensionPanel) => void): void; /** * Specifies the function to be called when the user clicks a resource link in the Developer Tools window. To unset the handler, either call the method with no parameters or pass null as the parameter. @@ -2048,7 +2048,7 @@ declare module chrome.documentScan { /** The number of scanned images allowed (defaults to 1). */ maxImages?: number; } - + interface DocumentScanCallbackArg { /** The data image URLs in a form that can be passed as the "src" value to an image tag. */ dataUrls: string[]; @@ -2069,371 +2069,1272 @@ declare module chrome.documentScan { //////////////////// // Dev Tools - Downloads //////////////////// +/** + * Use the chrome.downloads API to programmatically initiate, monitor, manipulate, and search for downloads. + * Availability: Since Chrome 31. + * Permissions: "downloads" + */ declare module chrome.downloads { interface HeaderNameValuePair { + /** Name of the HTTP header. */ name: string; + /** Value of the HTTP header. */ value: string; } interface DownloadOptions { + /** Post body. */ body?: string; + /** Use a file-chooser to allow the user to select a filename regardless of whether filename is set or already exists. */ saveAs?: boolean; + /** The URL to download. */ url: string; + /** A file path relative to the Downloads directory to contain the downloaded file, possibly containing subdirectories. Absolute paths, empty paths, and paths containing back-references ".." will cause an error. onDeterminingFilename allows suggesting a filename after the file's MIME type and a tentative filename have been determined. */ filename?: string; + /** 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. */ headers?: HeaderNameValuePair[]; + /** The HTTP method to use if the URL uses the HTTP[S] protocol. */ method?: string; + /** The action to take if filename already exists. */ + conflictAction?: string; } interface DownloadDelta { - danger?: DownloadStringDiff; - url?: DownloadStringDiff; - totalBytes?: DownloadStringDiff; - dangerAccepted?: DownloadBooleanDiff; - filename?: DownloadStringDiff; - paused?: DownloadBooleanDiff; - state?: DownloadStringDiff; - mime?: DownloadStringDiff; - fileSize?: DownloadLongDiff; - startTime?: DownloadLongDiff; - error?: DownloadLongDiff; - endTime?: DownloadLongDiff; + /** The change in danger, if any. */ + danger?: StringDelta; + /** The change in url, if any. */ + url?: StringDelta; + /** The change in totalBytes, if any. */ + totalBytes?: DoubleDelta; + /** The change in filename, if any. */ + filename?: StringDelta; + /** The change in paused, if any. */ + paused?: BooleanDelta; + /** The change in state, if any. */ + state?: StringDelta; + /** The change in mime, if any. */ + mime?: StringDelta; + /** The change in fileSize, if any. */ + fileSize?: DoubleDelta; + /** The change in startTime, if any. */ + startTime?: DoubleDelta; + /** The change in error, if any. */ + error?: StringDelta; + /** The change in endTime, if any. */ + endTime?: DoubleDelta; + /** The id of the DownloadItem that changed. */ id: number; + /** The change in canResume, if any. */ + canResume?: BooleanDelta; + /** The change in exists, if any. */ + exists?: BooleanDelta; } - interface DownloadBooleanDiff { + interface BooleanDelta { current?: boolean; previous?: boolean; } - interface DownloadLongDiff { + /** Since Chrome 34. */ + interface DoubleDelta { current?: number; previous?: number; } - interface DownloadStringDiff { + interface StringDelta { current?: string; previous?: string; } interface DownloadItem { + /** Number of bytes received so far from the host, without considering file compression. */ bytesReceived: number; + /** Indication of whether this download is thought to be safe or known to be suspicious. */ danger: string; + /** Absolute URL. */ url: string; + /** Number of bytes in the whole file, without considering file compression, or -1 if unknown. */ totalBytes: number; - dangerAccepted?: boolean; + /** Absolute local path. */ filename: string; + /** True if the download has stopped reading data from the host, but kept the connection open. */ paused: boolean; + /** Indicates whether the download is progressing, interrupted, or complete. */ state: string; + /** The file's MIME type. */ mime: string; + /** Number of bytes in the whole file post-decompression, or -1 if unknown. */ fileSize: number; - startTime: number; - error?: number; - endTime?: number; + /** The time when the download began in ISO 8601 format. May be passed directly to the Date constructor: chrome.downloads.search({}, function(items){items.forEach(function(item){console.log(new Date(item.startTime))})}) */ + startTime: string; + /** Why the download was interrupted. Several kinds of HTTP errors may be grouped under one of the errors beginning with SERVER_. Errors relating to the network begin with NETWORK_, errors relating to the process of writing the file to the file system begin with FILE_, and interruptions initiated by the user begin with USER_. */ + error?: string; + /** The time when the download ended in ISO 8601 format. May be passed directly to the Date constructor: chrome.downloads.search({}, function(items){items.forEach(function(item){if (item.endTime) console.log(new Date(item.endTime))})}) */ + endTime?: string; + /** An identifier that is persistent across browser sessions. */ id: number; + /** False if this download is recorded in the history, true if it is not recorded. */ incognito: boolean; + /** Absolute URL. */ + referrer: string; + /** Estimated time when the download will complete in ISO 8601 format. May be passed directly to the Date constructor: chrome.downloads.search({}, function(items){items.forEach(function(item){if (item.estimatedEndTime) console.log(new Date(item.estimatedEndTime))})}) */ + estimatedEndTime?: string; + /** True if the download is in progress and paused, or else if it is interrupted and can be resumed starting from where it was interrupted. */ + canResume: boolean; + /** Whether the downloaded file still exists. This information may be out of date because Chrome does not automatically watch for file removal. Call search() in order to trigger the check for file existence. When the existence check completes, if the file has been deleted, then an onChanged event will fire. Note that search() does not wait for the existence check to finish before returning, so results from search() may not accurately reflect the file system. Also, search() may be called as often as necessary, but will not check for file existence any more frequently than once every 10 seconds. */ + exists: boolean; + /** The identifier for the extension that initiated this download if this download was initiated by an extension. Does not change once it is set. */ + byExtensionId?: string; + /** The localized name of the extension that initiated this download if this download was initiated by an extension. May change if the extension changes its name or if the user changes their locale. */ + byExtensionName?: string; } interface GetFileIconOptions { + /** + * The size of the returned icon. The icon will be square with dimensions size * size pixels. The default and largest size for the icon is 32x32 pixels. The only supported sizes are 16 and 32. It is an error to specify any other size. + */ size?: number; } interface DownloadQuery { - orderBy?: string; + /** Set elements of this array to DownloadItem properties in order to sort search results. For example, setting orderBy=['startTime'] sorts the DownloadItem by their start time in ascending order. To specify descending order, prefix with a hyphen: '-startTime'. */ + orderBy?: string[]; + /** Limits results to DownloadItem whose url matches the given regular expression. */ urlRegex?: string; + /** Limits results to DownloadItem that ended before the given ms since the epoch. */ endedBefore?: number; + /** Limits results to DownloadItem whose totalBytes is greater than the given integer. */ totalBytesGreater?: number; + /** Indication of whether this download is thought to be safe or known to be suspicious. */ danger?: string; + /** Number of bytes in the whole file, without considering file compression, or -1 if unknown. */ totalBytes?: number; + /** True if the download has stopped reading data from the host, but kept the connection open. */ paused?: boolean; + /** Limits results to DownloadItem whose filename matches the given regular expression. */ filenameRegex?: string; - query?: string; + /** This array of search terms limits results to DownloadItem 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. */ + query?: string[]; + /** Limits results to DownloadItem whose totalBytes is less than the given integer. */ totalBytesLess?: number; + /** The id of the DownloadItem to query. */ id?: number; + /** Number of bytes received so far from the host, without considering file compression. */ bytesReceived?: number; + /** Limits results to DownloadItem that ended after the given ms since the epoch. */ endedAfter?: number; + /** Absolute local path. */ filename?: string; + /** Indicates whether the download is progressing, interrupted, or complete. */ state?: string; + /** Limits results to DownloadItem that started after the given ms since the epoch. */ startedAfter?: number; - dangerAccepted?: boolean; + /** The file's MIME type. */ mime?: string; + /** Number of bytes in the whole file post-decompression, or -1 if unknown. */ fileSize?: number; + /** The time when the download began in ISO 8601 format. */ startTime?: number; + /** Absolute URL. */ url?: string; + /** Limits results to DownloadItem that started before the given ms since the epoch. */ startedBefore?: number; + /** The maximum number of matching DownloadItem returned. Defaults to 1000. Set to 0 in order to return all matching DownloadItem. See search for how to page through results. */ limit?: number; + /** Why a download was interrupted. */ error?: number; + /** The time when the download ended in ISO 8601 format. */ endTime?: number; + /** Whether the downloaded file exists; */ + exists?: boolean; } + interface DownloadFilenameSuggestion { + /** The DownloadItem's new target DownloadItem.filename, as a path relative to the user's default Downloads directory, possibly containing subdirectories. Absolute paths, empty paths, and paths containing back-references ".." will be ignored. */ + filename: string; + /** The action to take if filename already exists. */ + conflictAction?: string; + } + interface DownloadChangedEvent extends chrome.events.Event { + /** + * When any of a DownloadItem's properties except bytesReceived and estimatedEndTime changes, this event fires with the downloadId and an object containing the properties that changed. + * @param callback The callback parameter should be a function that looks like this: + * function(object downloadDelta) {...}; + */ addListener(callback: (downloadDelta: DownloadDelta) => void): void; } interface DownloadCreatedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function( DownloadItem downloadItem) {...}; + */ addListener(callback: (downloadItem: DownloadItem) => void): void; } interface DownloadErasedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(integer downloadId) {...}; + * Parameter downloadId: The id of the DownloadItem that was erased. + */ addListener(callback: (downloadId: number) => void): void; } + interface DownloadDeterminingFilenameEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function( DownloadItem downloadItem, function suggest) {...}; + */ + addListener(callback: (downloadItem: DownloadItem, suggest: (suggestion?: DownloadFilenameSuggestion) => void) => void): void; + } + + /** + * Find DownloadItem. Set query to the empty object to get all DownloadItem. To get a specific DownloadItem, set only the id field. To page through a large number of items, set orderBy: ['-startTime'], set limit to the number of items per page, and set startedAfter to the startTime of the last item from the last page. + * @param callback The callback parameter should be a function that looks like this: + * function(array of DownloadItem results) {...}; + */ export function search(query: DownloadQuery, callback: (results: DownloadItem[]) => void): void; - export function pause(downloadId: number, callback?: Function): void; + /** + * Pause the download. If the request was successful the download is in a paused state. Otherwise runtime.lastError contains an error message. The request will fail if the download is not active. + * @param downloadId The id of the download to pause. + * @param callback Called when the pause request is completed. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function pause(downloadId: number, callback?: () => void): void; + /** + * 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, runtime.lastError will contain an error message. + * @param downloadId The identifier for the download. + * @param callback A URL to an image that represents the download. + * The callback parameter should be a function that looks like this: + * function(string iconURL) {...}; + */ export function getFileIcon(downloadId: number, callback: (iconURL: string) => void): void; + /** + * 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, runtime.lastError will contain an error message. + * @param downloadId The identifier for the download. + * @param callback A URL to an image that represents the download. + * The callback parameter should be a function that looks like this: + * function(string iconURL) {...}; + */ export function getFileIcon(downloadId: number, options: GetFileIconOptions, callback: (iconURL: string) => void): void; - export function resume(downloadId: number, callback?: Function): void; - export function cancel(downloadId: number, callback?: Function): void; + /** + * Resume a paused download. If the request was successful the download is in progress and unpaused. Otherwise runtime.lastError contains an error message. The request will fail if the download is not active. + * @param downloadId The id of the download to resume. + * @param callback Called when the resume request is completed. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function resume(downloadId: number, callback?: () => void): void; + /** + * Cancel a download. When callback is run, the download is cancelled, completed, interrupted or doesn't exist anymore. + * @param downloadId The id of the download to cancel. + * @param callback Called when the cancel request is completed. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function cancel(downloadId: number, callback?: () => void): void; + /** + * 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 runtime.lastError will contain a descriptive string. The error strings are not guaranteed to remain backwards compatible between releases. Extensions must not parse it. + * @param options What to download and how. + * @param callback Called with the id of the new DownloadItem. + * If you specify the callback parameter, it should be a function that looks like this: + * function(integer downloadId) {...}; + */ export function download(options: DownloadOptions, callback?: (downloadId: number) => void): void; + /** + * Open the downloaded file now if the DownloadItem is complete; otherwise returns an error through runtime.lastError. Requires the "downloads.open" permission in addition to the "downloads" permission. An onChanged event will fire when the item is opened for the first time. + * @param downloadId The identifier for the downloaded file. + */ export function open(downloadId: number): void; + /** + * Show the downloaded file in its folder in a file manager. + * @param downloadId The identifier for the downloaded file. + */ export function show(downloadId: number): void; + /** Show the default Downloads folder in a file manager. */ export function showDefaultFolder(): void; - export function erase(query: DownloadQuery, callback: (results: DownloadItem[]) => void): void; - export function removeFile(downloadId: number, callback: () => void): void; + /** + * Erase matching DownloadItem from history without deleting the downloaded file. An onErased event will fire for each DownloadItem that matches query, then callback will be called. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(array of integer erasedIds) {...}; + */ + export function erase(query: DownloadQuery, callback: (erasedIds: number[]) => void): void; + /** + * Remove the downloaded file if it exists and the DownloadItem is complete; otherwise return an error through runtime.lastError. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function removeFile(downloadId: number, callback?: () => void): void; + /** + * Prompt the user to accept a dangerous download. Can only be called from a visible context (tab, window, or page/browser action popup). Does not automatically accept dangerous downloads. If the download is accepted, then an onChanged event will fire, otherwise nothing will happen. When all the data is fetched into a temporary file and either the download is not dangerous or the danger has been accepted, then the temporary file is renamed to the target filename, the |state| changes to 'complete', and onChanged fires. + * @param downloadId The identifier for the DownloadItem. + * @param callback Called when the danger prompt dialog closes. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function acceptDanger(downloadId: number, callback: () => void): void; + /** Initiate dragging the downloaded file to another application. Call in a javascript ondragstart handler. */ export function drag(downloadId: number): void; + /** Enable or disable the gray shelf at the bottom of every window associated with the current browser profile. The shelf will be disabled as long as at least one extension has disabled it. Enabling the shelf while at least one other extension has disabled it will return an error through runtime.lastError. Requires the "downloads.shelf" permission in addition to the "downloads" permission. */ export function setShelfEnabled(enabled: boolean): void; + /** When any of a DownloadItem's properties except bytesReceived and estimatedEndTime changes, this event fires with the downloadId and an object containing the properties that changed. */ var onChanged: DownloadChangedEvent; + /** This event fires with the DownloadItem object when a download begins. */ var onCreated: DownloadCreatedEvent; + /** Fires with the downloadId when a download is erased from history. */ var onErased: DownloadErasedEvent; + /** During the filename determination process, extensions will be given the opportunity to override the target DownloadItem.filename. Each extension may not register more than one listener for this event. Each listener must call suggest exactly once, either synchronously or asynchronously. If the listener calls suggest asynchronously, then it must return true. If the listener neither calls suggest synchronously nor returns true, then suggest will be called automatically. The DownloadItem will not complete until all listeners have called suggest. Listeners may call suggest without any arguments in order to allow the download to use downloadItem.filename for its filename, or pass a suggestion object to suggest in order to override the target filename. If more than one extension overrides the filename, then the last extension installed whose listener passes a suggestion object to suggest wins. In order to avoid confusion regarding which extension will win, users should not install extensions that may conflict. If the download is initiated by download and the target filename is known before the MIME type and tentative filename have been determined, pass filename to download instead. */ + var onDeterminingFilename: DownloadDeterminingFilenameEvent; +} + +//////////////////// +// Enterprise Platform Keys +//////////////////// +/** + * Use the chrome.enterprise.platformKeys API to generate hardware-backed keys and to install certificates for these keys. The certificates will be managed by the platform and can be used for TLS authentication, network access or by other extension through chrome.platformKeys. + * Availability: Since Chrome 37. + * Permissions: "enterprise.platformKeys" + * Important: This API works only on Chrome OS. + * Note: This API is only for extensions pre-installed by policy. + */ +declare module chrome.enterprise.platformKeys { + interface Token { + /** + * Uniquely identifies this Token. + * Static IDs are "user" and "system", referring to the platform's user-specific and the system-wide hardware token, respectively. Any other tokens (with other identifiers) might be returned by enterprise.platformKeys.getTokens. + */ + id: string; + /** + * Implements the WebCrypto's SubtleCrypto interface. The cryptographic operations, including key generation, are hardware-backed. + * Only non-extractable RSASSA-PKCS1-V1_5 keys with modulusLength up to 2048 can be generated. Each key can be used for signing data at most once. + * Keys generated on a specific Token cannot be used with any other Tokens, nor can they be used with window.crypto.subtle. Equally, Key objects created with window.crypto.subtle cannot be used with this interface. + */ + subtleCrypto: SubtleCrypto; + } + + /** + * Returns the available Tokens. In a regular user's session the list will always contain the user's token with id "user". If a system-wide TPM token is available, the returned list will also contain the system-wide token with id "system". The system-wide token will be the same for all sessions on this device (device in the sense of e.g. a Chromebook). + * @param callback Invoked by getTokens with the list of available Tokens. + * The callback parameter should be a function that looks like this: + * function(array of Token tokens) {...}; + * Parameter tokens: The list of available tokens. + */ + export function getToken(callback: (tokens: Token[]) => void): void; + /** + * Returns the list of all client certificates available from the given token. Can be used to check for the existence and expiration of client certificates that are usable for a certain authentication. + * @param tokenId The id of a Token returned by getTokens. + * @param callback Called back with the list of the available certificates. + * The callback parameter should be a function that looks like this: + * function(array of ArrayBuffer certificates) {...}; + * Parameter certificates: The list of certificates, each in DER encoding of a X.509 certificate. + */ + export function getCertificates(tokenId: string, callback: (certificates: ArrayBuffer) => void): void; + /** + * Imports certificate to the given token if the certified key is already stored in this token. After a successful certification request, this function should be used to store the obtained certificate and to make it available to the operating system and browser for authentication. + * @param tokenId The id of a Token returned by getTokens. + * @param certificate The DER encoding of a X.509 certificate. + * @param callback Called back when this operation is finished. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function importCertificate(tokenId: string, certificate: ArrayBuffer, callback?: () => void): void; + /** + * Removes certificate from the given token if present. Should be used to remove obsolete certificates so that they are not considered during authentication and do not clutter the certificate choice. Should be used to free storage in the certificate store. + * @param tokenId The id of a Token returned by getTokens. + * @param certificate The DER encoding of a X.509 certificate. + * @param callback Called back when this operation is finished. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function removeCertificate(tokenId: string, certificate: ArrayBuffer, callback?: () => void): void; } //////////////////// // Events //////////////////// +/** + * The chrome.events namespace contains common types used by APIs dispatching events to notify you when something interesting happens. + * Availability: Since Chrome 21. + */ declare module chrome.events { + /** Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */ interface UrlFilter { + /** Matches if the scheme of the URL is equal to any of the schemes specified in the array. */ schemes?: string[]; + /** + * Since Chrome 23. + * Matches if the URL (without fragment identifier) matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. + */ urlMatches?: string; + /** Matches if the path segment of the URL contains a specified string. */ pathContains?: string; + /** Matches if the host name of the URL ends with a specified string. */ hostSuffix?: string; + /** Matches if the host name of the URL starts with a specified string. */ hostPrefix?: string; + /** Matches if the host name of the URL contains a specified string. To test whether a host name component has a prefix 'foo', use hostContains: '.foo'. This matches 'www.foobar.com' and 'foo.com', because an implicit dot is added at the beginning of the host name. Similarly, hostContains can be used to match against component suffix ('foo.') and to exactly match against components ('.foo.'). Suffix- and exact-matching for the last components need to be done separately using hostSuffix, because no implicit dot is added at the end of the host name. */ hostContains?: string; + /** Matches if the URL (without fragment identifier) contains a specified string. Port numbers are stripped from the URL if they match the default port number. */ urlContains?: string; + /** Matches if the query segment of the URL ends with a specified string. */ querySuffix?: string; + /** Matches if the URL (without fragment identifier) starts with a specified string. Port numbers are stripped from the URL if they match the default port number. */ urlPrefix?: string; + /** Matches if the host name of the URL is equal to a specified string. */ hostEquals?: string; + /** Matches if the URL (without fragment identifier) is equal to a specified string. Port numbers are stripped from the URL if they match the default port number. */ urlEquals?: string; + /** Matches if the query segment of the URL contains a specified string. */ queryContains?: string; + /** Matches if the path segment of the URL starts with a specified string. */ pathPrefix?: string; + /** Matches if the path segment of the URL is equal to a specified string. */ pathEquals?: string; + /** Matches if the path segment of the URL ends with a specified string. */ pathSuffix?: string; + /** Matches if the query segment of the URL is equal to a specified string. */ queryEquals?: string; + /** Matches if the query segment of the URL starts with a specified string. */ queryPrefix?: string; + /** Matches if the URL (without fragment identifier) ends with a specified string. Port numbers are stripped from the URL if they match the default port number. */ urlSuffix?: string; + /** Matches if the port of the URL is contained in any of the specified port lists. For example [80, 443, [1000, 1200]] matches all requests on port 80, 443 and in the range 1000-1200. */ ports?: any[]; + /** + * Since Chrome 28. + * Matches if the URL without query segment and fragment identifier matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. + */ + originAndPathMatches?: string; } + /** An object which allows the addition and removal of listeners for a Chrome event. */ interface Event { + /** + * Registers an event listener callback to an event. + * @param callback Called when an event occurs. The parameters of this function depend on the type of event. + * The callback parameter should be a function that looks like this: + * function() {...}; + */ addListener(callback: Function): void; + /** + * Returns currently registered rules. + * @param callback Called with registered rules. + * The callback parameter should be a function that looks like this: + * function(array of Rule rules) {...}; + * Parameter rules: Rules that were registered, the optional parameters are filled with values. + */ getRules(callback: (rules: Rule[]) => void): void; + /** + * Returns currently registered rules. + * @param ruleIdentifiers If an array is passed, only rules with identifiers contained in this array are returned. + * @param callback Called with registered rules. + * The callback parameter should be a function that looks like this: + * function(array of Rule rules) {...}; + * Parameter rules: Rules that were registered, the optional parameters are filled with values. + */ getRules(ruleIdentifiers: string[], callback: (rules: Rule[]) => void): void; + /** + * @param callback Listener whose registration status shall be tested. + */ hasListener(callback: Function): boolean; - removeRules(ruleIdentifiers?: string[], callback?: Function): void; + /** + * Unregisters currently registered rules. + * @param ruleIdentifiers If an array is passed, only rules with identifiers contained in this array are unregistered. + * @param callback Called when rules were unregistered. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + removeRules(ruleIdentifiers?: string[], callback?: () => void): void; + /** + * Unregisters currently registered rules. + * @param callback Called when rules were unregistered. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + removeRules(callback?: () => void): void; + /** + * Registers rules to handle events. + * @param rules Rules to be registered. These do not replace previously registered rules. + * @param callback Called with registered rules. + * If you specify the callback parameter, it should be a function that looks like this: + * function(array of Rule rules) {...}; + * Parameter rules: Rules that were registered, the optional parameters are filled with values. + */ addRules(rules: Rule[], callback?: (rules: Rule[]) => void): void; - removeListener(callback: Function): void; - hasListeners(): boolean; + /** + * Deregisters an event listener callback from an event. + * @param callback Listener that shall be unregistered. + * The callback parameter should be a function that looks like this: + * function() {...}; + */ + removeListener(callback: () => void): void; + hasListeners(): boolean; } + /** Description of a declarative rule for handling events. */ interface Rule { + /** Optional priority of this rule. Defaults to 100. */ priority?: number; + /** List of conditions that can trigger the actions. */ conditions: any[]; + /** Optional identifier that allows referencing this rule. */ id?: string; + /** List of actions that are triggered if one of the condtions is fulfilled. */ actions: any[]; + /** + * Since Chrome 28. + * Tags can be used to annotate rules and perform operations on sets of rules. + */ + tags?: string[]; } } //////////////////// // Extension //////////////////// +/** + * The chrome.extension API has utilities that can be used by any extension page. It includes support for exchanging messages between an extension and its content scripts or between extensions, as described in detail in Message Passing. + * Availability: Since Chrome 5. + */ declare module chrome.extension { interface FetchProperties { + /** The window to restrict the search to. If omitted, returns all views. */ windowId?: number; + /** The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: 'tab', 'notification', 'popup'. */ type?: string; } interface LastError { - message?: string; + /** Description of the error that has taken place. */ + message: string; } + interface OnRequestEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(any request, runtime.MessageSender sender, function sendResponse) {...}; + * Parameter request: The request sent by the calling script. + * Parameter sendResponse: Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response. If you have more than one onRequest listener in the same document, then only one may send a response. + */ + addListener(callback: (request: any, sender: runtime.MessageSender, sendResponse: () => void) => void): void; + /** + * @param callback The callback parameter should be a function that looks like this: + * function(runtime.MessageSender sender, function sendResponse) {...}; + * Parameter sendResponse: Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response. If you have more than one onRequest listener in the same document, then only one may send a response. + */ + addListener(callback: (sender: runtime.MessageSender, sendResponse: () => void) => void): void; + } + + /** + * Since Chrome 7. + * True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. The latter only applies to extensions with 'split' incognito_behavior. + */ var inIncognitoContext: boolean; + /** Set for the lifetime of a callback if an ansychronous extension api has resulted in an error. If no error has occured lastError will be undefined. */ var lastError: LastError; + /** Returns the JavaScript 'window' object for the background page running inside the current extension. Returns null if the extension has no background page. */ export function getBackgroundPage(): Window; + /** + * Converts a relative path within an extension install directory to a fully-qualified URL. + * @param path A path to a resource within an extension expressed relative to its install directory. + */ export function getURL(path: string): string; + /** + * Sets the value of the ap CGI parameter used in the extension's update URL. This value is ignored for extensions that are hosted in the Chrome Extension Gallery. + * Since Chrome 9. + */ export function setUpdateUrlData(data: string): void; + /** Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension. */ export function getViews(fetchProperties?: FetchProperties): Window[]; + /** + * Retrieves the state of the extension's access to the 'file://' scheme (as determined by the user-controlled 'Allow access to File URLs' checkbox. + * Since Chrome 12. + * @param callback The callback parameter should be a function that looks like this: + * function(boolean isAllowedAccess) {...}; + * Parameter isAllowedAccess: True if the extension can access the 'file://' scheme, false otherwise. + */ export function isAllowedFileSchemeAccess(callback: (isAllowedAccess: boolean) => void): void; + /** + * Retrieves the state of the extension's access to Incognito-mode (as determined by the user-controlled 'Allowed in Incognito' checkbox. + * Since Chrome 12. + * @param callback The callback parameter should be a function that looks like this: + * function(boolean isAllowedAccess) {...}; + * Parameter isAllowedAccess: True if the extension has access to Incognito mode, false otherwise. + */ export function isAllowedIncognitoAccess(callback: (isAllowedAccess: boolean) => void): void; + /** + * Sends a single request to other listeners within the extension. Similar to runtime.connect, but only sends a single request with an optional response. The extension.onRequest event is fired in each page of the extension. + * @deprecated Deprecated since Chrome 33. Please use runtime.sendMessage. + * @param extensionId The extension ID of the extension you want to connect to. If omitted, default is your own extension. + * @param responseCallback If you specify the responseCallback parameter, it should be a function that looks like this: + * function(any response) {...}; + * Parameter response: The JSON response object sent by the handler of the request. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message. + */ + export function sendRequest(extensionId: string, request: any, responseCallback?: (response: any) => void): void; + /** + * Sends a single request to other listeners within the extension. Similar to runtime.connect, but only sends a single request with an optional response. The extension.onRequest event is fired in each page of the extension. + * @deprecated Deprecated since Chrome 33. Please use runtime.sendMessage. + * @param responseCallback If you specify the responseCallback parameter, it should be a function that looks like this: + * function(any response) {...}; + * Parameter response: The JSON response object sent by the handler of the request. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message. + */ + export function sendRequest(request: any, responseCallback?: (response: any) => void): void; + /** + * Returns an array of the JavaScript 'window' objects for each of the tabs running inside the current extension. If windowId is specified, returns only the 'window' objects of tabs attached to the specified window. + * @deprecated Deprecated since Chrome 33. Please use extension.getViews {type: "tab"}. + */ + export function getExtensionTabs(windowId?: number): Window[]; + + /** + * Fired when a request is sent from either an extension process or a content script. + * @deprecated Deprecated since Chrome 33. Please use runtime.onMessage. + */ + var onRequest: OnRequestEvent; + /** + * Fired when a request is sent from another extension. + * @deprecated Deprecated since Chrome 33. Please use runtime.onMessageExternal. + */ + var onRequestExternal: OnRequestEvent; } //////////////////// // File Browser Handler //////////////////// +/** + * Use the chrome.fileBrowserHandler API to extend the Chrome OS file browser. For example, you can use this API to enable users to upload files to your website. + * Availability: Since Chrome 12. + * Permissions: "fileBrowserHandler" + * Important: This API works only on Chrome OS. + */ declare module chrome.fileBrowserHandler { interface SelectionParams { + /** + * List of file extensions that the selected file can have. The list is also used to specify what files to be shown in the select file dialog. Files with the listed extensions are only shown in the dialog. Extensions should not include the leading '.'. Example: ['jpg', 'png'] + * Since Chrome 23. + */ allowedFileExtensions?: string[]; + /** Suggested name for the file. */ suggestedName: string; } interface SelectionResult { + /** Selected file entry. It will be null if a file hasn't been selected. */ entry?: Object; + /** Whether the file has been selected. */ success: boolean; } + /** Event details payload for fileBrowserHandler.onExecute event. */ interface FileHandlerExecuteEventDetails { + /** The ID of the tab that raised this event. Tab IDs are unique within a browser session. */ tab_id?: number; + /** Array of Entry instances representing files that are targets of this action (selected in ChromeOS file browser). */ entries: any[]; - selectFile(selectionParams: SelectionParams, callback: (result: SelectionResult) => void): void; } interface FileBrowserHandlerExecuteEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(string id, FileHandlerExecuteEventDetails details) {...}; + * Parameter id: File browser action id as specified in the listener component's manifest. + * Parameter details: File handler execute event details. + */ addListener(callback: (id: string, details: FileHandlerExecuteEventDetails) => void): void; } + /** + * Prompts user to select file path under which file should be saved. When the file is selected, file access permission required to use the file (read, write and create) are granted to the caller. The file will not actually get created during the function call, so function caller must ensure its existence before using it. The function has to be invoked with a user gesture. + * Since Chrome 21. + * @param selectionParams Parameters that will be used while selecting the file. + * @param callback Function called upon completion. + * The callback parameter should be a function that looks like this: + * function(object result) {...}; + * Parameter result: Result of the method. + */ + export function selectFile(selectionParams: SelectionParams, callback: (result: SelectionResult) => void): void; + + /** Fired when file system action is executed from ChromeOS file browser. */ var onExecute: FileBrowserHandlerExecuteEvent; } +//////////////////// +// File System Provider +//////////////////// +/** + * Use the chrome.fileSystemProvider API to create file systems, that can be accessible from the file manager on Chrome OS. + * Availability: Since Chrome 40. + * Permissions: "fileSystemProvider" + * Important: This API works only on Chrome OS. + */ +declare module chrome.fileSystemProvider { + interface OpenedFileInfo { + /** A request ID to be be used by consecutive read/write and close requests. */ + openRequestId: number; + /** The path of the opened file. */ + filePath: string; + /** Whether the file was opened for reading or writing. */ + mode: string; + } + + interface FileWatchersInfo { + /** The path of the entry being observed. */ + entryPath: string; + /** Whether watching should include all child entries recursively. It can be true for directories only. */ + recursive: boolean; + /** Tag used by the last notification for the watcher. */ + lastTag?: string; + } + + interface EntryMetadata { + /** True if it is a directory. */ + isDirectory: boolean; + /** Name of this entry (not full path name). Must not contain '/'. For root it must be empty. */ + name: string; + /** File size in bytes. */ + size: number; + /** The last modified time of this entry. */ + modificationTime: Date; + /** Mime type for the entry. */ + mimeType?: string; + /** Thumbnail image as a data URI in either PNG, JPEG or WEBP format, at most 32 KB in size. Optional, but can be provided only when explicitly requested by the onGetMetadataRequested event. */ + thumbnail?: string; + } + + interface FileSystemInfo { + /** The identifier of the file system. */ + fileSystemId: string; + /** A human-readable name for the file system. */ + displayName: string; + /** Whether the file system supports operations which may change contents of the file system (such as creating, deleting or writing to files). */ + writable: boolean; + /** + * The maximum number of files that can be opened at once. If 0, then not limited. + * @since Since Chrome 42. + */ + openedFilesLimit: number; + /** + * List of currently opened files. + * @since Since Chrome 42. + */ + openedFiles: OpenedFileInfo[]; + /** + * Whether the file system supports the tag field for observing directories. + * @since Since Chrome 45. Warning: this is the current Beta channel. + */ + supportsNotifyTag?: boolean; + /** + * List of watchers. + * @since Since Chrome 45. Warning: this is the current Beta channel. + */ + watchers: FileWatchersInfo[]; + } + + /** @since Since Chrome 45. Warning: this is the current Beta channel. */ + interface GetActionsRequestedOptions { + /** The identifier of the file system related to this operation. */ + fileSystemId: string; + /** The unique identifier of this request. */ + requestId: number; + /** The path of the entry to return the list of actions for. */ + entryPath: string; + } + + /** @since Since Chrome 45. Warning: this is the current Beta channel. */ + interface Action { + /** The identifier of the action. Any string or CommonActionId for common actions. */ + id: string; + /** The title of the action. It may be ignored for common actions. */ + title?: string; + } + + /** @since Since Chrome 45. Warning: this is the current Beta channel. */ + interface ExecuteActionRequestedOptions { + /** The identifier of the file system related to this operation. */ + fileSystemId: string; + /** The unique identifier of this request. */ + requestId: number; + /** The path of the entry to be used for the action. */ + entryPath: string; + /** The identifier of the action to be executed. */ + actionId: string; + } + + interface MountOptions { + /** The string indentifier of the file system. Must be unique per each extension. */ + fileSystemId: string; + /** A human-readable name for the file system. */ + displayName: string; + /** Whether the file system supports operations which may change contents of the file system (such as creating, deleting or writing to files). */ + writable?: boolean; + /** + * The maximum number of files that can be opened at once. If not specified, or 0, then not limited. + * @since Since Chrome 41. + */ + openedFilesLimit?: number; + /** + * Whether the file system supports the tag field for observed directories. + * @since Since Chrome 45. Warning: this is the current Beta channel. + */ + supportsNotifyTag?: boolean; + } + + interface UnmountOptions { + /** The identifier of the file system to be unmounted. */ + fileSystemId: string; + } + + interface NotificationChange { + /** The path of the changed entry. */ + entryPath: string; + /** The type of the change which happened to the entry. */ + changeType: string; + } + + interface NotificationOptions { + /** The identifier of the file system related to this change. */ + fileSystemId: string; + /** The path of the observed entry. */ + observedPath: string; + /** Mode of the observed entry. */ + recursive: boolean; + /** The type of the change which happened to the observed entry. If it is DELETED, then the observed entry will be automatically removed from the list of observed entries. */ + changeType: string; + /** List of changes to entries within the observed directory (including the entry itself) */ + changes?: NotificationChange[]; + /** Tag for the notification. Required if the file system was mounted with the supportsNotifyTag option. Note, that this flag is necessary to provide notifications about changes which changed even when the system was shutdown. */ + tag?: string; + } + + interface RequestedEventOptions { + /** The identifier of the file system related to this operation. */ + fileSystemId: string; + /** The unique identifier of this request. */ + requestId: number; + } + + interface EntryPathRequestedEventOptions extends RequestedEventOptions { + /** The path of the entry to which this operation is related to. */ + entryPath: string; + } + + interface MetadataRequestedEventOptions extends EntryPathRequestedEventOptions { + /** Set to true if the thumbnail is requested. */ + thumbnail: boolean; + } + + interface DirectoryPathRequestedEventOptions extends RequestedEventOptions { + /** The path of the directory which is to be operated on. */ + directoryPath: string; + } + + interface FilePathRequestedEventOptions extends RequestedEventOptions { + /** The path of the entry for the operation */ + filePath: string; + } + + interface OpenFileRequestedEventOptions extends FilePathRequestedEventOptions { + /** Whether the file will be used for reading or writing. */ + mode: string; + } + + interface OpenedFileRequestedEventOptions extends RequestedEventOptions { + /** A request ID used to open the file. */ + openRequestId: number; + } + + interface OpenedFileOffsetRequestedEventOptions extends OpenedFileRequestedEventOptions { + /** Position in the file (in bytes) to start reading from. */ + offset: number; + /** Number of bytes to be returned. */ + length: number; + } + + interface DirectoryPathRecursiveRequestedEventOptions extends DirectoryPathRequestedEventOptions { + /** Whether the operation is recursive (for directories only). */ + recursive: boolean; + } + + interface EntryPathRecursiveRequestedEventOptions extends EntryPathRequestedEventOptions { + /** Whether the operation is recursive (for directories only). */ + recursive: boolean; + } + + interface SourceTargetPathRequestedEventOptions extends RequestedEventOptions { + /** The source path for the operation. */ + sourcePath: string; + /** The destination path for the operation. */ + targetPath: string; + } + + interface FilePathLengthRequestedEventOptions extends FilePathRequestedEventOptions { + /** Number of bytes to be retained after the operation completes. */ + length: number; + } + + interface OpenedFileIoRequestedEventOptions extends OpenedFileRequestedEventOptions { + /** Position in the file (in bytes) to start operating from. */ + offset: number; + /** Buffer of bytes to be operated on the file. */ + data: ArrayBuffer; + } + + interface OperationRequestedEventOptions extends RequestedEventOptions { + /** An ID of the request to which this operation is related. */ + operationRequestId: number; + } + + interface RequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: RequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void): void; + } + + interface MetadataRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: MetadataRequestedEventOptions, successCallback: (metadata: EntryMetadata) => void, errorCallback: (error: string) => void) => void): void; + } + + interface DirectoryPathRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: DirectoryPathRequestedEventOptions, successCallback: (entries: EntryMetadata[], hasMore: boolean) => void, errorCallback: (error: string) => void) => void): void; + } + + interface OpenFileRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: OpenFileRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void): void; + } + + interface OpenedFileRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: OpenedFileRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void): void; + } + + interface OpenedFileOffsetRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: OpenedFileOffsetRequestedEventOptions, successCallback: (data: ArrayBuffer, hasMore: boolean) => void, errorCallback: (error: string) => void) => void): void; + } + + interface DirectoryPathRecursiveRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: DirectoryPathRecursiveRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void): void; + } + + interface EntryPathRecursiveRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: EntryPathRecursiveRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void): void; + } + + interface FilePathRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: FilePathRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void): void; + } + + interface SourceTargetPathRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: SourceTargetPathRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void): void; + } + + interface FilePathLengthRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: FilePathLengthRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void): void; + } + + interface OpenedFileIoRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: OpenedFileIoRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void): void; + } + + interface OperationRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(object options, function successCallback, function errorCallback) {...}; + */ + addListener(callback: (options: OperationRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void): void; + } + + interface OptionlessRequestedEvent extends chrome.events.Event { + /** + * @param callback The callback parameter should be a function that looks like this: + * function(function successCallback, function errorCallback) {...}; + */ + addListener(callback: (successCallback: Function, errorCallback: (error: string) => void) => void): void; + } + + /** + * Mounts a file system with the given fileSystemId and displayName. displayName will be shown in the left panel of Files.app. displayName can contain any characters including '/', but cannot be an empty string. displayName must be descriptive but doesn't have to be unique. The fileSystemId must not be an empty string. + * Depending on the type of the file system being mounted, the source option must be set appropriately. + * In case of an error, runtime.lastError will be set with a corresponding error code. + * @param callback A generic result callback to indicate success or failure. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function mount(options: MountOptions, callback?: () => void): void; + /** + * Unmounts a file system with the given fileSystemId. It must be called after onUnmountRequested is invoked. Also, the providing extension can decide to perform unmounting if not requested (eg. in case of lost connection, or a file error). + * In case of an error, runtime.lastError will be set with a corresponding error code. + * @param callback A generic result callback to indicate success or failure. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function unmount(options: UnmountOptions, callback?: () => void): void; + /** + * Returns all file systems mounted by the extension. + * @param callback Callback to receive the result of getAll function. + * The callback parameter should be a function that looks like this: + * function(array of FileSystemInfo fileSystems) {...}; + */ + export function getAll(callback: (fileSystems: FileSystemInfo[]) => void): void; + /** + * Returns information about a file system with the passed fileSystemId. + * @since Since Chrome 42. + * @param callback Callback to receive the result of get function. + * The callback parameter should be a function that looks like this: + * function(FileSystemInfo fileSystem) {...}; + */ + export function get(fileSystemId: string, callback: (fileSystem: FileSystemInfo) => void): void; + /** + * Notifies about changes in the watched directory at observedPath in recursive mode. If the file system is mounted with supportsNofityTag, then tag must be provided, and all changes since the last notification always reported, even if the system was shutdown. The last tag can be obtained with getAll. + * To use, the file_system_provider.notify manifest option must be set to true. + * Value of tag can be any string which is unique per call, so it's possible to identify the last registered notification. Eg. if the providing extension starts after a reboot, and the last registered notification's tag is equal to "123", then it should call notify for all changes which happened since the change tagged as "123". It cannot be an empty string. + * Not all providers are able to provide a tag, but if the file system has a changelog, then the tag can be eg. a change number, or a revision number. + * Note that if a parent directory is removed, then all descendant entries are also removed, and if they are watched, then the API must be notified about the fact. Also, if a directory is renamed, then all descendant entries are in fact removed, as there is no entry under their original paths anymore. + * In case of an error, runtime.lastError will be set will a corresponding error code. + * @param callback A generic result callback to indicate success or failure. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function notify(options: NotificationOptions, callback: () => void): void; + + /** Raised when unmounting for the file system with the fileSystemId identifier is requested. In the response, the unmount API method must be called together with successCallback. If unmounting is not possible (eg. due to a pending operation), then errorCallback must be called. */ + var onUnmountRequested: RequestedEvent; + /** Raised when metadata of a file or a directory at entryPath is requested. The metadata must be returned with the successCallback call. In case of an error, errorCallback must be called. */ + var onGetMetadataRequested: MetadataRequestedEvent; + /** Raised when contents of a directory at directoryPath are requested. The results must be returned in chunks by calling the successCallback several times. In case of an error, errorCallback must be called. */ + var onReadDirectoryRequested: DirectoryPathRequestedEvent; + /** Raised when opening a file at filePath is requested. If the file does not exist, then the operation must fail. Maximum number of files opened at once can be specified with MountOptions. */ + var onOpenFileRequested: OpenFileRequestedEvent; + /** Raised when opening a file previously opened with openRequestId is requested to be closed. */ + var onCloseFileRequested: OpenedFileRequestedEvent; + /** Raised when reading contents of a file opened previously with openRequestId is requested. The results must be returned in chunks by calling successCallback several times. In case of an error, errorCallback must be called. */ + var onReadFileRequested: OpenedFileOffsetRequestedEvent; + /** Raised when creating a directory is requested. The operation must fail with the EXISTS error if the target directory already exists. If recursive is true, then all of the missing directories on the directory path must be created. */ + var onCreateDirectoryRequested: DirectoryPathRecursiveRequestedEvent; + /** Raised when deleting an entry is requested. If recursive is true, and the entry is a directory, then all of the entries inside must be recursively deleted as well. */ + var onDeleteEntryRequested: EntryPathRecursiveRequestedEvent; + /** Raised when creating a file is requested. If the file already exists, then errorCallback must be called with the "EXISTS" error code. */ + var onCreateFileRequested: FilePathRequestedEvent; + /** Raised when copying an entry (recursively if a directory) is requested. If an error occurs, then errorCallback must be called. */ + var onCopyEntryRequested: SourceTargetPathRequestedEvent; + /** Raised when moving an entry (recursively if a directory) is requested. If an error occurs, then errorCallback must be called. */ + var onMoveEntryRequested: SourceTargetPathRequestedEvent; + /** Raised when truncating a file to a desired length is requested. If an error occurs, then errorCallback must be called. */ + var onTruncateRequested: FilePathLengthRequestedEvent; + /** Raised when writing contents to a file opened previously with openRequestId is requested. */ + var onWriteFileRequested: OpenedFileIoRequestedEvent; + /** Raised when aborting an operation with operationRequestId is requested. The operation executed with operationRequestId must be immediately stopped and successCallback of this abort request executed. If aborting fails, then errorCallback must be called. Note, that callbacks of the aborted operation must not be called, as they will be ignored. Despite calling errorCallback, the request may be forcibly aborted. */ + var onAbortRequested: OperationRequestedEvent; + /** + * Raised when showing a configuration dialog for fileSystemId is requested. If it's handled, the file_system_provider.configurable manfiest option must be set to true. + * @since Since Chrome 44. + */ + var onConfigureRequested: RequestedEvent; + /** + * Raised when showing a dialog for mounting a new file system is requested. If the extension/app is a file handler, then this event shouldn't be handled. Instead app.runtime.onLaunched should be handled in order to mount new file systems when a file is opened. For multiple mounts, the file_system_provider.multiple_mounts manifest option must be set to true. + * @since Since Chrome 44. + */ + var onMountRequested: OptionlessRequestedEvent; + /** + * Raised when setting a new directory watcher is requested. If an error occurs, then errorCallback must be called. + * @since Since Chrome 45. Warning: this is the current Beta channel. + */ + var onAddWatcherRequested: EntryPathRecursiveRequestedEvent; + /** + * Raised when the watcher should be removed. If an error occurs, then errorCallback must be called. + * @since Since Chrome 45. Warning: this is the current Beta channel. + */ + var onRemoveWatcherRequested: EntryPathRecursiveRequestedEvent; +} + //////////////////// // Font Settings //////////////////// declare module chrome.fontSettings { - interface FontName { - displayName: string; - fontId: string; - } + interface FontName { + displayName: string; + fontId: string; + } - interface DefaultFontSizeDetails { - pixelSize: number; - } + interface DefaultFontSizeDetails { + pixelSize: number; + } - interface FontDetails { - genericFamily: string; - script?: string; - } + interface FontDetails { + genericFamily: string; + script?: string; + } - interface FullFontDetails { - genericFamily: string; - levelOfControl: string; - script?: string; - fontId: string; - } + interface FullFontDetails { + genericFamily: string; + levelOfControl: string; + script?: string; + fontId: string; + } - interface FontDetailsResult { - levelOfControl: string; - fontId: string; - } + interface FontDetailsResult { + levelOfControl: string; + fontId: string; + } - interface FontSizeDetails { - pixelSize: number; - levelOfControl: string; - } + interface FontSizeDetails { + pixelSize: number; + levelOfControl: string; + } - interface SetFontSizeDetails { - pixelSize: number; - } + interface SetFontSizeDetails { + pixelSize: number; + } - interface SetFontDetails { - genericFamily: string; - script?: string; - fontId: string; - } + interface SetFontDetails { + genericFamily: string; + script?: string; + fontId: string; + } - interface DefaultFixedFontSizeChangedEvent extends chrome.events.Event { - addListener(callback: (details: FontSizeDetails) => void): void; - } + interface DefaultFixedFontSizeChangedEvent extends chrome.events.Event { + addListener(callback: (details: FontSizeDetails) => void): void; + } - interface DefaultFontSizeChangedEvent extends chrome.events.Event { - addListener(callback: (details: FontSizeDetails) => void): void; - } + interface DefaultFontSizeChangedEvent extends chrome.events.Event { + addListener(callback: (details: FontSizeDetails) => void): void; + } - interface MinimumFontSizeChangedEvent extends chrome.events.Event { - addListener(callback: (details: FontSizeDetails) => void): void; - } + interface MinimumFontSizeChangedEvent extends chrome.events.Event { + addListener(callback: (details: FontSizeDetails) => void): void; + } - interface FontChangedEvent extends chrome.events.Event { - addListener(callback: (details: FullFontDetails) => void): void; - } + interface FontChangedEvent extends chrome.events.Event { + addListener(callback: (details: FullFontDetails) => void): void; + } - export function setDefaultFontSize(details: DefaultFontSizeDetails, callback?: Function): void; - export function getFont(details: FontDetails, callback?: (details: FontDetailsResult) => void): void; - export function getDefaultFontSize(details?: FontSizeDetails, callback?: (options: FontSizeDetails) => void): void; - export function getMinimumFontSize(details?: FontSizeDetails, callback?: (options: FontSizeDetails) => void): void; - export function setMinimumFontSize(details: SetFontSizeDetails, callback?: Function): void; - export function getDefaultFixedFontSize(details?: Object, callback?: (details: FontSizeDetails) => void): void; - export function clearDefaultFontSize(details?: Object, callback?: Function): void; - export function setDefaultFixedFontSize(details: SetFontSizeDetails, callback?: Function): void; - export function clearFont(details: FontDetails, callback?: Function): void; - export function setFont(details: SetFontDetails, callback?: Function): void; - export function clearMinimumFontSize(details?: Object, callback?: Function): void; - export function getFontList(callback: (results: FontName[]) => void): void; - export function clearDefaultFixedFontSize(details: Object, callback?: Function): void; + export function setDefaultFontSize(details: DefaultFontSizeDetails, callback?: Function): void; + export function getFont(details: FontDetails, callback?: (details: FontDetailsResult) => void): void; + export function getDefaultFontSize(details?: FontSizeDetails, callback?: (options: FontSizeDetails) => void): void; + export function getMinimumFontSize(details?: FontSizeDetails, callback?: (options: FontSizeDetails) => void): void; + export function setMinimumFontSize(details: SetFontSizeDetails, callback?: Function): void; + export function getDefaultFixedFontSize(details?: Object, callback?: (details: FontSizeDetails) => void): void; + export function clearDefaultFontSize(details?: Object, callback?: Function): void; + export function setDefaultFixedFontSize(details: SetFontSizeDetails, callback?: Function): void; + export function clearFont(details: FontDetails, callback?: Function): void; + export function setFont(details: SetFontDetails, callback?: Function): void; + export function clearMinimumFontSize(details?: Object, callback?: Function): void; + export function getFontList(callback: (results: FontName[]) => void): void; + export function clearDefaultFixedFontSize(details: Object, callback?: Function): void; - var onDefaultFixedFontSizeChanged: DefaultFixedFontSizeChangedEvent; - var onDefaultFontSizeChanged: DefaultFontSizeChangedEvent; - var onMinimumFontSizeChanged: MinimumFontSizeChangedEvent; - var onFontChanged: FontChangedEvent; + var onDefaultFixedFontSizeChanged: DefaultFixedFontSizeChangedEvent; + var onDefaultFontSizeChanged: DefaultFontSizeChangedEvent; + var onMinimumFontSizeChanged: MinimumFontSizeChangedEvent; + var onFontChanged: FontChangedEvent; } //////////////////// // History //////////////////// declare module chrome.history { - interface VisitItem { - transition: string; - visitTime?: number; - visitId: string; - referringVisitId: string; - id: string; - } + interface VisitItem { + transition: string; + visitTime?: number; + visitId: string; + referringVisitId: string; + id: string; + } - interface HistoryItem { - typedCount?: number; - title?: string; - url?: string; - lastVisitTime?: number; - visitCount?: number; - id: string; - } + interface HistoryItem { + typedCount?: number; + title?: string; + url?: string; + lastVisitTime?: number; + visitCount?: number; + id: string; + } - interface HistoryQuery { - text: string; - maxResults?: number; - startTime?: number; - endTime?: number; - } + interface HistoryQuery { + text: string; + maxResults?: number; + startTime?: number; + endTime?: number; + } - interface Url { - url: string; - } + interface Url { + url: string; + } - interface Range { - endTime: number; - startTime: number; - } + interface Range { + endTime: number; + startTime: number; + } - interface RemovedResult { - allHistory: boolean; - urls?: string[]; - } + interface RemovedResult { + allHistory: boolean; + urls?: string[]; + } - interface HistoryVisitedEvent extends chrome.events.Event { - addListener(callback: (result: HistoryItem) => void): void; - } + interface HistoryVisitedEvent extends chrome.events.Event { + addListener(callback: (result: HistoryItem) => void): void; + } - interface HistoryVisitRemovedEvent extends chrome.events.Event { - addListener(callback: (removed: RemovedResult) => void): void; - } + interface HistoryVisitRemovedEvent extends chrome.events.Event { + addListener(callback: (removed: RemovedResult) => void): void; + } - export function search(query: HistoryQuery, callback: (results: HistoryItem[]) => void): void; - export function addUrl(details: Url, callback?: Function): void; - export function deleteRange(range: Range, callback: Function): void; - export function deleteAll(callback: Function): void; - export function getVisits(details: Url, callback: (results: VisitItem[]) => void): void; - export function deleteUrl(details: Url, callback?: Function): void; + export function search(query: HistoryQuery, callback: (results: HistoryItem[]) => void): void; + export function addUrl(details: Url, callback?: Function): void; + export function deleteRange(range: Range, callback: Function): void; + export function deleteAll(callback: Function): void; + export function getVisits(details: Url, callback: (results: VisitItem[]) => void): void; + export function deleteUrl(details: Url, callback?: Function): void; - var onVisited: HistoryVisitedEvent; - var onVisitRemoved: HistoryVisitRemovedEvent; + var onVisited: HistoryVisitedEvent; + var onVisitRemoved: HistoryVisitRemovedEvent; } @@ -2441,8 +3342,8 @@ declare module chrome.history { // Identity //////////////////// declare module chrome.identity { - var getAuthToken: (options: any, cb: (token: {}) => void) => void; - var launchWebAuthFlow: (options: any, cb: (redirect_url: string) => void) => void; + var getAuthToken: (options: any, cb: (token: {}) => void) => void; + var launchWebAuthFlow: (options: any, cb: (redirect_url: string) => void) => void; } @@ -2450,201 +3351,201 @@ declare module chrome.identity { // Internationalization //////////////////// declare module chrome.i18n { - export function getMessage(messageName: string, substitutions?: any): string; - export function getAcceptLanguages(callback: (languages: string[]) => void): void; - export function getUILanguage(): string; + export function getMessage(messageName: string, substitutions?: any): string; + export function getAcceptLanguages(callback: (languages: string[]) => void): void; + export function getUILanguage(): string; } //////////////////// // Idle //////////////////// declare module chrome.idle { - interface IdleStateChangedEvent extends chrome.events.Event { - addListener(callback: (newState: string) => void): void; - } + interface IdleStateChangedEvent extends chrome.events.Event { + addListener(callback: (newState: string) => void): void; + } - export function queryState(thresholdSeconds: number, callback: (newState: string) => void): void; + export function queryState(thresholdSeconds: number, callback: (newState: string) => void): void; - var onStateChanged: IdleStateChangedEvent; + var onStateChanged: IdleStateChangedEvent; } //////////////////// // Input - IME //////////////////// declare module chrome.input.ime { - interface KeyboardEvent { - shiftKey?: boolean; - altKey?: boolean; - requestId: string; - key: string; - ctrlKey?: boolean; - type: string; - } + interface KeyboardEvent { + shiftKey?: boolean; + altKey?: boolean; + requestId: string; + key: string; + ctrlKey?: boolean; + type: string; + } - interface InputContext { - contextID: number; - type: string; - } + interface InputContext { + contextID: number; + type: string; + } - interface ImeParameters { - items: Object[]; - engineID: string; - } + interface ImeParameters { + items: Object[]; + engineID: string; + } - interface CommitTextParameters { - text: string; - contextID: number; - } + interface CommitTextParameters { + text: string; + contextID: number; + } - interface CandidatesParameters { - contextID: number; - candidates: Object[]; - } + interface CandidatesParameters { + contextID: number; + candidates: Object[]; + } - interface CompositionParameters { - contextID: number; - text: string; - segments: Object[]; - cursor: number; - selectionStart?: number; - selectionEnd?: number; - } + interface CompositionParameters { + contextID: number; + text: string; + segments: Object[]; + cursor: number; + selectionStart?: number; + selectionEnd?: number; + } - interface MenuItemParameters { - items: Object[]; - engineId: string; - } + interface MenuItemParameters { + items: Object[]; + engineId: string; + } - interface CandidateWindowPropertiesParameters { - cursorVisible?: boolean; - vertical?: boolean; - pageSize?: number; - auxiliaryTextVisible?: boolean; - auxiliaryText?: string; - visible?: boolean; - } + interface CandidateWindowPropertiesParameters { + cursorVisible?: boolean; + vertical?: boolean; + pageSize?: number; + auxiliaryTextVisible?: boolean; + auxiliaryText?: string; + visible?: boolean; + } - interface ClearCompositionParameters { - contextID: number; - } + interface ClearCompositionParameters { + contextID: number; + } - interface CursorPositionParameters { - candidateID: number; - contextID: number; - } + interface CursorPositionParameters { + candidateID: number; + contextID: number; + } - interface BlurEvent extends chrome.events.Event { - addListener(callback: (contextID: number) => void): void; - } + interface BlurEvent extends chrome.events.Event { + addListener(callback: (contextID: number) => void): void; + } - interface CandidateClickedEvent extends chrome.events.Event { - addListener(callback: (engineID: string, candidateID: number, button: string) => void): void; - } + interface CandidateClickedEvent extends chrome.events.Event { + addListener(callback: (engineID: string, candidateID: number, button: string) => void): void; + } - interface KeyEventEvent extends chrome.events.Event { - addListener(callback: (engineID: string, keyData: KeyboardEvent) => void): void; - } + interface KeyEventEvent extends chrome.events.Event { + addListener(callback: (engineID: string, keyData: KeyboardEvent) => void): void; + } - interface DeactivatedEvent extends chrome.events.Event { - addListener(callback: (engineID: string) => void): void; - } + interface DeactivatedEvent extends chrome.events.Event { + addListener(callback: (engineID: string) => void): void; + } - interface InputContextUpdateEvent extends chrome.events.Event { - addListener(callback: (context: InputContext) => void): void; - } + interface InputContextUpdateEvent extends chrome.events.Event { + addListener(callback: (context: InputContext) => void): void; + } - interface ActivateEvent extends chrome.events.Event { - addListener(callback: (engineID: string) => void): void; - } + interface ActivateEvent extends chrome.events.Event { + addListener(callback: (engineID: string) => void): void; + } - interface FocusEvent extends chrome.events.Event { - addListener(callback: (context: InputContext) => void): void; - } + interface FocusEvent extends chrome.events.Event { + addListener(callback: (context: InputContext) => void): void; + } - interface MenuItemActivatedEvent extends chrome.events.Event { - addListener(callback: (engineID: string, name: string) => void): void; - } + interface MenuItemActivatedEvent extends chrome.events.Event { + addListener(callback: (engineID: string, name: string) => void): void; + } - export function setMenuItems(parameters: ImeParameters, callback?: Function): void; - export function commitText(parameters: CommitTextParameters, callback?: (success: boolean) => void): void; - export function setCandidates(parameters: CandidatesParameters, callback?: (success: boolean) => void): void; - export function setComposition(parameters: CompositionParameters, callback?: (success: boolean) => void): void; - export function updateMenuItems(parameters: MenuItemParameters, callback?: Function): void; - export function setCandidateWindowProperties(parameters: CandidateWindowPropertiesParameters, callback?: (success: boolean) => void): void; - export function clearComposition(parameters: ClearCompositionParameters, callback?: (success: boolean) => void): void; - export function setCursorPosition(parameters: CursorPositionParameters, callback?: (success: boolean) => void): void; + export function setMenuItems(parameters: ImeParameters, callback?: Function): void; + export function commitText(parameters: CommitTextParameters, callback?: (success: boolean) => void): void; + export function setCandidates(parameters: CandidatesParameters, callback?: (success: boolean) => void): void; + export function setComposition(parameters: CompositionParameters, callback?: (success: boolean) => void): void; + export function updateMenuItems(parameters: MenuItemParameters, callback?: Function): void; + export function setCandidateWindowProperties(parameters: CandidateWindowPropertiesParameters, callback?: (success: boolean) => void): void; + export function clearComposition(parameters: ClearCompositionParameters, callback?: (success: boolean) => void): void; + export function setCursorPosition(parameters: CursorPositionParameters, callback?: (success: boolean) => void): void; - var onBlur: BlurEvent; - var onCandidateClicked: CandidateClickedEvent; - var onKeyEvent: KeyEventEvent; - var onDeactivated: DeactivatedEvent; - var onInputContextUpdate: InputContextUpdateEvent; - var onActivate: ActivateEvent; - var onFocus: FocusEvent; - var onMenuItemActivated: MenuItemActivatedEvent; + var onBlur: BlurEvent; + var onCandidateClicked: CandidateClickedEvent; + var onKeyEvent: KeyEventEvent; + var onDeactivated: DeactivatedEvent; + var onInputContextUpdate: InputContextUpdateEvent; + var onActivate: ActivateEvent; + var onFocus: FocusEvent; + var onMenuItemActivated: MenuItemActivatedEvent; } //////////////////// // Management //////////////////// declare module chrome.management { - interface ExtensionInfo { - disabledReason?: string; - appLaunchUrl?: string; - description: string; - permissions: string[]; - icons?: IconInfo[]; - hostPermissions: string[]; - enabled: boolean; - homepageUrl?: string; - mayDisable: boolean; - installType: string; - version: string; - id: string; - offlineEnabled: boolean; - updateUrl?: string; - type: string; - optionsUrl: string; - name: string; - } + interface ExtensionInfo { + disabledReason?: string; + appLaunchUrl?: string; + description: string; + permissions: string[]; + icons?: IconInfo[]; + hostPermissions: string[]; + enabled: boolean; + homepageUrl?: string; + mayDisable: boolean; + installType: string; + version: string; + id: string; + offlineEnabled: boolean; + updateUrl?: string; + type: string; + optionsUrl: string; + name: string; + } - interface IconInfo { - url: string; - size: number; - } + interface IconInfo { + url: string; + size: number; + } - interface UninstallOptions { - showConfirmDialog?: boolean; - } + interface UninstallOptions { + showConfirmDialog?: boolean; + } - interface ManagementDisabledEvent extends chrome.events.Event { - addListener(callback: (info: ExtensionInfo) => void): void; - } + interface ManagementDisabledEvent extends chrome.events.Event { + addListener(callback: (info: ExtensionInfo) => void): void; + } - interface ManagementUninstalledEvent extends chrome.events.Event { - addListener(callback: (id: string) => void): void; - } + interface ManagementUninstalledEvent extends chrome.events.Event { + addListener(callback: (id: string) => void): void; + } - interface ManagementInstalledEvent extends chrome.events.Event { - addListener(callback: (info: ExtensionInfo) => void): void; - } + interface ManagementInstalledEvent extends chrome.events.Event { + addListener(callback: (info: ExtensionInfo) => void): void; + } - interface ManagementEnabledEvent extends chrome.events.Event { - addListener(callback: (info: ExtensionInfo) => void): void; - } + interface ManagementEnabledEvent extends chrome.events.Event { + addListener(callback: (info: ExtensionInfo) => void): void; + } - export function setEnabled(id: string, enabled: boolean, callback?: Function): void; - export function getPermissionWarningsById(id: string, callback?: (permissionWarnings: string[]) => void): void; - export function get(id: string, callback?: (result: ExtensionInfo) => void): void; - export function getAll(callback?: (result: ExtensionInfo[]) => void): void; - export function getPermissionWarningsByManifest(manifestStr: string, callback?: (permissionwarnings: string[]) => void): void; - export function launchApp(id: string, callback?: Function): void; - export function uninstall(id: string, options: UninstallOptions, callback?: Function): void; + export function setEnabled(id: string, enabled: boolean, callback?: Function): void; + export function getPermissionWarningsById(id: string, callback?: (permissionWarnings: string[]) => void): void; + export function get(id: string, callback?: (result: ExtensionInfo) => void): void; + export function getAll(callback?: (result: ExtensionInfo[]) => void): void; + export function getPermissionWarningsByManifest(manifestStr: string, callback?: (permissionwarnings: string[]) => void): void; + export function launchApp(id: string, callback?: Function): void; + export function uninstall(id: string, options: UninstallOptions, callback?: Function): void; - var onDisabled: ManagementDisabledEvent; - var onUninstalled: ManagementUninstalledEvent; - var onInstalled: ManagementInstalledEvent; - var onEnabled: ManagementEnabledEvent; + var onDisabled: ManagementDisabledEvent; + var onUninstalled: ManagementUninstalledEvent; + var onInstalled: ManagementInstalledEvent; + var onEnabled: ManagementEnabledEvent; } //////////////////// @@ -2652,382 +3553,382 @@ declare module chrome.management { // https://developer.chrome.com/extensions/notifications //////////////////// declare module chrome.notifications { - interface ButtonOptions { - title: string; - iconUrl?: string; - } + interface ButtonOptions { + title: string; + iconUrl?: string; + } - interface ItemOptions { - title: string; - message: string; - } + interface ItemOptions { + title: string; + message: string; + } - interface NotificationOptions { - type?: string; - iconUrl?: string; - title?: string; - message?: string; - contextMessage?: string; - priority?: number; - eventTime?: number; - buttons?: Array; - items?: Array; - progress?: number; - isClickable?: boolean; - } + interface NotificationOptions { + type?: string; + iconUrl?: string; + title?: string; + message?: string; + contextMessage?: string; + priority?: number; + eventTime?: number; + buttons?: Array; + items?: Array; + progress?: number; + isClickable?: boolean; + } - interface OnClosed { - addListener(callback: (notificationId: string, byUser: boolean) => void): void; - } + interface OnClosed { + addListener(callback: (notificationId: string, byUser: boolean) => void): void; + } - interface OnClicked { - addListener(callback: (notificationId: string) => void): void; - } + interface OnClicked { + addListener(callback: (notificationId: string) => void): void; + } - interface OnButtonClicked { - addListener(callback: (notificationId: string, buttonIndex: number) => void): void; - } + interface OnButtonClicked { + addListener(callback: (notificationId: string, buttonIndex: number) => void): void; + } - interface OnPermissionLevelChanged { - addListener(callback: (level: string) => void): void; - } + interface OnPermissionLevelChanged { + addListener(callback: (level: string) => void): void; + } - interface OnShowSettings { - addListener(callback: Function): void; - } + interface OnShowSettings { + addListener(callback: Function): void; + } - export var onClosed: OnClosed; - export var onClicked: OnClicked; - export var onButtonClicked: OnButtonClicked; - export var onPermissionLevelChanged: OnPermissionLevelChanged; - export var onShowSettings: OnShowSettings; + export var onClosed: OnClosed; + export var onClicked: OnClicked; + export var onButtonClicked: OnButtonClicked; + export var onPermissionLevelChanged: OnPermissionLevelChanged; + export var onShowSettings: OnShowSettings; - export function create(notificationId: string, options: NotificationOptions, callback: (notificationId: string) => void): void; - export function update(notificationId: string, options: NotificationOptions, callback: (wasUpdated: boolean) => void): void; - export function clear(notificationId: string, callback: (wasCleared: boolean) => void): void; - export function getAll(callback: (notifications: any) => void): void; - export function getPermissionLevel(callback: (level: string) => void): void; + export function create(notificationId: string, options: NotificationOptions, callback: (notificationId: string) => void): void; + export function update(notificationId: string, options: NotificationOptions, callback: (wasUpdated: boolean) => void): void; + export function clear(notificationId: string, callback: (wasCleared: boolean) => void): void; + export function getAll(callback: (notifications: any) => void): void; + export function getPermissionLevel(callback: (level: string) => void): void; } //////////////////// // Omnibox //////////////////// declare module chrome.omnibox { - interface SuggestResult { - content: string; - description: string; - } + interface SuggestResult { + content: string; + description: string; + } - interface Suggestion { - description: string; - } + interface Suggestion { + description: string; + } - interface OmniboxInputEnteredEvent extends chrome.events.Event { - addListener(callback: (text: string) => void): void; - } + interface OmniboxInputEnteredEvent extends chrome.events.Event { + addListener(callback: (text: string) => void): void; + } - interface OmniboxInputChangedEvent extends chrome.events.Event { - addListener(callback: (text: string, suggest: (suggestResults: SuggestResult[]) => void) => void): void; - } + interface OmniboxInputChangedEvent extends chrome.events.Event { + addListener(callback: (text: string, suggest: (suggestResults: SuggestResult[]) => void) => void): void; + } - interface OmniboxInputStartedEvent extends chrome.events.Event { - addListener(callback: Function): void; - } + interface OmniboxInputStartedEvent extends chrome.events.Event { + addListener(callback: Function): void; + } - interface OmniboxInputCancelledEvent extends chrome.events.Event { - addListener(callback: Function): void; - } + interface OmniboxInputCancelledEvent extends chrome.events.Event { + addListener(callback: Function): void; + } - export function setDefaultSuggestion(suggestion: Suggestion): void; + export function setDefaultSuggestion(suggestion: Suggestion): void; - var onInputEntered: OmniboxInputEnteredEvent; - var onInputChanged: OmniboxInputChangedEvent; - var onInputStarted: OmniboxInputStartedEvent; - var onInputCancelled: OmniboxInputCancelledEvent; + var onInputEntered: OmniboxInputEnteredEvent; + var onInputChanged: OmniboxInputChangedEvent; + var onInputStarted: OmniboxInputStartedEvent; + var onInputCancelled: OmniboxInputCancelledEvent; } //////////////////// // Page Action //////////////////// declare module chrome.pageAction { - interface PageActionClickedEvent extends chrome.events.Event { - addListener(callback: (tab: chrome.tabs.Tab) => void): void; - } + interface PageActionClickedEvent extends chrome.events.Event { + addListener(callback: (tab: chrome.tabs.Tab) => void): void; + } - interface TitleDetails { - tabId: number; - title: string; - } + interface TitleDetails { + tabId: number; + title: string; + } - interface GetDetails { - tabId: number; - } + interface GetDetails { + tabId: number; + } - interface PopupDetails { - tabId: number; - popup: string; - } + interface PopupDetails { + tabId: number; + popup: string; + } - interface IconDetails { - tabId: number; - iconIndex?: number; - imageData?: ImageData; - path?: any; - } + interface IconDetails { + tabId: number; + iconIndex?: number; + imageData?: ImageData; + path?: any; + } - export function hide(tabId: number): void; - export function show(tabId: number): void; - export function setTitle(details: TitleDetails): void; - export function setPopup(details: PopupDetails): void; - export function getTitle(details: GetDetails, callback: (result: string) => void): void; - export function getPopup(details: GetDetails, callback: (result: string) => void): void; - export function setIcon(details: IconDetails, callback?: Function): void; + export function hide(tabId: number): void; + export function show(tabId: number): void; + export function setTitle(details: TitleDetails): void; + export function setPopup(details: PopupDetails): void; + export function getTitle(details: GetDetails, callback: (result: string) => void): void; + export function getPopup(details: GetDetails, callback: (result: string) => void): void; + export function setIcon(details: IconDetails, callback?: Function): void; - var onClicked: PageActionClickedEvent; + var onClicked: PageActionClickedEvent; } //////////////////// // Page Capture //////////////////// declare module chrome.pageCapture { - interface SaveDetails { - tabId: number; - } + interface SaveDetails { + tabId: number; + } - export function saveAsMHTML(details: SaveDetails, callback: (mhtmlData: any) => void): void; + export function saveAsMHTML(details: SaveDetails, callback: (mhtmlData: any) => void): void; } //////////////////// // Permissions //////////////////// declare module chrome.permissions { - interface Permissions { - origins?: string[]; - permissions?: string[]; - } + interface Permissions { + origins?: string[]; + permissions?: string[]; + } - interface PermissionsRemovedEvent { - addListener(callback: (permissions: Permissions) => void): void; - } + interface PermissionsRemovedEvent { + addListener(callback: (permissions: Permissions) => void): void; + } - interface PermissionsAddedEvent { - addListener(callback: (permissions: Permissions) => void): void; - } + interface PermissionsAddedEvent { + addListener(callback: (permissions: Permissions) => void): void; + } - export function contains(permissions: Permissions, callback: (result: boolean) => void): void; - export function getAll(callback: (permissions: Permissions) => void): void; - export function request(permissions: Permissions, callback?: (granted: boolean) => void): void; - export function remove(permissions: Permissions, callback?: (removed: boolean) => void): void; + export function contains(permissions: Permissions, callback: (result: boolean) => void): void; + export function getAll(callback: (permissions: Permissions) => void): void; + export function request(permissions: Permissions, callback?: (granted: boolean) => void): void; + export function remove(permissions: Permissions, callback?: (removed: boolean) => void): void; - var onRemoved: PermissionsRemovedEvent; - var onAdded: PermissionsAddedEvent; + var onRemoved: PermissionsRemovedEvent; + var onAdded: PermissionsAddedEvent; } //////////////////// // Privacy //////////////////// declare module chrome.privacy { - interface Services { - spellingServiceEnabled: chrome.types.ChromeSetting; - searchSuggestEnabled: chrome.types.ChromeSetting; - instantEnabled: chrome.types.ChromeSetting; - alternateErrorPagesEnabled: chrome.types.ChromeSetting; - safeBrowsingEnabled: chrome.types.ChromeSetting; - autofillEnabled: chrome.types.ChromeSetting; - translationServiceEnabled: chrome.types.ChromeSetting; - } + interface Services { + spellingServiceEnabled: chrome.types.ChromeSetting; + searchSuggestEnabled: chrome.types.ChromeSetting; + instantEnabled: chrome.types.ChromeSetting; + alternateErrorPagesEnabled: chrome.types.ChromeSetting; + safeBrowsingEnabled: chrome.types.ChromeSetting; + autofillEnabled: chrome.types.ChromeSetting; + translationServiceEnabled: chrome.types.ChromeSetting; + } - interface Network { - networkPredictionEnabled: chrome.types.ChromeSetting; - } + interface Network { + networkPredictionEnabled: chrome.types.ChromeSetting; + } - interface Websites { - thirdPartyCookiesAllowed: chrome.types.ChromeSetting; - referrersEnabled: chrome.types.ChromeSetting; - hyperlinkAuditingEnabled: chrome.types.ChromeSetting; - protectedContentEnabled: chrome.types.ChromeSetting; - } + interface Websites { + thirdPartyCookiesAllowed: chrome.types.ChromeSetting; + referrersEnabled: chrome.types.ChromeSetting; + hyperlinkAuditingEnabled: chrome.types.ChromeSetting; + protectedContentEnabled: chrome.types.ChromeSetting; + } - var services: Services; - var network: Network; - var websites: Websites; + var services: Services; + var network: Network; + var websites: Websites; } //////////////////// // Proxy //////////////////// declare module chrome.proxy { - interface PacScript { - url?: string; - mandatory?: boolean; - data?: string; - } + interface PacScript { + url?: string; + mandatory?: boolean; + data?: string; + } - interface ProxyConfig { - rules?: ProxyRules; - pacScript?: PacScript; - mode: string; - } + interface ProxyConfig { + rules?: ProxyRules; + pacScript?: PacScript; + mode: string; + } - interface ProxyServer { - host: string; - scheme?: string; - port?: number; - } + interface ProxyServer { + host: string; + scheme?: string; + port?: number; + } - interface ProxyRules { - proxyForFtp?: ProxyServer; - proxyForHttp?: ProxyServer; - facllbackProxy?: ProxyServer; - singleProxy?: ProxyServer; - proxyForHttps?: ProxyServer; - bypassList?: string[]; - } + interface ProxyRules { + proxyForFtp?: ProxyServer; + proxyForHttp?: ProxyServer; + facllbackProxy?: ProxyServer; + singleProxy?: ProxyServer; + proxyForHttps?: ProxyServer; + bypassList?: string[]; + } - interface ErrorDetails { - details: string; - error: string; - fatal: boolean; - } + interface ErrorDetails { + details: string; + error: string; + fatal: boolean; + } - interface ProxyErrorEvent extends chrome.events.Event { - addListener(callback: (details: ErrorDetails) => void): void; - } + interface ProxyErrorEvent extends chrome.events.Event { + addListener(callback: (details: ErrorDetails) => void): void; + } - var settings: chrome.types.ChromeSetting; - var onProxyError: ProxyErrorEvent; + var settings: chrome.types.ChromeSetting; + var onProxyError: ProxyErrorEvent; } //////////////////// // Runtime //////////////////// declare module chrome.runtime { - var lastError: LastError; - var id: string; + var lastError: LastError; + var id: string; - interface LastError { - message?: string; - } + interface LastError { + message?: string; + } - interface ConnectInfo { - name?: string; - } + interface ConnectInfo { + name?: string; + } - interface InstalledDetails { - reason: string; - previousVersion?: string; - } + interface InstalledDetails { + reason: string; + previousVersion?: string; + } - interface MessageOptions { - includeTlsChannelId?: boolean; - } + interface MessageOptions { + includeTlsChannelId?: boolean; + } - interface MessageSender { - id?: string; - tab?: chrome.tabs.Tab; - frameId?: number; - url?: string; - tlsChannelId?: string; - } + interface MessageSender { + id?: string; + tab?: chrome.tabs.Tab; + frameId?: number; + url?: string; + tlsChannelId?: string; + } - interface PlatformInfo { - os: string; - arch: string; - nacl_arch: string; - } + interface PlatformInfo { + os: string; + arch: string; + nacl_arch: string; + } - interface Port { - postMessage: (message: Object) => void; - disconnect: () => void; - sender?: MessageSender; - onDisconnect: chrome.events.Event; - onMessage: PortMessageEvent; - name: string; - } + interface Port { + postMessage: (message: Object) => void; + disconnect: () => void; + sender?: MessageSender; + onDisconnect: chrome.events.Event; + onMessage: PortMessageEvent; + name: string; + } - interface UpdateAvailableDetails { - version: string; - } + interface UpdateAvailableDetails { + version: string; + } - interface UpdateCheckDetails { - version: string; - } + interface UpdateCheckDetails { + version: string; + } - interface PortMessageEvent extends chrome.events.Event { - addListener(callback: (message: Object, port: Port) => void): void; - } + interface PortMessageEvent extends chrome.events.Event { + addListener(callback: (message: Object, port: Port) => void): void; + } - interface ExtensionMessageEvent extends chrome.events.Event { - addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void; - } + interface ExtensionMessageEvent extends chrome.events.Event { + addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void; + } - interface ExtensionMessageExternalEvent extends chrome.events.Event { - addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void; - } + interface ExtensionMessageExternalEvent extends chrome.events.Event { + addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void; + } - interface ExtensionConnectEvent extends chrome.events.Event { - addListener(callback: (port: Port) => void): void; - } + interface ExtensionConnectEvent extends chrome.events.Event { + addListener(callback: (port: Port) => void): void; + } - interface ExtensionConnectExternalEvent extends chrome.events.Event { - addListener(callback: (port: Port) => void): void; - } + interface ExtensionConnectExternalEvent extends chrome.events.Event { + addListener(callback: (port: Port) => void): void; + } - interface RuntimeSuspendEvent extends chrome.events.Event { - addListener(callback: Function): void; - } + interface RuntimeSuspendEvent extends chrome.events.Event { + addListener(callback: Function): void; + } - interface RuntimeStartupEvent extends chrome.events.Event { - addListener(callback: Function): void; - } + interface RuntimeStartupEvent extends chrome.events.Event { + addListener(callback: Function): void; + } - interface RuntimeInstalledEvent extends chrome.events.Event { - addListener(callback: (details: InstalledDetails) => void): void; - } + interface RuntimeInstalledEvent extends chrome.events.Event { + addListener(callback: (details: InstalledDetails) => void): void; + } - interface RuntimeSuspendCanceledEvent extends chrome.events.Event { - addListener(callback: Function): void; - } - interface RuntimeMessageEvent extends chrome.events.Event { - addListener(callback: Function): void; - } + interface RuntimeSuspendCanceledEvent extends chrome.events.Event { + addListener(callback: Function): void; + } + interface RuntimeMessageEvent extends chrome.events.Event { + addListener(callback: Function): void; + } - interface RuntimeRestartRequiredEvent extends chrome.events.Event { - addListener(callback: (reason: string) => void): void; - } + interface RuntimeRestartRequiredEvent extends chrome.events.Event { + addListener(callback: (reason: string) => void): void; + } - interface RuntimeUpdateAvailableEvent extends chrome.events.Event { - addListener(callback: (details: UpdateAvailableDetails) => void): void; - } + interface RuntimeUpdateAvailableEvent extends chrome.events.Event { + addListener(callback: (details: UpdateAvailableDetails) => void): void; + } - export function connect(connectInfo?: ConnectInfo): Port; - export function connect(extensionId: string, connectInfo?: ConnectInfo): Port; - export function connectNative(application: string): Port; - export function getBackgroundPage(callback: (backgroundPage?: Window) => void): void; - export function getManifest(): Object; - export function getPackageDirectoryEntry(callback: (directoryEntry: any) => void): void; - export function getPlatformInfo(callback: (platformInfo: PlatformInfo) => void): void; - export function getURL(path: string): string; - export function reload(): void; - export function requestUpdateCheck(callback: (status: string, details?: UpdateCheckDetails) => void): void; - export function restart(): void; - export function sendMessage(message: any, responseCallback?: (response: any) => void): void; - export function sendMessage(message: any, options: MessageOptions, responseCallback?: (response: any) => void): void; - export function sendMessage(extensionId: string, message: any, responseCallback?: (response: any) => void): void; - export function sendMessage(extensionId: string, message: any, options: MessageOptions, responseCallback?: (response: any) => void): void; - export function sendNativeMessage(application: string, message: any, responseCallback?: (response: any) => void): void; - export function setUninstallUrl(url: string): void; + export function connect(connectInfo?: ConnectInfo): Port; + export function connect(extensionId: string, connectInfo?: ConnectInfo): Port; + export function connectNative(application: string): Port; + export function getBackgroundPage(callback: (backgroundPage?: Window) => void): void; + export function getManifest(): Object; + export function getPackageDirectoryEntry(callback: (directoryEntry: any) => void): void; + export function getPlatformInfo(callback: (platformInfo: PlatformInfo) => void): void; + export function getURL(path: string): string; + export function reload(): void; + export function requestUpdateCheck(callback: (status: string, details?: UpdateCheckDetails) => void): void; + export function restart(): void; + export function sendMessage(message: any, responseCallback?: (response: any) => void): void; + export function sendMessage(message: any, options: MessageOptions, responseCallback?: (response: any) => void): void; + export function sendMessage(extensionId: string, message: any, responseCallback?: (response: any) => void): void; + export function sendMessage(extensionId: string, message: any, options: MessageOptions, responseCallback?: (response: any) => void): void; + export function sendNativeMessage(application: string, message: any, responseCallback?: (response: any) => void): void; + export function setUninstallUrl(url: string): void; - var onConnect: ExtensionConnectEvent; - var onConnectExternal: ExtensionConnectExternalEvent; - var onSuspend: RuntimeSuspendEvent; - var onStartup: RuntimeStartupEvent; - var onInstalled: RuntimeInstalledEvent; - var onSuspendCanceled: RuntimeSuspendCanceledEvent; - var onMessage: ExtensionMessageEvent; - var onMessageExternal: ExtensionMessageExternalEvent; - var onRestartRequired: RuntimeRestartRequiredEvent; - var onUpdateAvailable: RuntimeUpdateAvailableEvent; + var onConnect: ExtensionConnectEvent; + var onConnectExternal: ExtensionConnectExternalEvent; + var onSuspend: RuntimeSuspendEvent; + var onStartup: RuntimeStartupEvent; + var onInstalled: RuntimeInstalledEvent; + var onSuspendCanceled: RuntimeSuspendCanceledEvent; + var onMessage: ExtensionMessageEvent; + var onMessageExternal: ExtensionMessageExternalEvent; + var onRestartRequired: RuntimeRestartRequiredEvent; + var onUpdateAvailable: RuntimeUpdateAvailableEvent; } @@ -3035,846 +3936,846 @@ declare module chrome.runtime { // Script Badge //////////////////// declare module chrome.scriptBadge { - interface GetPopupDetails { - tabId: number; - } + interface GetPopupDetails { + tabId: number; + } - interface AttentionDetails { - tabId: number; - } + interface AttentionDetails { + tabId: number; + } - interface SetPopupDetails { - tabId: number; - popup: string; - } + interface SetPopupDetails { + tabId: number; + popup: string; + } - interface ScriptBadgeClickedEvent extends chrome.events.Event { - addListener(callback: (tab: chrome.tabs.Tab) => void): void; - } + interface ScriptBadgeClickedEvent extends chrome.events.Event { + addListener(callback: (tab: chrome.tabs.Tab) => void): void; + } - export function getPopup(details: GetPopupDetails, callback: Function): void; - export function getAttention(details: AttentionDetails): void; - export function setPopup(details: SetPopupDetails): void; + export function getPopup(details: GetPopupDetails, callback: Function): void; + export function getAttention(details: AttentionDetails): void; + export function setPopup(details: SetPopupDetails): void; - var onClicked: ScriptBadgeClickedEvent; + var onClicked: ScriptBadgeClickedEvent; } //////////////////// // Storage //////////////////// declare module chrome.storage { - interface StorageArea { - getBytesInUse(callback: (bytesInUse: number) => void): void; - getBytesInUse(keys: string, callback: (bytesInUse: number) => void): void; - getBytesInUse(keys: string[], callback: (bytesInUse: number) => void): void; - clear(callback?: Function): void; - set(items: Object, callback?: Function): void; - remove(keys: string, callback?: Function): void; - remove(keys: string[], callback?: Function): void; - get(callback: (items: Object) => void): void; - get(keys: string, callback: (items: Object) => void): void; - get(keys: string[], callback: (items: Object) => void): void; - get(keys: Object, callback: (items: Object) => void): void; - } + interface StorageArea { + getBytesInUse(callback: (bytesInUse: number) => void): void; + getBytesInUse(keys: string, callback: (bytesInUse: number) => void): void; + getBytesInUse(keys: string[], callback: (bytesInUse: number) => void): void; + clear(callback?: Function): void; + set(items: Object, callback?: Function): void; + remove(keys: string, callback?: Function): void; + remove(keys: string[], callback?: Function): void; + get(callback: (items: Object) => void): void; + get(keys: string, callback: (items: Object) => void): void; + get(keys: string[], callback: (items: Object) => void): void; + get(keys: Object, callback: (items: Object) => void): void; + } - interface StorageChange { - newValue?: any; - oldValue?: any; - } + interface StorageChange { + newValue?: any; + oldValue?: any; + } - interface Local extends StorageArea { - QUOTA_BYTES: number; - } + interface Local extends StorageArea { + QUOTA_BYTES: number; + } - interface Sync extends StorageArea { - MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: number; - QUOTA_BYTES: number; - QUOTA_BYTES_PER_ITEM: number; - MAX_ITEMS: number; - MAX_WRITE_OPERATIONS_PER_HOUR: number; - } + interface Sync extends StorageArea { + MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: number; + QUOTA_BYTES: number; + QUOTA_BYTES_PER_ITEM: number; + MAX_ITEMS: number; + MAX_WRITE_OPERATIONS_PER_HOUR: number; + } - interface StorageChangedEvent extends chrome.events.Event { - addListener(callback: (changes: Object, areaName: string) => void): void; - } + interface StorageChangedEvent extends chrome.events.Event { + addListener(callback: (changes: Object, areaName: string) => void): void; + } - var local: Local; - var sync: Sync; + var local: Local; + var sync: Sync; - var onChanged: StorageChangedEvent; + var onChanged: StorageChangedEvent; } //////////////////// // Socket //////////////////// declare module chrome.socket { - interface CreateInfo { - socketId: number; - } + interface CreateInfo { + socketId: number; + } - interface AcceptInfo { - resultCode: number; - socketId?: number; - } + interface AcceptInfo { + resultCode: number; + socketId?: number; + } - interface ReadInfo { - resultCode: number; - data: ArrayBuffer; - } + interface ReadInfo { + resultCode: number; + data: ArrayBuffer; + } - interface WriteInfo { - bytesWritten: number; - } + interface WriteInfo { + bytesWritten: number; + } - interface RecvFromInfo { - resultCode: number; - data: ArrayBuffer; - port: number; - address: string; - } + interface RecvFromInfo { + resultCode: number; + data: ArrayBuffer; + port: number; + address: string; + } - interface SocketInfo { - socketType: string; - localPort?: number; - peerAddress?: string; - peerPort?: number; - localAddress?: string; - connected: boolean; - } + interface SocketInfo { + socketType: string; + localPort?: number; + peerAddress?: string; + peerPort?: number; + localAddress?: string; + connected: boolean; + } - interface NetworkInterface { - name: string; - address: string; - } + interface NetworkInterface { + name: string; + address: string; + } - export function create(type: string, options?: Object, callback?: (createInfo: CreateInfo) => void): void; - export function destroy(socketId: number): void; - export function connect(socketId: number, hostname: string, port: number, callback: (result: number) => void): void; - export function bind(socketId: number, address: string, port: number, callback: (result: number) => void): void; - export function disconnect(socketId: number): void; - export function read(socketId: number, bufferSize?: number, callback?: (readInfo: ReadInfo) => void): void; - export function write(socketId: number, data: ArrayBuffer, callback?: (writeInfo: WriteInfo) => void): void; - export function recvFrom(socketId: number, bufferSize?: number, callback?: (recvFromInfo: RecvFromInfo) => void): void; - export function sendTo(socketId: number, data: ArrayBuffer, address: string, port: number, callback?: (writeInfo: WriteInfo) => void): void; - export function listen(socketId: number, address: string, port: number, backlog?: number, callback?: (result: number) => void): void; - export function accept(socketId: number, callback?: (acceptInfo: AcceptInfo) => void): void; - export function setKeepAlive(socketId: number, enable: boolean, delay?: number, callback?: (result: boolean) => void): void; - export function setNoDelay(socketId: number, noDelay: boolean, callback?: (result: boolean) => void): void; - export function getInfo(socketId: number, callback: (result: SocketInfo) => void): void; - export function getNetworkList(callback: (result: NetworkInterface[]) => void): void; + export function create(type: string, options?: Object, callback?: (createInfo: CreateInfo) => void): void; + export function destroy(socketId: number): void; + export function connect(socketId: number, hostname: string, port: number, callback: (result: number) => void): void; + export function bind(socketId: number, address: string, port: number, callback: (result: number) => void): void; + export function disconnect(socketId: number): void; + export function read(socketId: number, bufferSize?: number, callback?: (readInfo: ReadInfo) => void): void; + export function write(socketId: number, data: ArrayBuffer, callback?: (writeInfo: WriteInfo) => void): void; + export function recvFrom(socketId: number, bufferSize?: number, callback?: (recvFromInfo: RecvFromInfo) => void): void; + export function sendTo(socketId: number, data: ArrayBuffer, address: string, port: number, callback?: (writeInfo: WriteInfo) => void): void; + export function listen(socketId: number, address: string, port: number, backlog?: number, callback?: (result: number) => void): void; + export function accept(socketId: number, callback?: (acceptInfo: AcceptInfo) => void): void; + export function setKeepAlive(socketId: number, enable: boolean, delay?: number, callback?: (result: boolean) => void): void; + export function setNoDelay(socketId: number, noDelay: boolean, callback?: (result: boolean) => void): void; + export function getInfo(socketId: number, callback: (result: SocketInfo) => void): void; + export function getNetworkList(callback: (result: NetworkInterface[]) => void): void; } //////////////////// // TabCapture //////////////////// declare module chrome.tabCapture { - interface CaptureInfo { - tabId: number; - status: string; - fullscreen: boolean; - } + interface CaptureInfo { + tabId: number; + status: string; + fullscreen: boolean; + } - interface CaptureOptions { - audio?: boolean; - video?: boolean; - audioConstraints?: MediaTrackConstraints; - videoConstraints?: MediaTrackConstraints; - } + interface CaptureOptions { + audio?: boolean; + video?: boolean; + audioConstraints?: MediaTrackConstraints; + videoConstraints?: MediaTrackConstraints; + } - export function capture(options: CaptureOptions, callback: (stream: MediaStream) => void): void; - export function getCapturedTabs(callback: (result: CaptureInfo[]) => void): void; + export function capture(options: CaptureOptions, callback: (stream: MediaStream) => void): void; + export function getCapturedTabs(callback: (result: CaptureInfo[]) => void): void; } //////////////////// // Tabs //////////////////// declare module chrome.tabs { - interface Tab { - status?: string; - index: number; - openerTabId?: number; - title?: string; - url?: string; - pinned: boolean; - highlighted: boolean; - windowId: number; - active: boolean; - favIconUrl?: string; - id: number; - incognito: boolean; - } + interface Tab { + status?: string; + index: number; + openerTabId?: number; + title?: string; + url?: string; + pinned: boolean; + highlighted: boolean; + windowId: number; + active: boolean; + favIconUrl?: string; + id: number; + incognito: boolean; + } - interface InjectDetails { - allFrames?: boolean; - code?: string; - runAt?: string; - file?: string; - } + interface InjectDetails { + allFrames?: boolean; + code?: string; + runAt?: string; + file?: string; + } - interface CreateProperties { - index?: number; - openerTabId?: number; - url?: string; - pinned?: boolean; - windowId?: number; - active?: boolean; - } + interface CreateProperties { + index?: number; + openerTabId?: number; + url?: string; + pinned?: boolean; + windowId?: number; + active?: boolean; + } - interface MoveProperties { - index: number; - windowId?: number; - } + interface MoveProperties { + index: number; + windowId?: number; + } - interface UpdateProperties { - pinned?: boolean; - openerTabId?: number; - url?: string; - highlighted?: boolean; - active?: boolean; - } + interface UpdateProperties { + pinned?: boolean; + openerTabId?: number; + url?: string; + highlighted?: boolean; + active?: boolean; + } - interface CaptureVisibleTabOptions { - quality?: number; - format?: string; - } + interface CaptureVisibleTabOptions { + quality?: number; + format?: string; + } - interface ReloadProperties { - bypassCache?: boolean; - } + interface ReloadProperties { + bypassCache?: boolean; + } - interface ConnectInfo { - name?: string; - } + interface ConnectInfo { + name?: string; + } - interface HighlightInfo { - tabs: number[]; - windowId?: number; - } + interface HighlightInfo { + tabs: number[]; + windowId?: number; + } - interface QueryInfo { - status?: string; - lastFocusedWindow?: boolean; - windowId?: number; - windowType?: string; - active?: boolean; - index?: number; - title?: string; - url?: string | string[]; - currentWindow?: boolean; - highlighted?: boolean; - pinned?: boolean; - } + interface QueryInfo { + status?: string; + lastFocusedWindow?: boolean; + windowId?: number; + windowType?: string; + active?: boolean; + index?: number; + title?: string; + url?: string | string[]; + currentWindow?: boolean; + highlighted?: boolean; + pinned?: boolean; + } - interface TabHighlightInfo { - windowId: number; - tabIds: number[]; - } + interface TabHighlightInfo { + windowId: number; + tabIds: number[]; + } - interface TabRemoveInfo { - windowId: number; - isWindowClosing: boolean; - } + interface TabRemoveInfo { + windowId: number; + isWindowClosing: boolean; + } - interface TabAttachInfo { - newPosition: number; - newWindowId: number; - } + interface TabAttachInfo { + newPosition: number; + newWindowId: number; + } - interface TabChangeInfo { - status?: string; - pinned?: boolean; - url?: string; - } + interface TabChangeInfo { + status?: string; + pinned?: boolean; + url?: string; + } - interface TabMoveInfo { - toIndex: number; - windowId: number; - fromIndex: number; - } + interface TabMoveInfo { + toIndex: number; + windowId: number; + fromIndex: number; + } - interface TabDetachInfo { - oldWindowId: number; - oldPosition: number; - } + interface TabDetachInfo { + oldWindowId: number; + oldPosition: number; + } - interface TabActiveInfo { - tabId: number; - windowId: number; - } + interface TabActiveInfo { + tabId: number; + windowId: number; + } - interface TabHighlightedEvent extends chrome.events.Event { - addListener(callback: (highlightInfo: HighlightInfo) => void): void; - } + interface TabHighlightedEvent extends chrome.events.Event { + addListener(callback: (highlightInfo: HighlightInfo) => void): void; + } - interface TabRemovedEvent extends chrome.events.Event { - addListener(callback: (tabId: number, removeInfo: TabRemoveInfo) => void): void; - } + interface TabRemovedEvent extends chrome.events.Event { + addListener(callback: (tabId: number, removeInfo: TabRemoveInfo) => void): void; + } - interface TabUpdatedEvent extends chrome.events.Event { - addListener(callback: (tabId: number, changeInfo: TabChangeInfo, tab: Tab) => void): void; - } + interface TabUpdatedEvent extends chrome.events.Event { + addListener(callback: (tabId: number, changeInfo: TabChangeInfo, tab: Tab) => void): void; + } - interface TabAttachedEvent extends chrome.events.Event { - addListener(callback: (tabId: number, attachInfo: TabAttachInfo) => void): void; - } + interface TabAttachedEvent extends chrome.events.Event { + addListener(callback: (tabId: number, attachInfo: TabAttachInfo) => void): void; + } - interface TabMovedEvent extends chrome.events.Event { - addListener(callback: (tabId: number, moveInfo: TabMoveInfo) => void): void; - } + interface TabMovedEvent extends chrome.events.Event { + addListener(callback: (tabId: number, moveInfo: TabMoveInfo) => void): void; + } - interface TabDetachedEvent extends chrome.events.Event { - addListener(callback: (tabId: number, detachInfo: TabDetachInfo) => void): void; - } + interface TabDetachedEvent extends chrome.events.Event { + addListener(callback: (tabId: number, detachInfo: TabDetachInfo) => void): void; + } - interface TabCreatedEvent extends chrome.events.Event { - addListener(callback: (tab: Tab) => void): void; - } + interface TabCreatedEvent extends chrome.events.Event { + addListener(callback: (tab: Tab) => void): void; + } - interface TabActivatedEvent extends chrome.events.Event { - addListener(callback: (activeInfo: TabActiveInfo) => void): void; - } + interface TabActivatedEvent extends chrome.events.Event { + addListener(callback: (activeInfo: TabActiveInfo) => void): void; + } - interface TabReplacedEvent extends chrome.events.Event { - addListener(callback: (addedTabId: number, removedTabId: number) => void): void; - } + interface TabReplacedEvent extends chrome.events.Event { + addListener(callback: (addedTabId: number, removedTabId: number) => void): void; + } - export function executeScript(details: InjectDetails, callback?: (result: any[]) => void): void; - export function executeScript(tabId: number, details: InjectDetails, callback?: (result: any[]) => void): void; - export function get(tabId: number, callback: (tab: Tab) => void): void; - export function getCurrent(callback: (tab?: Tab) => void): void; - export function create(createProperties: CreateProperties, callback?: (tab: Tab) => void): void; - export function move(tabId: number, moveProperties: MoveProperties, callback?: (tab: Tab) => void): void; - export function move(tabIds: number[], moveProperties: MoveProperties, callback?: (tabs: Tab[]) => void): void; - export function update(updateProperties: UpdateProperties, callback?: (tab?: Tab) => void): void; - export function update(tabId: number, updateProperties: UpdateProperties, callback?: (tab?: Tab) => void): void; - export function remove(tabId: number, callback?: Function): void; - export function remove(tabIds: number[], callback?: Function): void; - export function captureVisibleTab(callback: (dataUrl: string) => void): void; - export function captureVisibleTab(windowId: number, callback: (dataUrl: string) => void): void; - export function captureVisibleTab(options: CaptureVisibleTabOptions, callback: (dataUrl: string) => void): void; - export function captureVisibleTab(windowId: number, options: CaptureVisibleTabOptions, callback: (dataUrl: string) => void): void; - export function reload(tabId?: number, reloadProperties?: ReloadProperties, func?: Function): void; - export function duplicate(tabId: number, callback?: (tab?: Tab) => void): void; - export function sendMessage(tabId: number, message: any, responseCallback?: (response: any) => void): void; - export function connect(tabId: number, connectInfo?: ConnectInfo): runtime.Port; - export function insertCSS(tabId: number, details: InjectDetails, callback?: Function): void; - export function highlight(highlightInfo: HighlightInfo, callback: (window: chrome.windows.Window) => void): void; - export function query(queryInfo: QueryInfo, callback: (result: Tab[]) => void): void; - export function detectLanguage(callback: (language: string) => void): void; - export function detectLanguage(tabId: number, callback: (language: string) => void): void; + export function executeScript(details: InjectDetails, callback?: (result: any[]) => void): void; + export function executeScript(tabId: number, details: InjectDetails, callback?: (result: any[]) => void): void; + export function get(tabId: number, callback: (tab: Tab) => void): void; + export function getCurrent(callback: (tab?: Tab) => void): void; + export function create(createProperties: CreateProperties, callback?: (tab: Tab) => void): void; + export function move(tabId: number, moveProperties: MoveProperties, callback?: (tab: Tab) => void): void; + export function move(tabIds: number[], moveProperties: MoveProperties, callback?: (tabs: Tab[]) => void): void; + export function update(updateProperties: UpdateProperties, callback?: (tab?: Tab) => void): void; + export function update(tabId: number, updateProperties: UpdateProperties, callback?: (tab?: Tab) => void): void; + export function remove(tabId: number, callback?: Function): void; + export function remove(tabIds: number[], callback?: Function): void; + export function captureVisibleTab(callback: (dataUrl: string) => void): void; + export function captureVisibleTab(windowId: number, callback: (dataUrl: string) => void): void; + export function captureVisibleTab(options: CaptureVisibleTabOptions, callback: (dataUrl: string) => void): void; + export function captureVisibleTab(windowId: number, options: CaptureVisibleTabOptions, callback: (dataUrl: string) => void): void; + export function reload(tabId?: number, reloadProperties?: ReloadProperties, func?: Function): void; + export function duplicate(tabId: number, callback?: (tab?: Tab) => void): void; + export function sendMessage(tabId: number, message: any, responseCallback?: (response: any) => void): void; + export function connect(tabId: number, connectInfo?: ConnectInfo): runtime.Port; + export function insertCSS(tabId: number, details: InjectDetails, callback?: Function): void; + export function highlight(highlightInfo: HighlightInfo, callback: (window: chrome.windows.Window) => void): void; + export function query(queryInfo: QueryInfo, callback: (result: Tab[]) => void): void; + export function detectLanguage(callback: (language: string) => void): void; + export function detectLanguage(tabId: number, callback: (language: string) => void): void; - var onHighlighted: TabHighlightedEvent; - var onRemoved: TabRemovedEvent; - var onUpdated: TabUpdatedEvent; - var onAttached: TabAttachedEvent; - var onMoved: TabMovedEvent; - var onDetached: TabDetachedEvent; - var onCreated: TabCreatedEvent; - var onActivated: TabActivatedEvent; - var onReplaced: TabReplacedEvent; + var onHighlighted: TabHighlightedEvent; + var onRemoved: TabRemovedEvent; + var onUpdated: TabUpdatedEvent; + var onAttached: TabAttachedEvent; + var onMoved: TabMovedEvent; + var onDetached: TabDetachedEvent; + var onCreated: TabCreatedEvent; + var onActivated: TabActivatedEvent; + var onReplaced: TabReplacedEvent; } //////////////////// // Top Sites //////////////////// declare module chrome.topSites { - interface MostVisitedURL { - url: string; - title: string; - } + interface MostVisitedURL { + url: string; + title: string; + } - export function get(callback: (data: MostVisitedURL) => void): void; + export function get(callback: (data: MostVisitedURL) => void): void; } //////////////////// // Text to Speech //////////////////// declare module chrome.tts { - interface TtsEvent { - charIndex?: number; - errorMessage?: string; - type: string; - } + interface TtsEvent { + charIndex?: number; + errorMessage?: string; + type: string; + } - interface TtsVoice { - lang?: string; - gender?: string; - voiceName?: string; - extensionsId?: string; - eventTypes?: string[]; - } + interface TtsVoice { + lang?: string; + gender?: string; + voiceName?: string; + extensionsId?: string; + eventTypes?: string[]; + } - interface SpeakOptions { - volume?: number; - enqueue?: boolean; - rate?: number; - onEvent?: (event: TtsEvent) => void; - pitch?: number; - lang?: string; - voiceName?: string; - extensionId?: string; - gender?: string; - requiredEventTypes?: string[]; - desiredEventTypes?: string[]; - } + interface SpeakOptions { + volume?: number; + enqueue?: boolean; + rate?: number; + onEvent?: (event: TtsEvent) => void; + pitch?: number; + lang?: string; + voiceName?: string; + extensionId?: string; + gender?: string; + requiredEventTypes?: string[]; + desiredEventTypes?: string[]; + } - export function isSpeaking(callback?: (speaking: boolean) => void): void; - export function stop(): void; - export function getVoices(callback?: (voices: TtsVoice[]) => void): void; - export function speak(utterance: string, options?: SpeakOptions, callback?: Function): void; + export function isSpeaking(callback?: (speaking: boolean) => void): void; + export function stop(): void; + export function getVoices(callback?: (voices: TtsVoice[]) => void): void; + export function speak(utterance: string, options?: SpeakOptions, callback?: Function): void; } //////////////////// // Text to Speech Engine //////////////////// declare module chrome.ttsEngine { - interface SpeakOptions { - lang?: string; - voiceName?: string; - gender?: string; - volume?: number; - rate?: number; - pitch?: number; - } + interface SpeakOptions { + lang?: string; + voiceName?: string; + gender?: string; + volume?: number; + rate?: number; + pitch?: number; + } - interface TtsEngineSpeakEvent extends chrome.events.Event { - addListener(callback: (utterance: string, options: SpeakOptions, sendTtsEvent: (event: chrome.tts.TtsEvent) => void) => void): void; - } + interface TtsEngineSpeakEvent extends chrome.events.Event { + addListener(callback: (utterance: string, options: SpeakOptions, sendTtsEvent: (event: chrome.tts.TtsEvent) => void) => void): void; + } - interface TtsEngineStopEvent extends chrome.events.Event { - addListener(callback: Function): void; - } + interface TtsEngineStopEvent extends chrome.events.Event { + addListener(callback: Function): void; + } - var onSpeak: TtsEngineSpeakEvent; - var onStop: TtsEngineStopEvent; + var onSpeak: TtsEngineSpeakEvent; + var onStop: TtsEngineStopEvent; } //////////////////// // Types //////////////////// declare module chrome.types { - interface ChromeSettingClearDetails { - scope?: string; - } + interface ChromeSettingClearDetails { + scope?: string; + } - interface ChromeSettingSetDetails extends ChromeSettingClearDetails { - value: any; - } + interface ChromeSettingSetDetails extends ChromeSettingClearDetails { + value: any; + } - interface ChromeSettingGetDetails { - incognito?: boolean; - } + interface ChromeSettingGetDetails { + incognito?: boolean; + } - type DetailsCallback = (details: ChromeSettingGetResultDetails) => void; + type DetailsCallback = (details: ChromeSettingGetResultDetails) => void; - interface ChromeSettingGetResultDetails { - levelOfControl: string; - value: any; - incognitoSpecific?: boolean; - } + interface ChromeSettingGetResultDetails { + levelOfControl: string; + value: any; + incognitoSpecific?: boolean; + } - interface ChromeSettingChangedEvent extends chrome.events.Event { - addListener(callback: DetailsCallback): void; - } + interface ChromeSettingChangedEvent extends chrome.events.Event { + addListener(callback: DetailsCallback): void; + } - interface ChromeSetting { - details: { - scope?: string; - callback?: Function; - }; - set(details: ChromeSettingSetDetails, callback?: Function): void; - get(details: ChromeSettingGetDetails, callback?: DetailsCallback): void; - clear(details: ChromeSettingClearDetails, callback?: Function): void; - onChange: ChromeSettingChangedEvent; - } + interface ChromeSetting { + details: { + scope?: string; + callback?: Function; + }; + set(details: ChromeSettingSetDetails, callback?: Function): void; + get(details: ChromeSettingGetDetails, callback?: DetailsCallback): void; + clear(details: ChromeSettingClearDetails, callback?: Function): void; + onChange: ChromeSettingChangedEvent; + } } //////////////////// // Web Navigation //////////////////// declare module chrome.webNavigation { - interface GetFrameDetails { - processId: number; - tabId: number; - frameId: number; - } + interface GetFrameDetails { + processId: number; + tabId: number; + frameId: number; + } - interface GetFrameResultDetails { - url: string; - errorOccurred: boolean; - parentFrameId: number; - } + interface GetFrameResultDetails { + url: string; + errorOccurred: boolean; + parentFrameId: number; + } - interface GetAllFrameDetails { - tabId: number; - } + interface GetAllFrameDetails { + tabId: number; + } - interface GetAllFrameResultDetails extends GetFrameResultDetails { - processId: number; - frameId: number; - } + interface GetAllFrameResultDetails extends GetFrameResultDetails { + processId: number; + frameId: number; + } - interface CallbackBasicDetails { - tabId: number; - timeStamp: number; - } + interface CallbackBasicDetails { + tabId: number; + timeStamp: number; + } - interface CallbackDetails extends CallbackBasicDetails { - processId: number; - url: string; - frameId: number; - } + interface CallbackDetails extends CallbackBasicDetails { + processId: number; + url: string; + frameId: number; + } - interface CallbackTransitionDetails extends CallbackDetails { - transitionType: string; - transitionQualifiers: string[]; - } + interface CallbackTransitionDetails extends CallbackDetails { + transitionType: string; + transitionQualifiers: string[]; + } - interface ReferenceFragmentUpdatedDetails extends CallbackTransitionDetails { - } + interface ReferenceFragmentUpdatedDetails extends CallbackTransitionDetails { + } - interface CompletedDetails extends CallbackDetails { - } + interface CompletedDetails extends CallbackDetails { + } - interface HistoryStateUpdatedDetails extends CallbackTransitionDetails { - } + interface HistoryStateUpdatedDetails extends CallbackTransitionDetails { + } - interface CreatedNavigationTargetDetails extends CallbackBasicDetails { - url: string; - sourceTabId: number; - sourceProcessId: number; - sourceFrameId: number; - } + interface CreatedNavigationTargetDetails extends CallbackBasicDetails { + url: string; + sourceTabId: number; + sourceProcessId: number; + sourceFrameId: number; + } - interface TabReplacedDetails extends CallbackBasicDetails { - replacedTabId: number; - } + interface TabReplacedDetails extends CallbackBasicDetails { + replacedTabId: number; + } - interface BeforeNavigateDetails extends CallbackDetails { - parentFrameId: number; - } + interface BeforeNavigateDetails extends CallbackDetails { + parentFrameId: number; + } - interface CommittedDetails extends CallbackTransitionDetails { - } + interface CommittedDetails extends CallbackTransitionDetails { + } - interface DomContentLoadedDetails extends CallbackDetails { - } + interface DomContentLoadedDetails extends CallbackDetails { + } - interface ErrorOccurredDetails extends CallbackDetails { - error: string; - } + interface ErrorOccurredDetails extends CallbackDetails { + error: string; + } - interface WebNavigationEventFilters { - url: chrome.events.UrlFilter[]; - } + interface WebNavigationEventFilters { + url: chrome.events.UrlFilter[]; + } - interface WebNavigationReferenceFragmentUpdatedEvent extends chrome.events.Event { - addListener(callback: (details: ReferenceFragmentUpdatedDetails) => void, filters?: WebNavigationEventFilters): void; - } + interface WebNavigationReferenceFragmentUpdatedEvent extends chrome.events.Event { + addListener(callback: (details: ReferenceFragmentUpdatedDetails) => void, filters?: WebNavigationEventFilters): void; + } - interface WebNavigationCompletedEvent extends chrome.events.Event { - addListener(callback: (details: CompletedDetails) => void, filters?: WebNavigationEventFilters): void; - } + interface WebNavigationCompletedEvent extends chrome.events.Event { + addListener(callback: (details: CompletedDetails) => void, filters?: WebNavigationEventFilters): void; + } - interface WebNavigationHistoryStateUpdatedEvent extends chrome.events.Event { - addListener(callback: (details: HistoryStateUpdatedDetails) => void, filters?: WebNavigationEventFilters): void; - } + interface WebNavigationHistoryStateUpdatedEvent extends chrome.events.Event { + addListener(callback: (details: HistoryStateUpdatedDetails) => void, filters?: WebNavigationEventFilters): void; + } - interface WebNavigationCreatedNavigationTargetEvent extends chrome.events.Event { - addListener(callback: (details: CreatedNavigationTargetDetails) => void, filters?: WebNavigationEventFilters): void; - } + interface WebNavigationCreatedNavigationTargetEvent extends chrome.events.Event { + addListener(callback: (details: CreatedNavigationTargetDetails) => void, filters?: WebNavigationEventFilters): void; + } - interface WebNavigationTabReplacedEvent extends chrome.events.Event { - addListener(callback: (details: TabReplacedDetails) => void): void; - } + interface WebNavigationTabReplacedEvent extends chrome.events.Event { + addListener(callback: (details: TabReplacedDetails) => void): void; + } - interface WebNavigationBeforeNavigateEvent extends chrome.events.Event { - addListener(callback: (details: BeforeNavigateDetails) => void, filters?: WebNavigationEventFilters): void; - } + interface WebNavigationBeforeNavigateEvent extends chrome.events.Event { + addListener(callback: (details: BeforeNavigateDetails) => void, filters?: WebNavigationEventFilters): void; + } - interface WebNavigationCommittedEvent extends chrome.events.Event { - addListener(callback: (details: CommittedDetails) => void, filters?: WebNavigationEventFilters): void; - } + interface WebNavigationCommittedEvent extends chrome.events.Event { + addListener(callback: (details: CommittedDetails) => void, filters?: WebNavigationEventFilters): void; + } - interface WebNavigationDomContentLoadedEvent extends chrome.events.Event { - addListener(callback: (details: DomContentLoadedDetails) => void, filters?: WebNavigationEventFilters): void; - } + interface WebNavigationDomContentLoadedEvent extends chrome.events.Event { + addListener(callback: (details: DomContentLoadedDetails) => void, filters?: WebNavigationEventFilters): void; + } - interface WebNavigationErrorOccurredEvent extends chrome.events.Event { - addListener(callback: (details: ErrorOccurredDetails) => void, filters?: WebNavigationEventFilters): void; - } + interface WebNavigationErrorOccurredEvent extends chrome.events.Event { + addListener(callback: (details: ErrorOccurredDetails) => void, filters?: WebNavigationEventFilters): void; + } - export function getFrame(details: GetFrameDetails, callback: (details?: GetFrameResultDetails) => void): void; - export function getAllFrames(details: GetAllFrameDetails, callback: (details?: GetAllFrameResultDetails[]) => void): void; + export function getFrame(details: GetFrameDetails, callback: (details?: GetFrameResultDetails) => void): void; + export function getAllFrames(details: GetAllFrameDetails, callback: (details?: GetAllFrameResultDetails[]) => void): void; - var onReferenceFragmentUpdated: WebNavigationReferenceFragmentUpdatedEvent; - var onCompleted: WebNavigationCompletedEvent; - var onHistoryStateUpdated: WebNavigationHistoryStateUpdatedEvent; - var onCreatedNavigationTarget: WebNavigationCreatedNavigationTargetEvent; - var onTabReplaced: WebNavigationTabReplacedEvent; - var onBeforeNavigate: WebNavigationBeforeNavigateEvent; - var onCommitted: WebNavigationCommittedEvent; - var onDOMContentLoaded: WebNavigationDomContentLoadedEvent; - var onErrorOccurred: WebNavigationErrorOccurredEvent; + var onReferenceFragmentUpdated: WebNavigationReferenceFragmentUpdatedEvent; + var onCompleted: WebNavigationCompletedEvent; + var onHistoryStateUpdated: WebNavigationHistoryStateUpdatedEvent; + var onCreatedNavigationTarget: WebNavigationCreatedNavigationTargetEvent; + var onTabReplaced: WebNavigationTabReplacedEvent; + var onBeforeNavigate: WebNavigationBeforeNavigateEvent; + var onCommitted: WebNavigationCommittedEvent; + var onDOMContentLoaded: WebNavigationDomContentLoadedEvent; + var onErrorOccurred: WebNavigationErrorOccurredEvent; } //////////////////// // Web Request //////////////////// declare module chrome.webRequest { - interface AuthCredentials { - username: string; - password: string; - } + interface AuthCredentials { + username: string; + password: string; + } - interface HttpHeader { - name: string; - value?: string; - binaryValue?: ArrayBuffer; - } + interface HttpHeader { + name: string; + value?: string; + binaryValue?: ArrayBuffer; + } - interface BlockingResponse { - cancel?: boolean; - redirectUrl?: string; - responseHeaders?: HttpHeader[]; - authCredentials?: AuthCredentials; - requestHeaders?: HttpHeader[]; - } + interface BlockingResponse { + cancel?: boolean; + redirectUrl?: string; + responseHeaders?: HttpHeader[]; + authCredentials?: AuthCredentials; + requestHeaders?: HttpHeader[]; + } - interface RequestFilter { - tabId?: number; - types?: string[]; - urls: string[]; - windowId?: number; - } + interface RequestFilter { + tabId?: number; + types?: string[]; + urls: string[]; + windowId?: number; + } - interface UploadData { - bytes?: ArrayBuffer; - file?: string; - } + interface UploadData { + bytes?: ArrayBuffer; + file?: string; + } - interface CallbackDetails { - requestId: string; - url: string; - method: string; - tabId: number; - frameId: number; - parentFrameId: number; - timeStamp: number; - type: string; - } + interface CallbackDetails { + requestId: string; + url: string; + method: string; + tabId: number; + frameId: number; + parentFrameId: number; + timeStamp: number; + type: string; + } - interface OnCompletedDetails extends CallbackDetails { - ip?: string; - statusLine: string; - responseHeaders?: HttpHeader[]; - fromCache: boolean; - statusCode: number; - } + interface OnCompletedDetails extends CallbackDetails { + ip?: string; + statusLine: string; + responseHeaders?: HttpHeader[]; + fromCache: boolean; + statusCode: number; + } - interface OnHeadersReceivedDetails extends CallbackDetails { - statusLine: string; - responseHeaders?: HttpHeader[]; - } + interface OnHeadersReceivedDetails extends CallbackDetails { + statusLine: string; + responseHeaders?: HttpHeader[]; + } - interface OnBeforeRedirectDetails extends CallbackDetails { - ip?: string; - statusLine: string; - responseHeaders?: HttpHeader[]; - fromCache: boolean; - redirectUrl: string; - statusCode: number; - } + interface OnBeforeRedirectDetails extends CallbackDetails { + ip?: string; + statusLine: string; + responseHeaders?: HttpHeader[]; + fromCache: boolean; + redirectUrl: string; + statusCode: number; + } - interface Challenger { - host: string; - port: number; - } + interface Challenger { + host: string; + port: number; + } - interface OnAuthRequiredDetails extends CallbackDetails { - statusLine: string; - challenger: Challenger; - responseHeaders?: HttpHeader[]; - isProxy: boolean; - realm?: string; - scheme: string; - } + interface OnAuthRequiredDetails extends CallbackDetails { + statusLine: string; + challenger: Challenger; + responseHeaders?: HttpHeader[]; + isProxy: boolean; + realm?: string; + scheme: string; + } - interface OnBeforeSendHeadersDetails extends CallbackDetails { - requestHeaders?: HttpHeader[]; - } + interface OnBeforeSendHeadersDetails extends CallbackDetails { + requestHeaders?: HttpHeader[]; + } - interface OnErrorOccurredDetails extends CallbackDetails { - ip?: string; - fromCache: boolean; - error: string; - } + interface OnErrorOccurredDetails extends CallbackDetails { + ip?: string; + fromCache: boolean; + error: string; + } - interface OnResponseStartedDetails extends CallbackDetails { - ip?: string; - statusLine: string; - responseHeaders?: HttpHeader[]; - fromCache: boolean; - statusCode: number; - } + interface OnResponseStartedDetails extends CallbackDetails { + ip?: string; + statusLine: string; + responseHeaders?: HttpHeader[]; + fromCache: boolean; + statusCode: number; + } - interface OnSendHeadersDetails extends CallbackDetails { - requestHeaders?: HttpHeader[]; - } + interface OnSendHeadersDetails extends CallbackDetails { + requestHeaders?: HttpHeader[]; + } - interface FormData { - [key: string]: string[]; - } + interface FormData { + [key: string]: string[]; + } - interface RequestBody { - raw?: UploadData[]; - error?: string; - formData?: FormData; - } + interface RequestBody { + raw?: UploadData[]; + error?: string; + formData?: FormData; + } - interface OnBeforeRequestDetails extends CallbackDetails { - requestBody?: RequestBody; - } + interface OnBeforeRequestDetails extends CallbackDetails { + requestBody?: RequestBody; + } - interface WebRequestCompletedEvent extends chrome.events.Event { - addListener(callback: (details: OnCompletedDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; - removeListener(callback: (details: OnCompletedDetails) => BlockingResponse): void; - } + interface WebRequestCompletedEvent extends chrome.events.Event { + addListener(callback: (details: OnCompletedDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; + removeListener(callback: (details: OnCompletedDetails) => BlockingResponse): void; + } - interface WebRequestHeadersReceivedEvent extends chrome.events.Event { - addListener(callback: (details: OnHeadersReceivedDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; - removeListener(callback: (details: OnHeadersReceivedDetails) => BlockingResponse): void; - } + interface WebRequestHeadersReceivedEvent extends chrome.events.Event { + addListener(callback: (details: OnHeadersReceivedDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; + removeListener(callback: (details: OnHeadersReceivedDetails) => BlockingResponse): void; + } - interface WebRequestBeforeRedirectEvent extends chrome.events.Event { - addListener(callback: (details: OnBeforeRedirectDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; - removeListener(callback: (details: OnBeforeRedirectDetails) => BlockingResponse): void; - } + interface WebRequestBeforeRedirectEvent extends chrome.events.Event { + addListener(callback: (details: OnBeforeRedirectDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; + removeListener(callback: (details: OnBeforeRedirectDetails) => BlockingResponse): void; + } - interface WebRequestAuthRequiredEvent extends chrome.events.Event { - addListener(callback: (details: OnAuthRequiredDetails, callback?: (response: BlockingResponse) => void) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; - removeListener(callback: (details: OnAuthRequiredDetails, callback?: (response: BlockingResponse) => void) => void): void; - } + interface WebRequestAuthRequiredEvent extends chrome.events.Event { + addListener(callback: (details: OnAuthRequiredDetails, callback?: (response: BlockingResponse) => void) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; + removeListener(callback: (details: OnAuthRequiredDetails, callback?: (response: BlockingResponse) => void) => void): void; + } - interface WebRequestBeforeSendHeadersEvent extends chrome.events.Event { - addListener(callback: (details: OnBeforeSendHeadersDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; - removeListener(callback: (details: OnBeforeSendHeadersDetails) => BlockingResponse): void; - } + interface WebRequestBeforeSendHeadersEvent extends chrome.events.Event { + addListener(callback: (details: OnBeforeSendHeadersDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; + removeListener(callback: (details: OnBeforeSendHeadersDetails) => BlockingResponse): void; + } - interface WebRequestErrorOccurredEvent extends chrome.events.Event { - addListener(callback: (details: OnErrorOccurredDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; - removeListener(callback: (details: OnErrorOccurredDetails) => BlockingResponse): void; - } + interface WebRequestErrorOccurredEvent extends chrome.events.Event { + addListener(callback: (details: OnErrorOccurredDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; + removeListener(callback: (details: OnErrorOccurredDetails) => BlockingResponse): void; + } - interface WebRequestResponseStartedEvent extends chrome.events.Event { - addListener(callback: (details: OnResponseStartedDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; - removeListener(callback: (details: OnResponseStartedDetails) => BlockingResponse): void; - } + interface WebRequestResponseStartedEvent extends chrome.events.Event { + addListener(callback: (details: OnResponseStartedDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; + removeListener(callback: (details: OnResponseStartedDetails) => BlockingResponse): void; + } - interface WebRequestSendHeadersEvent extends chrome.events.Event { - addListener(callback: (details: OnSendHeadersDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; - removeListener(callback: (details: OnSendHeadersDetails) => BlockingResponse): void; - } + interface WebRequestSendHeadersEvent extends chrome.events.Event { + addListener(callback: (details: OnSendHeadersDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; + removeListener(callback: (details: OnSendHeadersDetails) => BlockingResponse): void; + } - interface WebRequestBeforeRequestEvent extends chrome.events.Event { - addListener(callback: (details: OnBeforeRequestDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; - removeListener(callback: (details: OnBeforeRequestDetails) => BlockingResponse): void; - } + interface WebRequestBeforeRequestEvent extends chrome.events.Event { + addListener(callback: (details: OnBeforeRequestDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; + removeListener(callback: (details: OnBeforeRequestDetails) => BlockingResponse): void; + } - var MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES: number; + var MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES: number; - export function handlerBehaviorChanged(callback?: Function): void; + export function handlerBehaviorChanged(callback?: Function): void; - var onCompleted: WebRequestCompletedEvent; - var onHeadersReceived: WebRequestHeadersReceivedEvent; - var onBeforeRedirect: WebRequestBeforeRedirectEvent; - var onAuthRequired: WebRequestAuthRequiredEvent; - var onBeforeSendHeaders: WebRequestBeforeSendHeadersEvent; - var onErrorOccurred: WebRequestErrorOccurredEvent; - var onResponseStarted: WebRequestResponseStartedEvent; - var onSendHeaders: WebRequestSendHeadersEvent; - var onBeforeRequest: WebRequestBeforeRequestEvent; + var onCompleted: WebRequestCompletedEvent; + var onHeadersReceived: WebRequestHeadersReceivedEvent; + var onBeforeRedirect: WebRequestBeforeRedirectEvent; + var onAuthRequired: WebRequestAuthRequiredEvent; + var onBeforeSendHeaders: WebRequestBeforeSendHeadersEvent; + var onErrorOccurred: WebRequestErrorOccurredEvent; + var onResponseStarted: WebRequestResponseStartedEvent; + var onSendHeaders: WebRequestSendHeadersEvent; + var onBeforeRequest: WebRequestBeforeRequestEvent; } //////////////////// // Web Store //////////////////// declare module chrome.webstore { - export function install(url?: string, successCallback?: Function, failureCallback?: (error: string) => void): void; + export function install(url?: string, successCallback?: Function, failureCallback?: (error: string) => void): void; } //////////////////// // Windows //////////////////// declare module chrome.windows { - interface Window { - tabs?: chrome.tabs.Tab[]; - top: number; - height: number; - width: number; - state: string; - focused: boolean; - alwaysOnTop: boolean; - incognito: boolean; - type: string; - id: number; - left: number; - } + interface Window { + tabs?: chrome.tabs.Tab[]; + top: number; + height: number; + width: number; + state: string; + focused: boolean; + alwaysOnTop: boolean; + incognito: boolean; + type: string; + id: number; + left: number; + } - interface GetInfo { - populate?: boolean; - } + interface GetInfo { + populate?: boolean; + } - interface CreateData { - tabId?: number; - url?: string; - top?: number; - height?: number; - width?: number; - focused?: boolean; - incognito?: boolean; - type?: string; - left?: number; - } + interface CreateData { + tabId?: number; + url?: string; + top?: number; + height?: number; + width?: number; + focused?: boolean; + incognito?: boolean; + type?: string; + left?: number; + } - interface UpdateInfo { - top?: number; - drawAttention?: boolean; - height?: number; - width?: number; - state?: string; - focused?: boolean; - left?: number; - } + interface UpdateInfo { + top?: number; + drawAttention?: boolean; + height?: number; + width?: number; + state?: string; + focused?: boolean; + left?: number; + } - interface WindowRemovedEvent extends chrome.events.Event { - addListener(callback: (windowId: number) => void): void; - } + interface WindowRemovedEvent extends chrome.events.Event { + addListener(callback: (windowId: number) => void): void; + } - interface WindowCreatedEvent extends chrome.events.Event { - addListener(callback: (window: Window) => void): void; - } + interface WindowCreatedEvent extends chrome.events.Event { + addListener(callback: (window: Window) => void): void; + } - interface WindowFocusChangedEvent extends chrome.events.Event { - addListener(callback: (windowId: number) => void): void; - } + interface WindowFocusChangedEvent extends chrome.events.Event { + addListener(callback: (windowId: number) => void): void; + } - var WINDOW_ID_CURRENT: number; - var WINDOW_ID_NONE: number; + var WINDOW_ID_CURRENT: number; + var WINDOW_ID_NONE: number; - export function get(windowId: number, callback: (window: chrome.windows.Window) => void): void; - export function get(windowId: number, getInfo: GetInfo, callback: (window: chrome.windows.Window) => void): void; - export function getCurrent(callback: (window: chrome.windows.Window) => void): void; - export function getCurrent(getInfo: GetInfo, callback: (window: chrome.windows.Window) => void): void; - export function create(createData?: CreateData, callback?: (window: chrome.windows.Window) => void): void; - export function getAll(callback: (windows: chrome.windows.Window[]) => void): void; - export function getAll(getInfo: GetInfo, callback: (windows: chrome.windows.Window[]) => void): void; - export function update(windowId: number, updateInfo: UpdateInfo, callback?: (window: chrome.windows.Window) => void): void; - export function remove(windowId: number, callback?: Function): void; - export function getLastFocused(callback: (window: chrome.windows.Window) => void): void; - export function getLastFocused(getInfo: GetInfo, callback: (window: chrome.windows.Window) => void): void; + export function get(windowId: number, callback: (window: chrome.windows.Window) => void): void; + export function get(windowId: number, getInfo: GetInfo, callback: (window: chrome.windows.Window) => void): void; + export function getCurrent(callback: (window: chrome.windows.Window) => void): void; + export function getCurrent(getInfo: GetInfo, callback: (window: chrome.windows.Window) => void): void; + export function create(createData?: CreateData, callback?: (window: chrome.windows.Window) => void): void; + export function getAll(callback: (windows: chrome.windows.Window[]) => void): void; + export function getAll(getInfo: GetInfo, callback: (windows: chrome.windows.Window[]) => void): void; + export function update(windowId: number, updateInfo: UpdateInfo, callback?: (window: chrome.windows.Window) => void): void; + export function remove(windowId: number, callback?: Function): void; + export function getLastFocused(callback: (window: chrome.windows.Window) => void): void; + export function getLastFocused(getInfo: GetInfo, callback: (window: chrome.windows.Window) => void): void; - var onRemoved: WindowRemovedEvent; - var onCreated: WindowCreatedEvent; - var onFocusChanged: WindowFocusChangedEvent; + var onRemoved: WindowRemovedEvent; + var onCreated: WindowCreatedEvent; + var onFocusChanged: WindowFocusChangedEvent; }