Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
8831 lines (8159 sloc) 441 KB
// Type definitions for Chrome extension development
// Project: http://developer.chrome.com/extensions/
// Definitions by: Matthew Kimber <https://github.com/matthewkimber>, otiai10 <https://github.com/otiai10>, couven92 <https://github.com/couven92>, RReverser <https://github.com/rreverser>, sreimer15 <https://github.com/sreimer15>, MatCarlson <https://github.com/MatCarlson>, ekinsol <https://github.com/ekinsol>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
/// <reference types="filesystem" />
////////////////////
// Global object
////////////////////
interface Window {
chrome: typeof chrome;
}
////////////////////
// Accessibility Features
////////////////////
/**
* Use the chrome.accessibilityFeatures API to manage Chrome's accessibility features. This API relies on the ChromeSetting prototype of the type API for getting and setting individual accessibility features. In order to get feature states the extension must request accessibilityFeatures.read permission. For modifying feature state, the extension needs accessibilityFeatures.modify permission. Note that accessibilityFeatures.modify does not imply accessibilityFeatures.read permission.
* Availability: Since Chrome 37.
* Permissions: "accessibilityFeatures.read"
* Important: This API works only on Chrome OS.
*/
declare namespace chrome.accessibilityFeatures {
export interface AccessibilityFeaturesGetArg {
/** Optional. Whether to return the value that applies to the incognito session (default false). */
incognito?: boolean;
}
export interface AccessibilityFeaturesCallbackArg {
/** The value of the setting. */
value: any;
/**
* One of
* • not_controllable: cannot be controlled by any extension
* • controlled_by_other_extensions: controlled by extensions with higher precedence
* • controllable_by_this_extension: can be controlled by this extension
* • controlled_by_this_extension: controlled by this extension
*/
levelOfControl: string;
/** Optional. Whether the effective value is specific to the incognito session. This property will only be present if the incognito property in the details parameter of get() was true. */
incognitoSpecific?: boolean;
}
export interface AccessibilityFeaturesSetArg {
/**
* The value of the setting.
* Note that every setting has a specific value type, which is described together with the setting. An extension should not set a value of a different type.
*/
value: any;
/**
* Optional.
* The scope of the ChromeSetting. One of
* • regular: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere),
* • regular_only: setting for the regular profile only (not inherited by the incognito profile),
* • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences),
* • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences).
*/
scope?: string;
}
export interface AccessibilityFeaturesClearArg {
/**
* Optional.
* The scope of the ChromeSetting. One of
* • regular: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere),
* • regular_only: setting for the regular profile only (not inherited by the incognito profile),
* • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences),
* • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences).
*/
scope?: string;
}
export interface AccessibilityFeaturesSetting {
/**
* Gets the value of a setting.
* @param details Which setting to consider.
* @param callback The callback parameter should be a function that looks like this:
* function(object details) {...};
*/
get(details: AccessibilityFeaturesGetArg, callback: (details: AccessibilityFeaturesCallbackArg) => void): void;
/**
* Sets the value of a setting.
* @param details Which setting to change.
* @param callback Called at the completion of the set operation.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
set(details: AccessibilityFeaturesSetArg, callback?: () => void): void;
/**
* Clears the setting, restoring any default value.
* @param details Which setting to clear.
* @param callback Called at the completion of the clear operation.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
clear(details: AccessibilityFeaturesClearArg, callback?: () => void): void;
}
export var spokenFeedback: AccessibilityFeaturesSetting;
export var largeCursor: AccessibilityFeaturesSetting;
export var stickyKeys: AccessibilityFeaturesSetting;
export var highContrast: AccessibilityFeaturesSetting;
export var screenMagnifier: AccessibilityFeaturesSetting;
export var autoclick: AccessibilityFeaturesSetting;
export var virtualKeyboard: AccessibilityFeaturesSetting;
export var animationPolicy: AccessibilityFeaturesSetting;
}
////////////////////
// Alarms
////////////////////
/**
* Use the chrome.alarms API to schedule code to run periodically or at a specified time in the future.
* Availability: Since Chrome 22.
* Permissions: "alarms"
*/
declare namespace chrome.alarms {
export interface AlarmCreateInfo {
/** Optional. Length of time in minutes after which the onAlarm event should fire. */
delayInMinutes?: number;
/** Optional. If set, the onAlarm event should fire every periodInMinutes minutes after the initial event specified by when or delayInMinutes. If not set, the alarm will only fire once. */
periodInMinutes?: number;
/** Optional. Time at which the alarm should fire, in milliseconds past the epoch (e.g. Date.now() + n). */
when?: number;
}
export interface Alarm {
/** Optional. If not null, the alarm is a repeating alarm and will fire again in periodInMinutes minutes. */
periodInMinutes?: number;
/** Time at which this alarm was scheduled to fire, in milliseconds past the epoch (e.g. Date.now() + n). For performance reasons, the alarm may have been delayed an arbitrary amount beyond this. */
scheduledTime: number;
/** Name of this alarm. */
name: string;
}
export interface AlarmEvent extends chrome.events.Event<(alarm: Alarm) => void> { }
/**
* Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.
* In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
* To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
* @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
*/
export function create(alarmInfo: AlarmCreateInfo): void;
/**
* Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.
* In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
* To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
* @param name Optional name to identify this alarm. Defaults to the empty string.
* @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
*/
export function create(name: string, alarmInfo: AlarmCreateInfo): void;
/**
* Gets an array of all the alarms.
* @param callback The callback parameter should be a function that looks like this:
* function(array of Alarm alarms) {...};
*/
export function getAll(callback: (alarms: Alarm[]) => void): void;
/**
* Clears all alarms.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function(boolean wasCleared) {...};
*/
export function clearAll(callback?: (wasCleared: boolean) => void): void;
/**
* Clears the alarm with the given name.
* @param name The name of the alarm to clear. Defaults to the empty string.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function(boolean wasCleared) {...};
*/
export function clear(name?: string, callback?: (wasCleared: boolean) => void): void;
/**
* Clears the alarm without a name.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function(boolean wasCleared) {...};
*/
export function clear(callback: (wasCleared: boolean) => void): void;
/**
* Retrieves details about the specified alarm.
* @param callback The callback parameter should be a function that looks like this:
* function( Alarm alarm) {...};
*/
export function get(callback: (alarm: Alarm) => void): void;
/**
* Retrieves details about the specified alarm.
* @param name The name of the alarm to get. Defaults to the empty string.
* @param callback The callback parameter should be a function that looks like this:
* function( Alarm alarm) {...};
*/
export function get(name: string, callback: (alarm: Alarm) => void): void;
/** Fired when an alarm has elapsed. Useful for event pages. */
export var onAlarm: AlarmEvent;
}
////////////////////
// Browser
////////////////////
/**
* Use the chrome.browser API to interact with the Chrome browser associated with
* the current application and Chrome profile.
*/
declare namespace chrome.browser {
export interface Options {
/** The URL to navigate to when the new tab is initially opened. */
url: string;
}
/**
* Opens a new tab in a browser window associated with the current application
* and Chrome profile. If no browser window for the Chrome profile is opened,
* a new one is opened prior to creating the new tab.
* @param options Configures how the tab should be opened.
* @param callback Called when the tab was successfully
* created, or failed to be created. If failed, runtime.lastError will be set.
*/
export function openTab(options: Options, callback: () => void): void;
/**
* Opens a new tab in a browser window associated with the current application
* and Chrome profile. If no browser window for the Chrome profile is opened,
* a new one is opened prior to creating the new tab. Since Chrome 42 only.
* @param options Configures how the tab should be opened.
*/
export function openTab(options: Options): void;
}
////////////////////
// Bookmarks
////////////////////
/**
* Use the chrome.bookmarks API to create, organize, and otherwise manipulate bookmarks. Also see Override Pages, which you can use to create a custom Bookmark Manager page.
* Availability: Since Chrome 5.
* Permissions: "bookmarks"
*/
declare namespace chrome.bookmarks {
/** A node (either a bookmark or a folder) in the bookmark tree. Child nodes are ordered within their parent folder. */
export interface BookmarkTreeNode {
/** Optional. The 0-based position of this node within its parent folder. */
index?: number;
/** Optional. When this node was created, in milliseconds since the epoch (new Date(dateAdded)). */
dateAdded?: number;
/** The text displayed for the node. */
title: string;
/** Optional. The URL navigated to when a user clicks the bookmark. Omitted for folders. */
url?: string;
/** Optional. When the contents of this folder last changed, in milliseconds since the epoch. */
dateGroupModified?: number;
/** The unique identifier for the node. IDs are unique within the current profile, and they remain valid even after the browser is restarted. */
id: string;
/** Optional. The id of the parent folder. Omitted for the root node. */
parentId?: string;
/** Optional. An ordered list of children of this node. */
children?: BookmarkTreeNode[];
/**
* Optional.
* Since Chrome 37.
* Indicates the reason why this node is unmodifiable. The managed value indicates that this node was configured by the system administrator or by the custodian of a supervised user. Omitted if the node can be modified by the user and the extension (default).
*/
unmodifiable?: any;
}
export interface BookmarkRemoveInfo {
index: number;
parentId: string;
node: BookmarkTreeNode;
}
export interface BookmarkMoveInfo {
index: number;
oldIndex: number;
parentId: string;
oldParentId: string;
}
export interface BookmarkChangeInfo {
url?: string;
title: string;
}
export interface BookmarkReorderInfo {
childIds: string[];
}
export interface BookmarkRemovedEvent extends chrome.events.Event<(id: string, removeInfo: BookmarkRemoveInfo) => void> { }
export interface BookmarkImportEndedEvent extends chrome.events.Event<() => void> { }
export interface BookmarkMovedEvent extends chrome.events.Event<(id: string, moveInfo: BookmarkMoveInfo) => void> { }
export interface BookmarkImportBeganEvent extends chrome.events.Event<() => void> { }
export interface BookmarkChangedEvent extends chrome.events.Event<(id: string, changeInfo: BookmarkChangeInfo) => void> { }
export interface BookmarkCreatedEvent extends chrome.events.Event<(id: string, bookmark: BookmarkTreeNode) => void> { }
export interface BookmarkChildrenReordered extends chrome.events.Event<(id: string, reorderInfo: BookmarkReorderInfo) => void> { }
export interface BookmarkSearchQuery {
query?: string;
url?: string;
title?: string;
}
export interface BookmarkCreateArg {
/** Optional. Defaults to the Other Bookmarks folder. */
parentId?: string;
index?: number;
title?: string;
url?: string;
}
export interface BookmarkDestinationArg {
parentId?: string;
index?: number;
}
export interface BookmarkChangesArg {
title?: string;
url?: string;
}
/** @deprecated since Chrome 38. Bookmark write operations are no longer limited by Chrome. */
export var MAX_WRITE_OPERATIONS_PER_HOUR: number;
/** @deprecated since Chrome 38. Bookmark write operations are no longer limited by Chrome. */
export var MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: number;
/**
* Searches for BookmarkTreeNodes matching the given query. Queries specified with an object produce BookmarkTreeNodes matching all specified properties.
* @param query A string of words and quoted phrases that are matched against bookmark URLs and titles.
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function search(query: string, callback: (results: BookmarkTreeNode[]) => void): void;
/**
* Searches for BookmarkTreeNodes matching the given query. Queries specified with an object produce BookmarkTreeNodes matching all specified properties.
* @param query An object with one or more of the properties query, url, and title specified. Bookmarks matching all specified properties will be produced.
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function search(query: BookmarkSearchQuery, callback: (results: BookmarkTreeNode[]) => void): void;
/**
* Retrieves the entire Bookmarks hierarchy.
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function getTree(callback: (results: BookmarkTreeNode[]) => void): void;
/**
* Retrieves the recently added bookmarks.
* @param numberOfItems The maximum number of items to return.
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function getRecent(numberOfItems: number, callback: (results: BookmarkTreeNode[]) => void): void;
/**
* Retrieves the specified BookmarkTreeNode.
* @param id A single string-valued id
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function get(id: string, callback: (results: BookmarkTreeNode[]) => void): void;
/**
* Retrieves the specified BookmarkTreeNode.
* @param idList An array of string-valued ids
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function get(idList: string[], callback: (results: BookmarkTreeNode[]) => void): void;
/**
* Creates a bookmark or folder under the specified parentId. If url is NULL or missing, it will be a folder.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function( BookmarkTreeNode result) {...};
*/
export function create(bookmark: BookmarkCreateArg, callback?: (result: BookmarkTreeNode) => void): void;
/**
* Moves the specified BookmarkTreeNode to the provided location.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function( BookmarkTreeNode result) {...};
*/
export function move(id: string, destination: BookmarkDestinationArg, callback?: (result: BookmarkTreeNode) => void): void;
/**
* Updates the properties of a bookmark or folder. Specify only the properties that you want to change; unspecified properties will be left unchanged. Note: Currently, only 'title' and 'url' are supported.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function( BookmarkTreeNode result) {...};
*/
export function update(id: string, changes: BookmarkChangesArg, callback?: (result: BookmarkTreeNode) => void): void;
/**
* Removes a bookmark or an empty bookmark folder.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function remove(id: string, callback?: Function): void;
/**
* Retrieves the children of the specified BookmarkTreeNode id.
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function getChildren(id: string, callback: (results: BookmarkTreeNode[]) => void): void;
/**
* Since Chrome 14.
* Retrieves part of the Bookmarks hierarchy, starting at the specified node.
* @param id The ID of the root of the subtree to retrieve.
* @param callback The callback parameter should be a function that looks like this:
* function(array of BookmarkTreeNode results) {...};
*/
export function getSubTree(id: string, callback: (results: BookmarkTreeNode[]) => void): void;
/**
* Recursively removes a bookmark folder.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeTree(id: string, callback?: Function): void;
/** Fired when a bookmark or folder is removed. When a folder is removed recursively, a single notification is fired for the folder, and none for its contents. */
export var onRemoved: BookmarkRemovedEvent;
/** Fired when a bookmark import session is ended. */
export var onImportEnded: BookmarkImportEndedEvent;
/** Fired when a bookmark import session is begun. Expensive observers should ignore onCreated updates until onImportEnded is fired. Observers should still handle other notifications immediately. */
export var onImportBegan: BookmarkImportBeganEvent;
/** Fired when a bookmark or folder changes. Note: Currently, only title and url changes trigger this. */
export var onChanged: BookmarkChangedEvent;
/** Fired when a bookmark or folder is moved to a different parent folder. */
export var onMoved: BookmarkMovedEvent;
/** Fired when a bookmark or folder is created. */
export var onCreated: BookmarkCreatedEvent;
/** Fired when the children of a folder have changed their order due to the order being sorted in the UI. This is not called as a result of a move(). */
export var onChildrenReordered: BookmarkChildrenReordered;
}
////////////////////
// Browser Action
////////////////////
/**
* Use browser actions to put icons in the main Google Chrome toolbar, to the right of the address bar. In addition to its icon, a browser action can also have a tooltip, a badge, and a popup.
* Availability: Since Chrome 5.
* Manifest: "browser_action": {...}
*/
declare namespace chrome.browserAction {
export interface BadgeBackgroundColorDetails {
/** An array of four integers in the range [0,255] that make up the RGBA color of the badge. For example, opaque red is [255, 0, 0, 255]. Can also be a string with a CSS value, with opaque red being #FF0000 or #F00. */
color: string | ColorArray;
/** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number;
}
export interface BadgeTextDetails {
/** Any number of characters can be passed, but only about four can fit in the space. */
text: string;
/** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number;
}
export type ColorArray = [number, number, number, number];
export interface TitleDetails {
/** The string the browser action should display when moused over. */
title: string;
/** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number;
}
export interface TabDetails {
/** Optional. Specify the tab to get the information. If no tab is specified, the non-tab-specific information is returned. */
tabId?: number;
}
export interface TabIconDetails {
/** Optional. Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}' */
path?: any;
/** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number;
/** Optional. Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}' */
imageData?: ImageData | { [index: number]: ImageData };
}
export interface PopupDetails {
/** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number;
/** The html file to show in a popup. If set to the empty string (''), no popup is shown. */
popup: string;
}
export interface BrowserClickedEvent extends chrome.events.Event<(tab: chrome.tabs.Tab) => void> { }
/**
* Since Chrome 22.
* Enables the browser action for a tab. By default, browser actions are enabled.
* @param tabId The id of the tab for which you want to modify the browser action.
* @param callback Supported since Chrome 67
*/
export function enable(tabId?: number, callback?: () => void): void;
/**
* Sets the background color for the badge.
* @param callback Supported since Chrome 67
*/
export function setBadgeBackgroundColor(details: BadgeBackgroundColorDetails, callback?: () => void): void;
/**
* Sets the badge text for the browser action. The badge is displayed on top of the icon.
* @param callback Supported since Chrome 67
*/
export function setBadgeText(details: BadgeTextDetails, callback?: () => void): void;
/**
* Sets the title of the browser action. This shows up in the tooltip.
* @param callback Supported since Chrome 67
*/
export function setTitle(details: TitleDetails, callback?: () => void): void;
/**
* Since Chrome 19.
* Gets the badge text of the browser action. If no tab is specified, the non-tab-specific badge text is returned.
* @param callback Supported since Chrome 67
*/
export function getBadgeText(details: TabDetails, callback: (result: string) => void): void;
/**
* Sets the html document to be opened as a popup when the user clicks on the browser action's icon.
* @param callback Supported since Chrome 67
*/
export function setPopup(details: PopupDetails, callback?: () => void): void;
/**
* Since Chrome 22.
* Disables the browser action for a tab.
* @param tabId The id of the tab for which you want to modify the browser action.
* @param callback Supported since Chrome 67
*/
export function disable(tabId?: number, callback?: () => void): void;
/**
* Since Chrome 19.
* Gets the title of the browser action.
* @param callback The callback parameter should be a function that looks like this:
* function(string result) {...};
*/
export function getTitle(details: TabDetails, callback: (result: string) => void): void;
/**
* Since Chrome 19.
* Gets the background color of the browser action.
* @param callback The callback parameter should be a function that looks like this:
* function( ColorArray result) {...};
*/
export function getBadgeBackgroundColor(details: TabDetails, callback: (result: ColorArray) => void): void;
/**
* Since Chrome 19.
* Gets the html document set as the popup for this browser action.
* @param callback The callback parameter should be a function that looks like this:
* function(string result) {...};
*/
export function getPopup(details: TabDetails, callback: (result: string) => void): void;
/**
* Sets the icon for the browser action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the path or the imageData property must be specified.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function setIcon(details: TabIconDetails, callback?: Function): void;
/** Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup. */
export var onClicked: BrowserClickedEvent;
}
////////////////////
// Browsing Data
////////////////////
/**
* Use the chrome.browsingData API to remove browsing data from a user's local profile.
* Availability: Since Chrome 19.
* Permissions: "browsingData"
*/
declare namespace chrome.browsingData {
export interface OriginTypes {
/** Optional. Websites that have been installed as hosted applications (be careful!). */
protectedWeb?: boolean;
/** Optional. Extensions and packaged applications a user has installed (be _really_ careful!). */
extension?: boolean;
/** Optional. Normal websites. */
unprotectedWeb?: boolean;
}
/** Options that determine exactly what data will be removed. */
export interface RemovalOptions {
/**
* Optional.
* Since Chrome 21.
* An object whose properties specify which origin types ought to be cleared. If this object isn't specified, it defaults to clearing only "unprotected" origins. Please ensure that you really want to remove application data before adding 'protectedWeb' or 'extensions'.
*/
originTypes?: OriginTypes;
/** Optional. Remove data accumulated on or after this date, represented in milliseconds since the epoch (accessible via the getTime method of the JavaScript Date object). If absent, defaults to 0 (which would remove all browsing data). */
since?: number;
}
/**
* Since Chrome 27.
* A set of data types. Missing data types are interpreted as false.
*/
export interface DataTypeSet {
/** Optional. Websites' WebSQL data. */
webSQL?: boolean;
/** Optional. Websites' IndexedDB data. */
indexedDB?: boolean;
/** Optional. The browser's cookies. */
cookies?: boolean;
/** Optional. Stored passwords. */
passwords?: boolean;
/** Optional. Server-bound certificates. */
serverBoundCertificates?: boolean;
/** Optional. The browser's download list. */
downloads?: boolean;
/** Optional. The browser's cache. Note: when removing data, this clears the entire cache: it is not limited to the range you specify. */
cache?: boolean;
/** Optional. Websites' appcaches. */
appcache?: boolean;
/** Optional. Websites' file systems. */
fileSystems?: boolean;
/** Optional. Plugins' data. */
pluginData?: boolean;
/** Optional. Websites' local storage data. */
localStorage?: boolean;
/** Optional. The browser's stored form data. */
formData?: boolean;
/** Optional. The browser's history. */
history?: boolean;
/**
* Optional.
* Since Chrome 39.
* Service Workers.
*/
serviceWorkers?: boolean;
}
export interface SettingsCallback {
options: RemovalOptions;
/** All of the types will be present in the result, with values of true if they are both selected to be removed and permitted to be removed, otherwise false. */
dataToRemove: DataTypeSet;
/** All of the types will be present in the result, with values of true if they are permitted to be removed (e.g., by enterprise policy) and false if not. */
dataRemovalPermitted: DataTypeSet;
}
/**
* Since Chrome 26.
* Reports which types of data are currently selected in the 'Clear browsing data' settings UI. Note: some of the data types included in this API are not available in the settings UI, and some UI settings control more than one data type listed here.
* @param callback The callback parameter should be a function that looks like this:
* function(object result) {...};
*/
export function settings(callback: (result: SettingsCallback) => void): void;
/**
* Clears plugins' data.
* @param callback Called when plugins' data has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removePluginData(options: RemovalOptions, callback?: () => void): void;
/**
* Clears the browser's stored form data (autofill).
* @param callback Called when the browser's form data has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeFormData(options: RemovalOptions, callback?: () => void): void;
/**
* Clears websites' file system data.
* @param callback Called when websites' file systems have been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeFileSystems(options: RemovalOptions, callback?: () => void): void;
/**
* Clears various types of browsing data stored in a user's profile.
* @param dataToRemove The set of data types to remove.
* @param callback Called when deletion has completed.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function remove(options: RemovalOptions, dataToRemove: DataTypeSet, callback?: () => void): void;
/**
* Clears the browser's stored passwords.
* @param callback Called when the browser's passwords have been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removePasswords(options: RemovalOptions, callback?: () => void): void;
/**
* Clears the browser's cookies and server-bound certificates modified within a particular timeframe.
* @param callback Called when the browser's cookies and server-bound certificates have been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeCookies(options: RemovalOptions, callback?: () => void): void;
/**
* Clears websites' WebSQL data.
* @param callback Called when websites' WebSQL databases have been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeWebSQL(options: RemovalOptions, callback?: () => void): void;
/**
* Clears websites' appcache data.
* @param callback Called when websites' appcache data has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeAppcache(options: RemovalOptions, callback?: () => void): void;
/**
* Clears the browser's list of downloaded files (not the downloaded files themselves).
* @param callback Called when the browser's list of downloaded files has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeDownloads(options: RemovalOptions, callback?: () => void): void;
/**
* Clears websites' local storage data.
* @param callback Called when websites' local storage has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeLocalStorage(options: RemovalOptions, callback?: () => void): void;
/**
* Clears the browser's cache.
* @param callback Called when the browser's cache has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeCache(options: RemovalOptions, callback?: () => void): void;
/**
* Clears the browser's history.
* @param callback Called when the browser's history has cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeHistory(options: RemovalOptions, callback?: () => void): void;
/**
* Clears websites' IndexedDB data.
* @param callback Called when websites' IndexedDB data has been cleared.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeIndexedDB(options: RemovalOptions, callback?: () => void): void;
}
////////////////////
// Commands
////////////////////
/**
* Use the commands API to add keyboard shortcuts that trigger actions in your extension, for example, an action to open the browser action or send a command to the extension.
* Availability: Since Chrome 25.
* Manifest: "commands": {...}
*/
declare namespace chrome.commands {
export interface Command {
/** Optional. The name of the Extension Command */
name?: string;
/** Optional. The Extension Command description */
description?: string;
/** Optional. The shortcut active for this command, or blank if not active. */
shortcut?: string;
}
export interface CommandEvent extends chrome.events.Event<(command: string) => void> { }
/**
* Returns all the registered extension commands for this extension and their shortcut (if active).
* @param callback Called to return the registered commands.
* If you specify the callback parameter, it should be a function that looks like this:
* function(array of Command commands) {...};
*/
export function getAll(callback: (commands: Command[]) => void): void;
/** Fired when a registered command is activated using a keyboard shortcut. */
export var onCommand: CommandEvent;
}
////////////////////
// Content Settings
////////////////////
/**
* Use the chrome.contentSettings API to change settings that control whether websites can use features such as cookies, JavaScript, and plugins. More generally speaking, content settings allow you to customize Chrome's behavior on a per-site basis instead of globally.
* Availability: Since Chrome 16.
* Permissions: "contentSettings"
*/
declare namespace chrome.contentSettings {
type ScopeEnum = 'regular' | 'incognito_session_only';
export interface ClearDetails {
/**
* Optional.
* Where to clear the setting (default: regular).
* The scope of the ContentSetting. One of
* * regular: setting for regular profile (which is inherited by the incognito profile if not overridden elsewhere),
* * incognito_session_only: setting for incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular settings).
*/
scope?: ScopeEnum;
}
export interface SetDetails {
/** Optional. The resource identifier for the content type. */
resourceIdentifier?: ResourceIdentifier;
/** The setting applied by this rule. See the description of the individual ContentSetting objects for the possible values. */
setting: any;
/** Optional. The pattern for the secondary URL. Defaults to matching all URLs. For details on the format of a pattern, see Content Setting Patterns. */
secondaryPattern?: string;
/** Optional. Where to set the setting (default: regular). */
scope?: ScopeEnum;
/** The pattern for the primary URL. For details on the format of a pattern, see Content Setting Patterns. */
primaryPattern: string;
}
export interface CookieSetDetails extends SetDetails {
setting: 'allow' | 'block' | 'session_only';
}
export interface ImagesSetDetails extends SetDetails {
setting: 'allow' | 'block';
}
export interface JavascriptSetDetails extends SetDetails {
setting: 'allow' | 'block';
}
export interface LocationSetDetails extends SetDetails {
setting: 'allow' | 'block' | 'ask';
}
export interface PluginsSetDetails extends SetDetails {
setting: 'allow' | 'block' | 'detect_important_content';
}
export interface PopupsSetDetails extends SetDetails {
setting: 'allow' | 'block';
}
export interface NotificationsSetDetails extends SetDetails {
setting: 'allow' | 'block' | 'ask';
}
export interface FullscreenSetDetails extends SetDetails {
setting: 'allow';
}
export interface MouselockSetDetails extends SetDetails {
setting: 'allow';
}
export interface MicrophoneSetDetails extends SetDetails {
setting: 'allow' | 'block' | 'ask';
}
export interface CameraSetDetails extends SetDetails {
setting: 'allow' | 'block' | 'ask';
}
export interface PpapiBrokerSetDetails extends SetDetails {
setting: 'allow' | 'block' | 'ask';
}
export interface MultipleAutomaticDownloadsSetDetails extends SetDetails {
setting: 'allow' | 'block' | 'ask';
}
export interface GetDetails {
/** Optional. The secondary URL for which the content setting should be retrieved. Defaults to the primary URL. Note that the meaning of a secondary URL depends on the content type, and not all content types use secondary URLs. */
secondaryUrl?: string;
/** Optional. A more specific identifier of the type of content for which the settings should be retrieved. */
resourceIdentifier?: ResourceIdentifier;
/** Optional. Whether to check the content settings for an incognito session. (default false) */
incognito?: boolean;
/** The primary URL for which the content setting should be retrieved. Note that the meaning of a primary URL depends on the content type. */
primaryUrl: string;
}
export interface ReturnedDetails {
/** The content setting. See the description of the individual ContentSetting objects for the possible values. */
setting: any;
}
export interface ContentSetting {
/**
* Clear all content setting rules set by this extension.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
clear(details: ClearDetails, callback?: () => void): void;
/**
* Applies a new content setting rule.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
set(details: SetDetails, callback?: () => void): void;
/**
* @param callback The callback parameter should be a function that looks like this:
* function(array of ResourceIdentifier resourceIdentifiers) {...};
* Parameter resourceIdentifiers: A list of resource identifiers for this content type, or undefined if this content type does not use resource identifiers.
*/
getResourceIdentifiers(callback: (resourceIdentifiers?: ResourceIdentifier[]) => void): void;
/**
* Gets the current content setting for a given pair of URLs.
* @param callback The callback parameter should be a function that looks like this:
* function(object details) {...};
*/
get(details: GetDetails, callback: (details: ReturnedDetails) => void): void;
}
export interface CookieContentSetting extends ContentSetting{
set(details: CookieSetDetails, callback?: () => void): void;
}
export interface PopupsContentSetting extends ContentSetting{
set(details: PopupsSetDetails, callback?: () => void): void;
}
export interface JavascriptContentSetting extends ContentSetting{
set(details: JavascriptSetDetails, callback?: () => void): void;
}
export interface NotificationsContentSetting extends ContentSetting{
set(details: NotificationsSetDetails, callback?: () => void): void;
}
export interface PluginsContentSetting extends ContentSetting{
set(details: PluginsSetDetails, callback?: () => void): void;
}
export interface ImagesContentSetting extends ContentSetting{
set(details: ImagesSetDetails, callback?: () => void): void;
}
export interface LocationContentSetting extends ContentSetting{
set(details: LocationSetDetails, callback?: () => void): void;
}
export interface FullscreenContentSetting extends ContentSetting{
set(details: FullscreenSetDetails, callback?: () => void): void;
}
export interface MouselockContentSetting extends ContentSetting{
set(details: MouselockSetDetails, callback?: () => void): void;
}
export interface MicrophoneContentSetting extends ContentSetting{
set(details: MicrophoneSetDetails, callback?: () => void): void;
}
export interface CameraContentSetting extends ContentSetting{
set(details: CameraSetDetails, callback?: () => void): void;
}
export interface PpapiBrokerContentSetting extends ContentSetting{
set(details: PpapiBrokerSetDetails, callback?: () => void): void;
}
export interface MultipleAutomaticDownloadsContentSetting extends ContentSetting{
set(details: MultipleAutomaticDownloadsSetDetails, callback?: () => void): void;
}
/** The only content type using resource identifiers is contentSettings.plugins. For more information, see Resource Identifiers. */
export interface ResourceIdentifier {
/** The resource identifier for the given content type. */
id: string;
/** Optional. A human readable description of the resource. */
description?: string;
}
/**
* Whether to allow cookies and other local data to be set by websites. One of
* allow: Accept cookies,
* block: Block cookies,
* session_only: Accept cookies only for the current session.
* Default is allow.
* The primary URL is the URL representing the cookie origin. The secondary URL is the URL of the top-level frame.
*/
export var cookies: CookieContentSetting;
/**
* Whether to allow sites to show pop-ups. One of
* allow: Allow sites to show pop-ups,
* block: Don't allow sites to show pop-ups.
* Default is block.
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
export var popups: PopupsContentSetting;
/**
* Whether to run JavaScript. One of
* allow: Run JavaScript,
* block: Don't run JavaScript.
* Default is allow.
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
export var javascript: JavascriptContentSetting;
/**
* Whether to allow sites to show desktop notifications. One of
* allow: Allow sites to show desktop notifications,
* block: Don't allow sites to show desktop notifications,
* ask: Ask when a site wants to show desktop notifications.
* Default is ask.
* The primary URL is the URL of the document which wants to show the notification. The secondary URL is not used.
*/
export var notifications: NotificationsContentSetting;
/**
* Whether to run plugins. One of
* allow: Run plugins automatically,
* block: Don't run plugins automatically,
* detect_important_content: Only run automatically those plugins that are detected as the website's main content.
* Default is allow.
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
export var plugins: PluginsContentSetting;
/**
* Whether to show images. One of
* allow: Show images,
* block: Don't show images.
* Default is allow.
* The primary URL is the URL of the top-level frame. The secondary URL is the URL of the image.
*/
export var images: ImagesContentSetting;
/**
* Since Chrome 42.
* Whether to allow Geolocation. One of
* allow: Allow sites to track your physical location,
* block: Don't allow sites to track your physical location,
* ask: Ask before allowing sites to track your physical location.
* Default is ask.
* The primary URL is the URL of the document which requested location data. The secondary URL is the URL of the top-level frame (which may or may not differ from the requesting URL).
*/
export var location: LocationContentSetting;
/**
* Since Chrome 42.
* Whether to allow sites to toggle the fullscreen mode. One of
* allow: Allow sites to toggle the fullscreen mode,
* ask: Ask when a site wants to toggle the fullscreen mode.
* Default is ask.
* The primary URL is the URL of the document which requested to toggle the fullscreen mode. The secondary URL is the URL of the top-level frame (which may or may not differ from the requesting URL).
*/
export var fullscreen: FullscreenContentSetting;
/**
* Since Chrome 42.
* Whether to allow sites to disable the mouse cursor. One of
* allow: Allow sites to disable the mouse cursor,
* block: Don't allow sites to disable the mouse cursor,
* ask: Ask when a site wants to disable the mouse cursor.
* Default is ask.
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
export var mouselock: MouselockContentSetting;
/**
* Since Chrome 46.
* Whether to allow sites to access the microphone. One of
* allow: Allow sites to access the microphone,
* block: Don't allow sites to access the microphone,
* ask: Ask when a site wants to access the microphone.
* Default is ask.
* The primary URL is the URL of the document which requested microphone access. The secondary URL is not used.
* NOTE: The 'allow' setting is not valid if both patterns are ''.
*/
export var microphone: MicrophoneContentSetting;
/**
* Since Chrome 46.
* Whether to allow sites to access the camera. One of
* allow: Allow sites to access the camera,
* block: Don't allow sites to access the camera,
* ask: Ask when a site wants to access the camera.
* Default is ask.
* The primary URL is the URL of the document which requested camera access. The secondary URL is not used.
* NOTE: The 'allow' setting is not valid if both patterns are ''.
*/
export var camera: CameraContentSetting;
/**
* Since Chrome 42.
* Whether to allow sites to run plugins unsandboxed. One of
* allow: Allow sites to run plugins unsandboxed,
* block: Don't allow sites to run plugins unsandboxed,
* ask: Ask when a site wants to run a plugin unsandboxed.
* Default is ask.
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
export var unsandboxedPlugins: PpapiBrokerContentSetting;
/**
* Since Chrome 42.
* Whether to allow sites to download multiple files automatically. One of
* allow: Allow sites to download multiple files automatically,
* block: Don't allow sites to download multiple files automatically,
* ask: Ask when a site wants to download files automatically after the first file.
* Default is ask.
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
export var automaticDownloads: MultipleAutomaticDownloadsContentSetting;
}
////////////////////
// Context Menus
////////////////////
/**
* Use the chrome.contextMenus API to add items to Google Chrome's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.
* Availability: Since Chrome 6.
* Permissions: "contextMenus"
*/
declare namespace chrome.contextMenus {
export interface OnClickData {
/**
* Optional.
* Since Chrome 35.
* The text for the context selection, if any.
*/
selectionText?: string;
/**
* Optional.
* Since Chrome 35.
* A flag indicating the state of a checkbox or radio item after it is clicked.
*/
checked?: boolean;
/**
* Since Chrome 35.
* The ID of the menu item that was clicked.
*/
menuItemId: any;
/**
* Optional.
* Since Chrome 35.
* The ID of the frame of the element where the context menu was
* clicked, if it was in a frame.
*/
frameId?: number;
/**
* Optional.
* Since Chrome 35.
* The URL of the frame of the element where the context menu was clicked, if it was in a frame.
*/
frameUrl?: string;
/**
* Since Chrome 35.
* A flag indicating whether the element is editable (text input, textarea, etc.).
*/
editable: boolean;
/**
* Optional.
* Since Chrome 35.
* One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements.
*/
mediaType?: string;
/**
* Optional.
* Since Chrome 35.
* A flag indicating the state of a checkbox or radio item before it was clicked.
*/
wasChecked?: boolean;
/**
* Since Chrome 35.
* The URL of the page where the menu item was clicked. This property is not set if the click occured in a context where there is no current page, such as in a launcher context menu.
*/
pageUrl: string;
/**
* Optional.
* Since Chrome 35.
* If the element is a link, the URL it points to.
*/
linkUrl?: string;
/**
* Optional.
* Since Chrome 35.
* The parent ID, if any, for the item clicked.
*/
parentMenuItemId?: any;
/**
* Optional.
* Since Chrome 35.
* Will be present for elements with a 'src' URL.
*/
srcUrl?: string;
}
export interface CreateProperties {
/** Optional. Lets you restrict the item to apply only to documents whose URL matches one of the given patterns. (This applies to frames as well.) For details on the format of a pattern, see Match Patterns. */
documentUrlPatterns?: string[];
/** Optional. The initial state of a checkbox or radio item: true for selected and false for unselected. Only one radio item can be selected at a time in a given group of radio items. */
checked?: boolean;
/** Optional. The text to be displayed in the item; this is required unless type is 'separator'. When the context is 'selection', you can use %s within the string to show the selected text. For example, if this parameter's value is "Translate '%s' to Pig Latin" and the user selects the word "cool", the context menu item for the selection is "Translate 'cool' to Pig Latin". */
title?: string;
/** Optional. List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */
contexts?: string[];
/**
* Optional.
* Since Chrome 20.
* Whether this context menu item is enabled or disabled. Defaults to true.
*/
enabled?: boolean;
/** Optional. Similar to documentUrlPatterns, but lets you filter based on the src attribute of img/audio/video tags and the href of anchor tags. */
targetUrlPatterns?: string[];
/**
* Optional.
* A function that will be called back when the menu item is clicked. Event pages cannot use this; instead, they should register a listener for chrome.contextMenus.onClicked.
* @param info Information sent when a context menu item is clicked.
* @param tab The details of the tab where the click took place. Note: this parameter only present for extensions.
*/
onclick?: (info: OnClickData, tab: chrome.tabs.Tab) => void;
/** Optional. The ID of a parent menu item; this makes the item a child of a previously added item. */
parentId?: any;
/** Optional. The type of menu item. Defaults to 'normal' if not specified. */
type?: string;
/**
* Optional.
* Since Chrome 21.
* The unique ID to assign to this item. Mandatory for event pages. Cannot be the same as another ID for this extension.
*/
id?: string;
/**
* Optional.
* Since Chrome 62.
* Whether the item is visible in the menu.
*/
visible?: boolean;
}
export interface UpdateProperties {
documentUrlPatterns?: string[];
checked?: boolean;
title?: string;
contexts?: string[];
/** Optional. Since Chrome 20. */
enabled?: boolean;
targetUrlPatterns?: string[];
onclick?: Function;
/** Optional. Note: You cannot change an item to be a child of one of its own descendants. */
parentId?: any;
type?: string;
}
export interface MenuClickedEvent extends chrome.events.Event<(info: OnClickData, tab?: chrome.tabs.Tab) => void> { }
/**
* Since Chrome 38.
* The maximum number of top level extension items that can be added to an extension action context menu. Any items beyond this limit will be ignored.
*/
export var ACTION_MENU_TOP_LEVEL_LIMIT: number;
/**
* Removes all context menu items added by this extension.
* @param callback Called when removal is complete.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function removeAll(callback?: () => void): void;
/**
* Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation callback fires (the details will be in chrome.runtime.lastError).
* @param callback Called when the item has been created in the browser. If there were any problems creating the item, details will be available in chrome.runtime.lastError.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function create(createProperties: CreateProperties, callback?: () => void): void;
/**
* Updates a previously created context menu item.
* @param id The ID of the item to update.
* @param updateProperties The properties to update. Accepts the same values as the create function.
* @param callback Called when the context menu has been updated.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function update(id: string, updateProperties: UpdateProperties, callback?: () => void): void;
/**
* Updates a previously created context menu item.
* @param id The ID of the item to update.
* @param updateProperties The properties to update. Accepts the same values as the create function.
* @param callback Called when the context menu has been updated.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function update(id: number, updateProperties: UpdateProperties, callback?: () => void): void;
/**
* Removes a context menu item.
* @param menuItemId The ID of the context menu item to remove.
* @param callback Called when the context menu has been removed.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function remove(menuItemId: string, callback?: () => void): void;
/**
* Removes a context menu item.
* @param menuItemId The ID of the context menu item to remove.
* @param callback Called when the context menu has been removed.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function remove(menuItemId: number, callback?: () => void): void;
/**
* Since Chrome 21.
* Fired when a context menu item is clicked.
*/
export var onClicked: MenuClickedEvent;
}
////////////////////
// Cookies
////////////////////
/**
* Use the chrome.cookies API to query and modify cookies, and to be notified when they change.
* Availability: Since Chrome 6.
* Permissions: "cookies", host permissions
*/
declare namespace chrome.cookies {
/** Represents information about an HTTP cookie. */
export interface Cookie {
/** The domain of the cookie (e.g. "www.google.com", "example.com"). */
domain: string;
/** The name of the cookie. */
name: string;
/** The ID of the cookie store containing this cookie, as provided in getAllCookieStores(). */
storeId: string;
/** The value of the cookie. */
value: string;
/** True if the cookie is a session cookie, as opposed to a persistent cookie with an expiration date. */
session: boolean;
/** True if the cookie is a host-only cookie (i.e. a request's host must exactly match the domain of the cookie). */
hostOnly: boolean;
/** Optional. The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies. */
expirationDate?: number;
/** The path of the cookie. */
path: string;
/** True if the cookie is marked as HttpOnly (i.e. the cookie is inaccessible to client-side scripts). */
httpOnly: boolean;
/** True if the cookie is marked as Secure (i.e. its scope is limited to secure channels, typically HTTPS). */
secure: boolean;
}
/** Represents a cookie store in the browser. An incognito mode window, for instance, uses a separate cookie store from a non-incognito window. */
export interface CookieStore {
/** The unique identifier for the cookie store. */
id: string;
/** Identifiers of all the browser tabs that share this cookie store. */
tabIds: number[];
}
export interface GetAllDetails {
/** Optional. Restricts the retrieved cookies to those whose domains match or are subdomains of this one. */
domain?: string;
/** Optional. Filters the cookies by name. */
name?: string;
/** Optional. Restricts the retrieved cookies to those that would match the given URL. */
url?: string;
/** Optional. The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used. */
storeId?: string;
/** Optional. Filters out session vs. persistent cookies. */
session?: boolean;
/** Optional. Restricts the retrieved cookies to those whose path exactly matches this string. */
path?: string;
/** Optional. Filters the cookies by their Secure property. */
secure?: boolean;
}
export interface SetDetails {
/** Optional. The domain of the cookie. If omitted, the cookie becomes a host-only cookie. */
domain?: string;
/** Optional. The name of the cookie. Empty by default if omitted. */
name?: string;
/** The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie. If host permissions for this URL are not specified in the manifest file, the API call will fail. */
url: string;
/** Optional. The ID of the cookie store in which to set the cookie. By default, the cookie is set in the current execution context's cookie store. */
storeId?: string;
/** Optional. The value of the cookie. Empty by default if omitted. */
value?: string;
/** Optional. The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie. */
expirationDate?: number;
/** Optional. The path of the cookie. Defaults to the path portion of the url parameter. */
path?: string;
/** Optional. Whether the cookie should be marked as HttpOnly. Defaults to false. */
httpOnly?: boolean;
/** Optional. Whether the cookie should be marked as Secure. Defaults to false. */
secure?: boolean;
}
export interface Details {
name: string;
url: string;
storeId?: string;
}
export interface CookieChangeInfo {
/** Information about the cookie that was set or removed. */
cookie: Cookie;
/** True if a cookie was removed. */
removed: boolean;
/**
* Since Chrome 12.
* The underlying reason behind the cookie's change.
*/
cause: string;
}
export interface CookieChangedEvent extends chrome.events.Event<(changeInfo: CookieChangeInfo) => void> { }
/**
* Lists all existing cookie stores.
* @param callback The callback parameter should be a function that looks like this:
* function(array of CookieStore cookieStores) {...};
* Parameter cookieStores: All the existing cookie stores.
*/
export function getAllCookieStores(callback: (cookieStores: CookieStore[]) => void): void;
/**
* Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first.
* @param details Information to filter the cookies being retrieved.
* @param callback The callback parameter should be a function that looks like this:
* function(array of Cookie cookies) {...};
* Parameter cookies: All the existing, unexpired cookies that match the given cookie info.
*/
export function getAll(details: GetAllDetails, callback: (cookies: Cookie[]) => void): void;
/**
* Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
* @param details Details about the cookie being set.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function( Cookie cookie) {...};
* Optional parameter cookie: Contains details about the cookie that's been set. If setting failed for any reason, this will be "null", and "chrome.runtime.lastError" will be set.
*/
export function set(details: SetDetails, callback?: (cookie: Cookie | null) => void): void;
/**
* Deletes a cookie by name.
* @param details Information to identify the cookie to remove.
* @param callback If you specify the callback parameter, it should be a function that looks like this:
* function(object details) {...};
*/
export function remove(details: Details, callback?: (details: Details) => void): void;
/**
* Retrieves information about a single cookie. If more than one cookie of the same name exists for the given URL, the one with the longest path will be returned. For cookies with the same path length, the cookie with the earliest creation time will be returned.
* @param details Details to identify the cookie being retrieved.
* @param callback The callback parameter should be a function that looks like this:
* function( Cookie cookie) {...};
* Parameter cookie: Contains details about the cookie. This parameter is null if no such cookie was found.
*/
export function get(details: Details, callback: (cookie: Cookie | null) => void): void;
/** Fired when a cookie is set or removed. As a special case, note that updating a cookie's properties is implemented as a two step process: the cookie to be updated is first removed entirely, generating a notification with "cause" of "overwrite" . Afterwards, a new cookie is written with the updated values, generating a second notification with "cause" "explicit". */
export var onChanged: CookieChangedEvent;
}
////////////////////
// Debugger
////////////////////
/**
* The chrome.debugger API serves as an alternate transport for Chrome's remote debugging protocol. Use chrome.debugger to attach to one or more tabs to instrument network interaction, debug JavaScript, mutate the DOM and CSS, etc. Use the Debuggee tabId to target tabs with sendCommand and route events by tabId from onEvent callbacks.
* Availability: Since Chrome 18.
* Permissions: "debugger"
*/
declare module chrome {
namespace _debugger {
/** Debuggee identifier. Either tabId or extensionId must be specified */
export interface Debuggee {
/** Optional. The id of the tab which you intend to debug. */
tabId?: number;
/**
* Optional.
* Since Chrome 27.
* The id of the extension which you intend to debug. Attaching to an extension background page is only possible when 'silent-debugger-extension-api' flag is enabled on the target browser.
*/
extensionId?: string;
/**
* Optional.
* Since Chrome 28.
* The opaque id of the debug target.
*/
targetId?: string;
}
/**
* Since Chrome 28.
* Debug target information
*/
export interface TargetInfo {
/** Target type. */
type: string;
/** Target id. */
id: string;
/**
* Optional.
* Since Chrome 30.
* The tab id, defined if type == 'page'.
*/
tabId?: number;
/**
* Optional.
* Since Chrome 30.
* The extension id, defined if type = 'background_page'.
*/
extensionId?: string;
/** True if debugger is already attached. */
attached: boolean;
/** Target page title. */
title: string;
/** Target URL. */
url: string;
/** Optional. Target favicon URL. */
faviconUrl?: string;
}
export interface DebuggerDetachedEvent extends chrome.events.Event<(source: Debuggee, reason: string) => void> { }
export interface DebuggerEventEvent extends chrome.events.Event<(source: Debuggee, method: string, params?: Object) => void> { }
/**
* Attaches debugger to the given target.
* @param target Debugging target to which you want to attach.
* @param requiredVersion Required debugging protocol version ("0.1"). One can only attach to the debuggee with matching major version and greater or equal minor version. List of the protocol versions can be obtained in the documentation pages.
* @param callback Called once the attach operation succeeds or fails. Callback receives no arguments. If the attach fails, runtime.lastError will be set to the error message.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function attach(target: Debuggee, requiredVersion: string, callback?: () => void): void;
/**
* Detaches debugger from the given target.
* @param target Debugging target from which you want to detach.
* @param callback Called once the detach operation succeeds or fails. Callback receives no arguments. If the detach fails, runtime.lastError will be set to the error message.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function detach(target: Debuggee, callback?: () => void): void;
/**
* Sends given command to the debugging target.
* @param target Debugging target to which you want to send the command.
* @param method Method name. Should be one of the methods defined by the remote debugging protocol.
* @param commandParams Since Chrome 22.
* JSON object with request parameters. This object must conform to the remote debugging params scheme for given method.
* @param callback Response body. If an error occurs while posting the message, the callback will be called with no arguments and runtime.lastError will be set to the error message.
* If you specify the callback parameter, it should be a function that looks like this:
* function(object result) {...};
*/
export function sendCommand(target: Debuggee, method: string, commandParams?: Object, callback?: (result?: Object) => void): void;
/**
* Since Chrome 28.
* Returns the list of available debug targets.
* @param callback The callback parameter should be a function that looks like this:
* function(array of TargetInfo result) {...};
* Parameter result: Array of TargetInfo objects corresponding to the available debug targets.
*/
export function getTargets(callback: (result: TargetInfo[]) => void): void;
/** Fired when browser terminates debugging session for the tab. This happens when either the tab is being closed or Chrome DevTools is being invoked for the attached tab. */
export var onDetach: DebuggerDetachedEvent;
/** Fired whenever debugging target issues instrumentation event. */
export var onEvent: DebuggerEventEvent;
}
export { _debugger as debugger }
}
////////////////////
// Declarative Content
////////////////////
/**
* Use the chrome.declarativeContent API to take actions depending on the content of a page, without requiring permission to read the page's content.
* Availability: Since Chrome 33.
* Permissions: "declarativeContent"
*/
declare namespace chrome.declarativeContent {
export interface PageStateUrlDetails {
/** Optional. 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;
/** Optional. Matches if the host name of the URL is equal to a specified string. */
hostEquals?: string;
/** Optional. Matches if the host name of the URL starts with a specified string. */
hostPrefix?: string;
/** Optional. Matches if the host name of the URL ends with a specified string. */
hostSuffix?: string;
/** Optional. Matches if the path segment of the URL contains a specified string. */
pathContains?: string;
/** Optional. Matches if the path segment of the URL is equal to a specified string. */
pathEquals?: string;
/** Optional. Matches if the path segment of the URL starts with a specified string. */
pathPrefix?: string;
/** Optional. Matches if the path segment of the URL ends with a specified string. */
pathSuffix?: string;
/** Optional. Matches if the query segment of the URL contains a specified string. */
queryContains?: string;
/** Optional. Matches if the query segment of the URL is equal to a specified string. */
queryEquals?: string;
/** Optional. Matches if the query segment of the URL starts with a specified string. */
queryPrefix?: string;
/** Optional. Matches if the query segment of the URL ends with a specified string. */
querySuffix?: string;
/** Optional. 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;
/** Optional. 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;
/** Optional. 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;
/** Optional. 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;
/** Optional. 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;
/** Optional. 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;
/** Optional. Matches if the scheme of the URL is equal to any of the schemes specified in the array. */
schemes?: string[];
/** Optional. 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?: (number | number[])[];
}
export class PageStateMatcherProperties {
/** Optional. Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */
pageUrl?: PageStateUrlDetails;
/** Optional. Matches if all of the CSS selectors in the array match displayed elements in a frame with the same origin as the page's main frame. All selectors in this array must be compound selectors to speed up matching. Note that listing hundreds of CSS selectors or CSS selectors that match hundreds of times per page can still slow down web sites. */
css?: string[];
/**
* Optional.
* Since Chrome 45. Warning: this is the current Beta channel. More information available on the API documentation pages.
* Matches if the bookmarked state of the page is equal to the specified value. Requres the bookmarks permission.
*/
isBookmarked?: boolean;
}
/** Matches the state of a web page by various criteria. */
export class PageStateMatcher {
constructor (options: PageStateMatcherProperties);
}
/** Declarative event action that shows the extension's page action while the corresponding conditions are met. */
export class ShowPageAction { }
/** Provides the Declarative Event API consisting of addRules, removeRules, and getRules. */
export interface PageChangedEvent extends chrome.events.Event<() => void> { }
export var onPageChanged: PageChangedEvent;
}
////////////////////
// Declarative Web Request
////////////////////
declare namespace chrome.declarativeWebRequest {
export interface HeaderFilter {
nameEquals?: string;
valueContains?: any;
nameSuffix?: string;
valueSuffix?: string;
valuePrefix?: string;
nameContains?: any;
valueEquals?: string;
namePrefix?: string;
}
export interface AddResponseHeader {
name: string;
value: string;
}
export interface RemoveResponseCookie {
filter: ResponseCookie;
}
export interface RemoveResponseHeader {
name: string;
value?: string;
}
export interface RequestMatcher {
contentType?: string[];
url?: chrome.events.UrlFilter;
excludeContentType?: string[];
excludeResponseHeader?: HeaderFilter[];
resourceType?: string;
responseHeaders?: HeaderFilter[];
}
export interface IgnoreRules {
lowerPriorityThan: number;
}
export interface RedirectToEmptyDocument { }
export interface RedirectRequest {
redirectUrl: string;
}
export interface ResponseCookie {
domain?: string;
name?: string;
expires?: string;
maxAge?: number;
value?: string;
path?: string;
httpOnly?: string;
secure?: string;
}
export interface AddResponseCookie {
cookie: ResponseCookie;
}
export interface EditResponseCookie {
filter: ResponseCookie;
modification: ResponseCookie;
}
export interface CancelRequest { }
export interface RemoveRequestHeader {
name: string;
}
export interface EditRequestCookie {
filter: RequestCookie;
modification: RequestCookie;
}
export interface SetRequestHeader {
name: string;
value: string;
}
export interface RequestCookie {
name?: string;
value?: string;
}
export interface RedirectByRegEx {
to: string;
from: string;
}
export interface RedirectToTransparentImage { }
export interface AddRequestCookie {
cookie: RequestCookie;
}
export interface RemoveRequestCookie {
filter: RequestCookie;
}
export interface RequestedEvent extends chrome.events.Event<Function> { }
export var onRequest: RequestedEvent;
}
////////////////////
// DesktopCapture
////////////////////
/**
* Desktop Capture API that can be used to capture content of screen, individual windows or tabs.
* Availability: Since Chrome 34.
* Permissions: "desktopCapture"
*/
declare namespace chrome.desktopCapture {
/**
* Shows desktop media picker UI with the specified set of sources.
* @param sources Set of sources that should be shown to the user.
* @param callback The callback parameter should be a function that looks like this:
* function(string streamId) {...};
* Parameter streamId: An opaque string that can be passed to getUserMedia() API to generate media stream that corresponds to the source selected by the user. If user didn't select any source (i.e. canceled the prompt) then the callback is called with an empty streamId. The created streamId can be used only once and expires after a few seconds when it is not used.
*/
export function chooseDesktopMedia(sources: string[], callback: (streamId: string) => void): number;
/**
* Shows desktop media picker UI with the specified set of sources.
* @param sources Set of sources that should be shown to the user.
* @param targetTab Optional tab for which the stream is created. If not specified then the resulting stream can be used only by the calling extension. The stream can only be used by frames in the given tab whose security origin matches tab.url.
* @param callback The callback parameter should be a function that looks like this:
* function(string streamId) {...};
* Parameter streamId: An opaque string that can be passed to getUserMedia() API to generate media stream that corresponds to the source selected by the user. If user didn't select any source (i.e. canceled the prompt) then the callback is called with an empty streamId. The created streamId can be used only once and expires after a few seconds when it is not used.
*/
export function chooseDesktopMedia(sources: string[], targetTab: chrome.tabs.Tab, callback: (streamId: string) => void): number;
/**
* Hides desktop media picker dialog shown by chooseDesktopMedia().
* @param desktopMediaRequestId Id returned by chooseDesktopMedia()
*/
export function cancelChooseDesktopMedia(desktopMediaRequestId: number): void;
}
////////////////////
// Dev Tools - Inspected Window
////////////////////
/**
* Use the chrome.devtools.inspectedWindow API to interact with the inspected window: obtain the tab ID for the inspected page, evaluate the code in the context of the inspected window, reload the page, or obtain the list of resources within the page.
* Availability: Since Chrome 18.
*/
declare namespace chrome.devtools.inspectedWindow {
/** A resource within the inspected page, such as a document, a script, or an image. */
export interface Resource {
/** The URL of the resource. */
url: string;
/**
* Gets the content of the resource.
* @param callback A function that receives resource content when the request completes.
* The callback parameter should be a function that looks like this:
* function(string content, string encoding) {...};
* Parameter content: Content of the resource (potentially encoded).
* Parameter encoding: Empty if content is not encoded, encoding name otherwise. Currently, only base64 is supported.
*/
getContent(callback: (content: string, encoding: string) => void): void;
/**
* Sets the content of the resource.
* @param content New content of the resource. Only resources with the text type are currently supported.
* @param commit True if the user has finished editing the resource, and the new content of the resource should be persisted; false if this is a minor change sent in progress of the user editing the resource.
* @param callback A function called upon request completion.
* If you specify the callback parameter, it should be a function that looks like this:
* function(object error) {...};
* Optional parameter error: Set to undefined if the resource content was set successfully; describes error otherwise.
*/
setContent(content: string, commit: boolean, callback?: (error: Object) => void): void;
}
export interface ReloadOptions {
/** Optional. If specified, the string will override the value of the User-Agent HTTP header that's sent while loading the resources of the inspected page. The string will also override the value of the navigator.userAgent property that's returned to any scripts that are running within the inspected page. */
userAgent?: string;
/** Optional. When true, the loader will ignore the cache for all inspected page resources loaded before the load event is fired. The effect is similar to pressing Ctrl+Shift+R in the inspected window or within the Developer Tools window. */
ignoreCache?: boolean;
/** Optional. If specified, the script will be injected into every frame of the inspected page immediately upon load, before any of the frame's scripts. The script will not be injected after subsequent reloads—for example, if the user presses Ctrl+R. */
injectedScript?: string;
/**
* Optional.
* If specified, this script evaluates into a function that accepts three string arguments: the source to preprocess, the URL of the source, and a function name if the source is an DOM event handler. The preprocessorerScript function should return a string to be compiled by Chrome in place of the input source. In the case that the source is a DOM event handler, the returned source must compile to a single JS function.
* @deprecated Deprecated since Chrome 41. Please avoid using this parameter, it will be removed soon.
*/
preprocessorScript?: string;
}
export interface EvaluationExceptionInfo {
/** Set if the error occurred on the DevTools side before the expression is evaluated. */
isError: boolean;
/** Set if the error occurred on the DevTools side before the expression is evaluated. */
code: string;
/** Set if the error occurred on the DevTools side before the expression is evaluated. */
description: string;
/** Set if the error occurred on the DevTools side before the expression is evaluated, contains the array of the values that may be substituted into the description string to provide more information about the cause of the error. */
details: any[];
/** Set if the evaluated code produces an unhandled exception. */
isException: boolean;
/** Set if the evaluated code produces an unhandled exception. */
value: string;
}
export interface ResourceAddedEvent extends chrome.events.Event<(resource: Resource) => void> { }
export interface ResourceContentCommittedEvent extends chrome.events.Event<(resource: Resource, content: string) => void> { }
/** The ID of the tab being inspected. This ID may be used with chrome.tabs.* API. */
export var tabId: number;
/** Reloads the inspected page. */
export function reload(reloadOptions: ReloadOptions): void;
/**
* Evaluates a JavaScript expression in the context of the main frame of the inspected page. The expression must evaluate to a JSON-compliant object, otherwise an exception is thrown. The eval function can report either a DevTools-side error or a JavaScript exception that occurs during evaluation. In either case, the result parameter of the callback is undefined. In the case of a DevTools-side error, the isException parameter is non-null and has isError set to true and code set to an error code. In the case of a JavaScript error, isException is set to true and value is set to the string value of thrown object.
* @param expression An expression to evaluate.
* @param callback A function called when evaluation completes.
* If you specify the callback parameter, it should be a function that looks like this:
* function(object result, object exceptionInfo) {...};
* Parameter result: The result of evaluation.
* Parameter exceptionInfo: An object providing details if an exception occurred while evaluating the expression.
*/
export function eval<T>(expression: string, callback?: (result: T, exceptionInfo: EvaluationExceptionInfo) => void): void;
/**
* Evaluates a JavaScript expression in the context of the main frame of the inspected page. The expression must evaluate to a JSON-compliant object, otherwise an exception is thrown. The eval function can report either a DevTools-side error or a JavaScript exception that occurs during evaluation. In either case, the result parameter of the callback is undefined. In the case of a DevTools-side error, the isException parameter is non-null and has isError set to true and code set to an error code. In the case of a JavaScript error, isException is set to true and value is set to the string value of thrown object.
* @param expression An expression to evaluate.
* @param options The options parameter can contain one or more options.
* @param callback A function called when evaluation completes.
* If you specify the callback parameter, it should be a function that looks like this:
* function(object result, object exceptionInfo) {...};
* Parameter result: The result of evaluation.
* Parameter exceptionInfo: An object providing details if an exception occurred while evaluating the expression.
*/
export function eval<T>(expression: string, options: EvalOptions, callback?: (result: T, exceptionInfo: EvaluationExceptionInfo) => void): void;
/**
* Retrieves the list of resources from the inspected page.
* @param callback A function that receives the list of resources when the request completes.
* The callback parameter should be a function that looks like this:
* function(array of Resource resources) {...};
*/
export function getResources(callback: (resources: Resource[]) => void): void;
/** Fired when a new resource is added to the inspected page. */
export var onResourceAdded: ResourceAddedEvent;
/** Fired when a new revision of the resource is committed (e.g. user saves an edited version of the resource in the Developer Tools). */
export var onResourceContentCommitted: ResourceContentCommittedEvent;
export interface EvalOptions {
/** If specified, the expression is evaluated on the iframe whose URL matches the one specified. By default, the expression is evaluated in the top frame of the inspected page. */
frameURL?: string;
/** Evaluate the expression in the context of the content script of the calling extension, provided that the content script is already injected into the inspected page. If not, the expression is not evaluated and the callback is invoked with the exception parameter set to an object that has the isError field set to true and the code field set to E_NOTFOUND. */
useContentScriptContext?: boolean;
/** Evaluate the expression in the context of a content script of an extension that matches the specified origin. If given, contextSecurityOrigin overrides the 'true' setting on userContentScriptContext. */
contextSecurityOrigin?: string;
}
}
////////////////////
// Dev Tools - Network
////////////////////
/**
* Use the chrome.devtools.network API to retrieve the information about network requests displayed by the Developer Tools in the Network panel.
* Availability: Since Chrome 18.
*/
declare namespace chrome.devtools.network {
/** Represents a network request for a document resource (script, image and so on). See HAR Specification for reference. */
export interface Request {
/**
* Returns content of the response body.
* @param callback A function that receives the response body when the request completes.
* The callback parameter should be a function that looks like this:
* function(string content, string encoding) {...};
* Parameter content: Content of the response body (potentially encoded).
* Parameter encoding: Empty if content is not encoded, encoding name otherwise. Currently, only base64 is supported.
*/
getContent(callback: (content: string, encoding: string) => void): void;
}
export interface RequestFinishedEvent extends chrome.events.Event<(request: Request) => void> { }
export interface NavigatedEvent extends chrome.events.Event<(url: string) => void> { }
/**
* Returns HAR log that contains all known network requests.
* @param callback A function that receives the HAR log when the request completes.
* The callback parameter should be a function that looks like this:
* function(object harLog) {...};
* Parameter harLog: A HAR log. See HAR specification for details.
*/
export function getHAR(callback: (harLog: Object) => void): void;
/** Fired when a network request is finished and all request data are available. */
export var onRequestFinished: RequestFinishedEvent;
/** Fired when the inspected window navigates to a new page. */
export var onNavigated: NavigatedEvent;
}
////////////////////
// Dev Tools - Panels
////////////////////
/**
* Use the chrome.devtools.panels API to integrate your extension into Developer Tools window UI: create your own panels, access existing panels, and add sidebars.
* Availability: Since Chrome 18.
*/
declare namespace chrome.devtools.panels {
export interface PanelShownEvent extends chrome.events.Event<(window: Window) => void> { }
export interface PanelHiddenEvent extends chrome.events.Event<() => void> { }
export interface PanelSearchEvent extends chrome.events.Event<(action: string, queryString?: string) => void> { }
/** Represents a panel created by extension. */
export interface ExtensionPanel {
/**
* Appends a button to the status bar of the panel.
* @param iconPath Path to the icon of the button. The file should contain a 64x24-pixel image composed of two 32x24 icons. The left icon is used when the button is inactive; the right icon is displayed when the button is pressed.
* @param tooltipText Text shown as a tooltip when user hovers the mouse over the button.
* @param disabled Whether the button is disabled.
*/
createStatusBarButton(iconPath: string, tooltipText: string, disabled: boolean): Button;
/** Fired when the user switches to the panel. */
onShown: PanelShownEvent;
/** Fired when the user switches away from the panel. */
onHidden: PanelHiddenEvent;
/** Fired upon a search action (start of a new search, search result navigation, or search being canceled). */
onSearch: PanelSearchEvent;
}
export interface ButtonClickedEvent extends chrome.events.Event<() => void> { }
/** A button created by the extension. */
export interface Button {
/**
* Updates the attributes of the button. If some of the arguments are omitted or null, the corresponding attributes are not updated.
* @param iconPath Path to the new icon of the button.
* @param tooltipText Text shown as a tooltip when user hovers the mouse over the button.
* @param disabled Whether the button is disabled.
*/
update(iconPath?: string | null, tooltipText?: string | null, disabled?: boolean | null): void;
/** Fired when the button is clicked. */
onClicked: ButtonClickedEvent;
}
export interface SelectionChangedEvent extends chrome.events.Event<() => void> { }
/** Represents the Elements panel. */
export interface ElementsPanel {
/**
* Creates a pane within panel's sidebar.
* @param title Text that is displayed in sidebar caption.
* @param callback A callback invoked when the sidebar is created.
* If you specify the callback parameter, it should be a function that looks like this:
* function( ExtensionSidebarPane result) {...};
* Parameter result: An ExtensionSidebarPane object for created sidebar pane.
*/
createSidebarPane(title: string, callback?: (result: ExtensionSidebarPane) => void): void;
/** Fired when an object is selected in the panel. */
onSelectionChanged: SelectionChangedEvent;
}
/**
* Since Chrome 41.
* Represents the Sources panel.
*/
export interface SourcesPanel {
/**
* Creates a pane within panel's sidebar.
* @param title Text that is displayed in sidebar caption.
* @param callback A callback invoked when the sidebar is created.
* If you specify the callback parameter, it should be a function that looks like this:
* function( ExtensionSidebarPane result) {...};
* Parameter result: An ExtensionSidebarPane object for created sidebar pane.
*/
createSidebarPane(title: string, callback?: (result: ExtensionSidebarPane) => void): void;
/** Fired when an object is selected in the panel. */
onSelectionChanged: SelectionChangedEvent;
}
export interface ExtensionSidebarPaneShownEvent extends chrome.events.Event<(window: chrome.windows.Window) => void> { }
export interface ExtensionSidebarPaneHiddenEvent extends chrome.events.Event<() => void> { }
/** A sidebar created by the extension. */
export interface ExtensionSidebarPane {
/**
* Sets the height of the sidebar.
* @param height A CSS-like size specification, such as '100px' or '12ex'.
*/
setHeight(height: string): void;
/**
* Sets an expression that is evaluated within the inspected page. The result is displayed in the sidebar pane.
* @param expression An expression to be evaluated in context of the inspected page. JavaScript objects and DOM nodes are displayed in an expandable tree similar to the console/watch.
* @param rootTitle An optional title for the root of the expression tree.
* @param callback A callback invoked after the sidebar pane is updated with the expression evaluation results.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
setExpression(expression: string, rootTitle?: string, callback?: () => void): void;
/**
* Sets an expression that is evaluated within the inspected page. The result is displayed in the sidebar pane.
* @param expression An expression to be evaluated in context of the inspected page. JavaScript objects and DOM nodes are displayed in an expandable tree similar to the console/watch.
* @param callback A callback invoked after the sidebar pane is updated with the expression evaluation results.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
setExpression(expression: string, callback?: () => void): void;
/**
* Sets a JSON-compliant object to be displayed in the sidebar pane.
* @param jsonObject An object to be displayed in context of the inspected page. Evaluated in the context of the caller (API client).
* @param rootTitle An optional title for the root of the expression tree.
* @param callback A callback invoked after the sidebar is updated with the object.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
setObject(jsonObject: Object, rootTitle?: string, callback?: () => void): void;
/**
* Sets a JSON-compliant object to be displayed in the sidebar pane.
* @param jsonObject An object to be displayed in context of the inspected page. Evaluated in the context of the caller (API client).
* @param callback A callback invoked after the sidebar is updated with the object.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
setObject(jsonObject: Object, callback?: () => void): void;
/**
* Sets an HTML page to be displayed in the sidebar pane.
* @param path Relative path of an extension page to display within the sidebar.
*/
setPage(path: string): void;
/** Fired when the sidebar pane becomes visible as a result of user switching to the panel that hosts it. */
onShown: ExtensionSidebarPaneShownEvent;
/** Fired when the sidebar pane becomes hidden as a result of the user switching away from the panel that hosts the sidebar pane. */
onHidden: ExtensionSidebarPaneHiddenEvent;
}
/** Elements panel. */
export var elements: ElementsPanel;
/**
* Since Chrome 38.
* Sources panel.
*/
export var sources: SourcesPanel;
/**
* Creates an extension panel.
* @param title Title that is displayed next to the extension icon in the Developer Tools toolbar.
* @param iconPath Path of the panel's icon relative to the extension directory.
* @param pagePath Path of the panel's HTML page relative to the extension directory.
* @param callback A function that is called when the panel is created.
* 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.
* @param callback A function that is called when the user clicks on a valid resource link in Developer Tools window. Note that if the user clicks an invalid URL or an XHR, this function is not called.
* If you specify the callback parameter, it should be a function that looks like this:
* function( devtools.inspectedWindow.Resource resource) {...};
* Parameter resource: A devtools.inspectedWindow.Resource object for the resource that was clicked.
*/
export function setOpenResourceHandler(callback?: (resource: chrome.devtools.inspectedWindow.Resource) => void): void;
/**
* Since Chrome 38.
* Requests DevTools to open a URL in a Developer Tools panel.
* @param url The URL of the resource to open.
* @param lineNumber Specifies the line number to scroll to when the resource is loaded.
* @param callback A function that is called when the resource has been successfully loaded.
* If you specify the callback parameter, it should be a function that looks like this:
* function() {...};
*/
export function openResource(url: string, lineNumber: number, callback: () => void): void;
}
////////////////////
// Document Scan
////////////////////
/**
* Use the chrome.documentScan API to discover and retrieve images from attached paper document scanners.
* Availability: Since Chrome 44.
* Permissions: "documentScan"
* Important: This API works only on Chrome OS.
*/
declare namespace chrome.documentScan {
export interface DocumentScanOptions {
/** Optional. The MIME types that are accepted by the caller. */
mimeTypes?: string[];
/** Optional. The number of scanned images allowed (defaults to 1). */
maxImages?: number;
}
export interface DocumentScanCallbackArg {
/** The data image URLs in a form that can be passed as the "src" value to an image tag. */
dataUrls: string[];
/** The MIME type of dataUrls. */
mimeType: string;
}
/**
* Performs a document scan. On success, the PNG data will be sent to the callback.
* @param options Object containing scan parameters.
* @param callback Called with the result and data from the scan.
* The callback parameter should be a function that looks like this:
* function(object result) {...};
*/
export function scan(options: DocumentScanOptions, callback: (result: DocumentScanCallbackArg) => void): void;
}
////////////////////
// Dev Tools - Downloads
////////////////////
/**
* Use the chrome.downloads API to programmatically initiate, monitor, manipulate, and search for downloads.
* Availability: Since Chrome 31.
* Permissions: "downloads"
*/
declare namespace chrome.downloads {
export interface HeaderNameValuePair {
/** Name of the HTTP header. */
name: string;
/** Value of the HTTP header. */
value: string;
}
export interface DownloadOptions {
/** Optional. Post body. */
body?: string;
/** Optional. 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;
/** Optional. 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;
/** Optional. 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[];
/** Optional. The HTTP method to use if the URL uses the HTTP[S] protocol. */
method?: string;
/** Optional. The action to take if filename already exists. */
conflictAction?: string;
}
export interface DownloadDelta {
/** The id of the DownloadItem that changed. */
id: number;
/** Optional. The change in danger, if any. */
danger?: StringDelta;
/** Optional. The change in url, if any. */
url?: StringDelta;
/**
* Optional. The change in finalUrl, if any.
* @since Since Chrome 54.
*/
finalUrl: StringDelta;
/** Optional. The change in totalBytes, if any. */
totalBytes?: DoubleDelta;
/** Optional. The change in filename, if any. */
filename?: StringDelta;
/** Optional. The change in paused, if any. */
paused?: BooleanDelta;
/** Optional. The change in state, if any. */
state?: StringDelta;
/** Optional. The change in mime, if any. */
mime?: StringDelta;
/** Optional. The change in fileSize, if any. */
fileSize?: DoubleDelta;
/** Optional. The change in startTime, if any. */
startTime?: StringDelta;
/** Optional. The change in error, if any. */
error?: StringDelta;
/** Optional. The change in endTime, if any. */
endTime?: StringDelta;
/** Optional. The change in canResume, if any. */
canResume?: BooleanDelta;
/** Optional. The change in exists, if any. */
exists?: BooleanDelta;
}
export interface BooleanDelta {
current?: boolean;
previous?: boolean;
}
/** Since Chrome 34. */
export interface DoubleDelta {
current?: number;
previous?: number;
}
export interface StringDelta {
current?: string;
previous?: string;
}
export 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;
/** The absolute URL that this download initiated from, before any redirects. */
url: string;
/**
* The absolute URL that this download is being made from, after all redirects.
* @since Since Chrome 54.
*/
finalUrl: string;
/** Number of bytes in the whole file, without considering file compression, or -1 if unknown. */
totalBytes: number;
/** 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;
/** 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;
/** Optional. 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;
/** Optional. 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;
/** Optional. 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;
/** Optional. 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;
/** Optional. 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;
}
export interface GetFileIconOptions {
/** Optional. * 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;
}
export interface DownloadQuery {
/** Optional. 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[];
/** Optional. Limits results to DownloadItem whose url matches the given regular expression. */
urlRegex?: string;
/** Optional. Limits results to DownloadItem that ended before the time in ISO 8601 format. */
endedBefore?: string;
/** Optional. Limits results to DownloadItem whose totalBytes is greater than the given integer. */
totalBytesGreater?: number;
/** Optional. Indication of whether this download is thought to be safe or known to be suspicious. */
danger?: string;
/** Optional. Number of bytes in the whole file, without considering file compression, or -1 if unknown. */
totalBytes?: number;
/** Optional. True if the download has stopped reading data from the host, but kept the connection open. */
paused?: boolean;
/** Optional. Limits results to DownloadItem whose filename matches the given regular expression. */
filenameRegex?: string;
/** Optional. 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[];
/** Optional. Limits results to DownloadItem whose totalBytes is less than the given integer. */
totalBytesLess?: number;
/** Optional. The id of the DownloadItem to query. */
id?: number;
/** Optional. Number of bytes received so far from the host, without considering file compression. */
bytesReceived?: number;
/** Optional. Limits results to DownloadItem that ended after the time in ISO 8601 format. */
endedAfter?: string;
/** Optional. Absolute local path. */
filename?: string;
/** Optional. Indicates whether the download is progressing, interrupted, or complete. */
state?: string;
/** Optional. Limits results to DownloadItem that started after the time in ISO 8601 format. */
startedAfter?: string;
/** Optional. The file's MIME type. */
mime?: string;
/** Optional. Number of bytes in the whole file post-decompression, or -1 if unknown. */
fileSize?: number;
/** Optional. The time when the download began in ISO 8601 format. */
startTime?: string;
/** Optional. Absolute URL. */
url?: string;
/** Optional. Limits results to DownloadItem that started before the time in ISO 8601 format. */
startedBefore?: string;
/** Optional. 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;
/** Optional. Why a download was interrupted. */
error?: number;
/** Optional. The time when the download ended in ISO 8601 format. */
endTime?: string;
/** Optional. Whether the downloaded file exists; */
exists?: boolean;
}
export 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;
/** Optional. The action to take if filename already exists. */
conflictAction?: string;
}
export interface DownloadChangedEvent extends chrome.events.Event<(downloadDelta: DownloadDelta) => void> { }
export interface DownloadCreatedEvent extends chrome.events.Event<(downloadItem: DownloadItem) => void> { }
export interface DownloadErasedEvent extends chrome.events.Event<(downloadId: number) => void> { }
export interface DownloadDeterminingFilenameEvent extends chrome.events.Event<(downloadItem: DownloadItem, suggest: (suggestion?: DownloadFilenameSuggestion) => 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;
/**
* 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;
/**
* 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;
/**
* 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. */
export var onChanged: DownloadChangedEvent;
/** This event fires with the DownloadItem object when a download begins. */
export var onCreated: DownloadCreatedEvent;
/** Fires with the downloadId when a download is erased from history. */
export 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. */
export 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 namespace chrome.enterprise.platformKeys {
export 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;
}
////////////////////
// Enterprise Device Attributes
////////////////////
/**
* Use the <code>chrome.enterprise.deviceAttributes</code> API to read device attributes.
* Permissions: "enterprise.deviceAttributes"
* Since: Chrome 46
* Important: This API works only on Chrome OS.
* Note: This API is only for extensions pre-installed by policy.
*/
declare namespace chrome.enterprise.deviceAttributes {
/**
* @description Fetches the value of the device identifier of the directory API, that is generated by the server and identifies the cloud record of the device for querying in the cloud directory API.
* @export
* @param callback Called with the device identifier of the directory API when received.
* The callback parameter should be a function that looks like this:
* function(string deviceId) {...};
*/
export function getDirectoryDeviceId(callback: (deviceId: string) => void): void;
/**
* @since Chrome 66.
* @description
* Fetches the device's serial number.
* Please note the purpose of this API is to administrate the device
* (e.g. generating Certificate Sign Requests for device-wide certificates).
* This API may not be used for tracking devices without the consent of the device's administrator.
* If the current user is not affiliated, returns an empty string.
* @param callback Called with the serial number of the device.
*/
export function getDeviceSerialNumber(callback: (serialNumber: string) => void): void;
/**
* @since Chrome 66.
* @description
* Fetches the administrator-annotated Asset Id.
* If the current user is not affiliated or no Asset Id has been set by the administrator, returns an empty string.
* @param callback Called with the Asset ID of the device.
*/
export function getDeviceAssetId(callback: (assetId: string) => void): void;
/**
* @since Chrome 66.
* @description
* Fetches the administrator-annotated Location.
* If the current user is not affiliated or no Annotated Location has been set by the administrator, returns an empty string.
* @param callback Called with the Annotated Location of the device.
*/
export function getDeviceAnnotatedLocation(callback: (annotatedLocation: string) => 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 namespace chrome.events {
/** Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */
export interface UrlFilter {
/** Optional. Matches if the scheme of the URL is equal to any of the schemes specified in the array. */
schemes?: string[];
/**
* Optional.
* 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;
/** Optional. Matches if the path segment of the URL contains a specified string. */
pathContains?: string;
/** Optional. Matches if the host name of the URL ends with a specified string. */
hostSuffix?: string;
/** Optional. Matches if the host name of the URL starts with a specified string. */
hostPrefix?: string;
/** Optional. 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;
/** Optional. 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;
/** Optional. Matches if the query segment of the URL ends with a specified string. */
querySuffix?: string;
/** Optional. 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;
/** Optional. Matches if the host name of the URL is equal to a specified string. */
hostEquals?: string;
/** Optional. 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;
/** Optional. Matches if the query segment of the URL contains a specified string. */
queryContains?: string;
/** Optional. Matches if the path segment of the URL starts with a specified string. */
pathPrefix?: string;
/** Optional. Matches if the path segment of the URL is equal to a specified string. */
pathEquals?: string;
/** Optional. Matches if the path segment of the URL ends with a specified string. */
pathSuffix?: string;
/** Optional. Matches if the query segment of the URL is equal to a specified string. */
queryEquals?: string;
/** Optional. Matches if the query segment of the URL starts with a specified string. */
queryPrefix?: string;
/** Optional. 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;
/** Optional. 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[];
/**
* Optional.
* 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. */
export interface Event<T extends Function> {
/**
* 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: T): 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: T): boolean;
/**
* 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;
/**
* 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: T): void;
hasListeners(): boolean;
}
/** Description of a declarative rule for handling events. */
export interface Rule {
/** Optional. Optional priority of this rule. Defaults to 100. */
priority?: number;
/** List of conditions that can trigger the actions. */
conditions: any[];
/** Optional. Optional identifier that allows referencing this rule. */
id?: string;
/** List of actions that are triggered if one of the condtions is fulfilled. */
actions: any[];
/**
* Optional.
* 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 namespace chrome.extension {
export interface FetchProperties {
/** Optional. The window to restrict the search to. If omitted, returns all views. */
windowId?: number;
/** Optional. The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: 'tab', 'notification', 'popup'. */
type?: string;
}
export interface LastError {
/** Description of the error that has taken place. */
message: string;
}
export interface OnRequestEvent extends chrome.events.Event<((request: any, sender: runtime.MessageSender, sendResponse: (response: any) => void) => void) | ((sender: runtime.MessageSender, sendResponse: (response: any) => 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.
*/
export 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. */
export 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 | null;
/**
* 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.
*/
export var onRequest: OnRequestEvent;
/**
* Fired when a request is sent from another extension.
* @deprecated Deprecated since Chrome 33. Please use runtime.onMessageExternal.
*/
export 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 namespace chrome.fileBrowserHandler {
export interface SelectionParams {
/**
* Optional.
* 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;
}
export interface SelectionResult {
/** Optional. Selected file entry. It will be null if a file hasn't been selected. */
entry?: Object | null;
/** Whether the file has been selected. */
success: boolean;
}
/** Event details payload for fileBrowserHandler.onExecute event. */
export interface FileHandlerExecuteEventDetails {
/** Optional. 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[];
}
export interface FileBrowserHandlerExecuteEvent extends chrome.events.Event<(id: string, details: FileHandlerExecuteEventDetails) => 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. */
export 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 namespace chrome.fileSystemProvider {
export 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;
}
export 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;
/** Optional. Tag used by the last notification for the watcher. */
lastTag?: string;
}
export 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;
/** Optional. Mime type for the entry. */
mimeType?: string;
/** Optional. 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;
}
export 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[];
/**
* Optional.
* 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. */
export 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. */
export interface Action {
/** The identifier of the action. Any string or CommonActionId for common actions. */
id: string;
/** Optional. 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. */
export 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;
}
export 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;
/** Optional. Whether the file system supports operations which may change contents of the file system (such as creating, deleting or writing to files). */
writable?: boolean;
/**
* Optional.
* 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;
/**
* Optional.
* Whether the file system supports the tag field for observed directories.
* @since Since Chrome 45. Warning: this is the current Beta channel.
*/
supportsNotifyTag?: boolean;
}
export interface UnmountOptions {
/** The identifier of the file system to be unmounted. */
fileSystemId: string;
}
export interface NotificationChange {
/** The path of the changed entry. */
entryPath: string;
/** The type of the change which happened to the entry. */
changeType: string;
}
export 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;
/** Optional. List of changes to entries within the observed directory (including the entry itself) */
changes?: NotificationChange[];
/** Optional. 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;
}
export interface RequestedEventOptions {
/** The identifier of the file system related to this operation. */
fileSystemId: string;
/** The unique identifier of this request. */
requestId: number;
}
export interface EntryPathRequestedEventOptions extends RequestedEventOptions {
/** The path of the entry to which this operation is related to. */
entryPath: string;
}
export interface MetadataRequestedEventOptions extends EntryPathRequestedEventOptions {
/** Set to true if the thumbnail is requested. */
thumbnail: boolean;
}
export interface DirectoryPathRequestedEventOptions extends RequestedEventOptions {
/** The path of the directory which is to be operated on. */
directoryPath: string;
}
export interface FilePathRequestedEventOptions extends RequestedEventOptions {
/** The path of the entry for the operation */
filePath: string;
}
export interface OpenFileRequestedEventOptions extends FilePathRequestedEventOptions {
/** Whether the file will be used for reading or writing. */
mode: string;
}
export interface OpenedFileRequestedEventOptions extends RequestedEventOptions {
/** A request ID used to open the file. */
openRequestId: number;
}
export interface OpenedFileOffsetRequestedEventOptions extends OpenedFileRequestedEventOptions {
/** Position in the file (in bytes) to start reading from. */
offset: number;
/** Number of bytes to be returned. */
length: number;
}
export interface DirectoryPathRecursiveRequestedEventOptions extends DirectoryPathRequestedEventOptions {
/** Whether the operation is recursive (for directories only). */
recursive: boolean;
}
export interface EntryPathRecursiveRequestedEventOptions extends EntryPathRequestedEventOptions {
/** Whether the operation is recursive (for directories only). */
recursive: boolean;
}
export interface SourceTargetPathRequestedEventOptions extends RequestedEventOptions {
/** The source path for the operation. */
sourcePath: string;
/** The destination path for the operation. */
targetPath: string;
}
export interface FilePathLengthRequestedEventOptions extends FilePathRequestedEventOptions {
/** Number of bytes to be retained after the operation completes. */
length: number;
}
export 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;
}
export interface OperationRequestedEventOptions extends RequestedEventOptions {
/** An ID of the request to which this operation is related. */
operationRequestId: number;
}
export interface RequestedEvent extends chrome.events.Event<(options: RequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> { }
export interface MetadataRequestedEvent extends chrome.events.Event<(options: MetadataRequestedEventOptions, successCallback: (metadata: EntryMetadata) => void, errorCallback: (error: string) => void) => void> { }
export interface DirectoryPathRequestedEvent extends chrome.events.Event<(options: DirectoryPathRequestedEventOptions, successCallback: (entries: EntryMetadata[], hasMore: boolean) => void, errorCallback: (error: string) => void) => void> { }
export interface OpenFileRequestedEvent extends chrome.events.Event<(options: OpenFileRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> { }
export interface OpenedFileRequestedEvent extends chrome.events.Event<(options: OpenedFileRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> { }
export interface OpenedFileOffsetRequestedEvent extends chrome.events.Event<(options: OpenedFileOffsetRequestedEventOptions, successCallback: (data: ArrayBuffer, hasMore: boolean) => void, errorCallback: (error: string) => void) => void> { }
export interface DirectoryPathRecursiveRequestedEvent extends chrome.events.Event<(options: DirectoryPathRecursiveRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> { }
export interface EntryPathRecursiveRequestedEvent extends chrome.events.Event<(options: EntryPathRecursiveRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> { }
export interface FilePathRequestedEvent extends chrome.events.Event<(options: FilePathRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> { }
export interface SourceTargetPathRequestedEvent extends chrome.events.Event<(options: SourceTargetPathRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> { }
export interface FilePathLengthRequestedEvent extends chrome.events.Event<(options: FilePathLengthRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> { }
export interface OpenedFileIoRequestedEvent extends chrome.events.Event<(options: OpenedFileIoRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> { }
export interface OperationRequestedEvent extends chrome.events.Event<(options: OperationRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> { }
export interface OptionlessRequestedEvent extends chrome.events.Event<(successCallback: Function, errorCallback: (error: string) => 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. */
export 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. */
export 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. */
export 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. */
export var onOpenFileRequested: OpenFileRequestedEvent;
/** Raised when opening a file previously opened with openRequestId is requested to be closed. */
export 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. */
export 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. */
export 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. */
export 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. */
export var onCreateFileRequested: FilePathRequestedEvent;
/** Raised when copying an entry (recursively if a directory) is requested. If an error occurs, then errorCallback must be called. */
export var onCopyEntryRequested: SourceTargetPathRequestedEvent;
/** Raised when moving an entry (recursively if a directory) is requested. If an error occurs, then errorCallback must be called. */
export var onMoveEntryRequested: SourceTargetPathRequestedEvent;
/** Raised when truncating a file to a desired length is requested. If an error occurs, then errorCallback must be called. */
export var onTruncateRequested: FilePathLengthRequestedEvent;
/** Raised when writing contents to a file opened previously with openRequestId is requested. */
export 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. */
export 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.
*/
export 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.
*/
export 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.
*/
export 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.
*/
export var onRemoveWatcherRequested: EntryPathRecursiveRequestedEvent;
}
////////////////////
// Font Settings
////////////////////
/**
* Use the chrome.fontSettings API to manage Chrome's font settings.
* Availability: Since Chrome 22.
* Permissions: "fontSettings"
*/
declare namespace chrome.fontSettings {
/** Represents a font name. */
export interface FontName {
/** The display name of the font. */
displayName: string;
/** The font ID. */
fontId: string;
}
export interface DefaultFontSizeDetails {
/** The font size in pixels. */
pixelSize: number;
}
export interface FontDetails {
/** The generic font family for the font. */
genericFamily: string;
/** Optional. The script for the font. If omitted, the global script font setting is affected. */
script?: string;
}
export interface FullFontDetails {
/** The generic font family for which the font setting has changed. */
genericFamily: string;
/** The level of control this extension has over the setting. */
levelOfControl: string;
/** Optional. The script code for which the font setting has changed. */
script?: string;
/** The font ID. See the description in getFont. */
fontId: string;
}