UNPKG

declarations

Version:

[![npm version](https://badge.fury.io/js/declarations.svg)](https://www.npmjs.com/package/declarations)

1,048 lines (984 loc) 377 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> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// <reference path='../webrtc/MediaStream.d.ts'/> /// <reference path='../filesystem/filesystem.d.ts' /> //////////////////// // 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 { interface AccessibilityFeaturesGetArg { /** Optional. Whether to return the value that applies to the incognito session (default false). */ incognito?: boolean; } 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; } 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; } 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; } 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; } var spokenFeedback: AccessibilityFeaturesSetting; var largeCursor: AccessibilityFeaturesSetting; var stickyKeys: AccessibilityFeaturesSetting; var highContrast: AccessibilityFeaturesSetting; var screenMagnifier: AccessibilityFeaturesSetting; var autoclick: AccessibilityFeaturesSetting; var virtualKeyboard: AccessibilityFeaturesSetting; 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 { 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; } 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; } 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. */ var onAlarm: AlarmEvent; } /** * Use the chrome.browser API to interact with the Chrome browser associated with * the current application and Chrome profile. */ declare namespace chrome.browser { 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. */ 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; } interface BookmarkRemoveInfo { index: number; parentId: string; } interface BookmarkMoveInfo { index: number; oldIndex: number; parentId: string; oldParentId: string; } interface BookmarkChangeInfo { url?: string; title: string; } interface BookmarkReorderInfo { childIds: string[]; } interface BookmarkRemovedEvent extends chrome.events.Event<(id: string, removeInfo: BookmarkRemoveInfo) => void> {} interface BookmarkImportEndedEvent extends chrome.events.Event<() => void> {} interface BookmarkMovedEvent extends chrome.events.Event<(id: string, moveInfo: BookmarkMoveInfo) => void> {} interface BookmarkImportBeganEvent extends chrome.events.Event<() => void> {} interface BookmarkChangedEvent extends chrome.events.Event<(id: string, changeInfo: BookmarkChangeInfo) => void> {} interface BookmarkCreatedEvent extends chrome.events.Event<(id: string, bookmark: BookmarkTreeNode) => void> {} interface BookmarkChildrenReordered extends chrome.events.Event<(id: string, reorderInfo: BookmarkReorderInfo) => void> {} interface BookmarkSearchQuery { query?: string; url?: string; title?: string; } interface BookmarkCreateArg { /** Optional. Defaults to the Other Bookmarks folder. */ parentId?: string; index?: number; title?: string; url?: string; } interface BookmarkDestinationArg { parentId?: string; index?: number; } interface BookmarkChangesArg { title?: string; url?: string; } /** @deprecated since Chrome 38. Bookmark write operations are no longer limited by Chrome. */ var MAX_WRITE_OPERATIONS_PER_HOUR: number; /** @deprecated since Chrome 38. Bookmark write operations are no longer limited by Chrome. */ 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. */ var onRemoved: BookmarkRemovedEvent; /** Fired when a bookmark import session is ended. */ 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. */ var onImportBegan: BookmarkImportBeganEvent; /** Fired when a bookmark or folder changes. Note: Currently, only title and url changes trigger this. */ var onChanged: BookmarkChangedEvent; /** Fired when a bookmark or folder is moved to a different parent folder. */ var onMoved: BookmarkMovedEvent; /** Fired when a bookmark or folder is created. */ 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(). */ 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 { 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: any; /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number; } 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; } 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; } interface TabDetails { /** Optional. Specify the tab to get the information. If no tab is specified, the non-tab-specific information is returned. */ tabId?: number; } 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; } 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; } 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. */ export function enable(tabId?: number): void; /** Sets the background color for the badge. */ export function setBadgeBackgroundColor(details: BadgeBackgroundColorDetails): void; /** Sets the badge text for the browser action. The badge is displayed on top of the icon. */ export function setBadgeText(details: BadgeTextDetails): void; /** Sets the title of the browser action. This shows up in the tooltip. */ export function setTitle(details: TitleDetails): 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 The callback parameter should be a function that looks like this: * function(string result) {...}; */ 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. */ export function setPopup(details: PopupDetails): 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. */ export function disable(tabId?: number): 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: number[]) => 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. */ 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 { 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. */ 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. */ 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; } 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 { 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; } 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. */ 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 { 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?: string; } 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?: string; /** The pattern for the primary URL. For details on the format of a pattern, see Content Setting Patterns. */ primaryPattern: string; } 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; } interface ReturnedDetails { /** The content setting. See the description of the individual ContentSetting objects for the possible values. */ setting: any; } 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; } /** The only content type using resource identifiers is contentSettings.plugins. For more information, see Resource Identifiers. */ 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. */ var cookies: ContentSetting; /** * 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. */ var popups: ContentSetting; /** * 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. */ var javascript: ContentSetting; /** * 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. */ var notifications: ContentSetting; /** * 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. */ var plugins: ContentSetting; /** * 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. */ var images: ContentSetting; /** * 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). */ var location: ContentSetting; /** * 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). */ var fullscreen: ContentSetting; /** * 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. */ var mouselock: ContentSetting; /** * 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. */ var unsandboxedPlugins: ContentSetting; /** * 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. */ var automaticDownloads: ContentSetting; } //////////////////// // 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 { 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 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; } 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; } interface UpdateProperties {