chrome-types
Version:
TypeScript definitions for Chrome extensions
1,426 lines (1,151 loc) • 1.29 MB
TypeScript
/**
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated on Fri Jan 16 2026 22:25:38 GMT+0000 (Coordinated Universal Time)
// Built at d848dfaecedc6a6d47988fa2f68932d934dd9275
// Includes all types, including MV2 + Platform Apps APIs.
// These are stubs for DOM APIs not nessecarily available in TS' defaults.
interface Entry {}
interface FileEntry extends Entry {}
interface DirectoryEntry extends Entry {}
interface LocalMediaStream {}
interface DOMFileSystem extends FileSystem {}
// This is used to support addListener() where additional parameters are supported.
// The name is detected inside the developer.chrome.com repository and special actions are taken.
type CustomChromeEvent<H extends (...args: any) => void> =
Omit<chrome.events.Event<H>, 'addListener'> & {
// nb. This just copies the description from `chrome.events.Event.addListener`.
/**
* Registers an event listener _callback_ to an event.
*/
readonly addListener: H;
};
declare namespace chrome {
/**
* Use the `chrome.accessibilityFeatures` API to manage Chrome's accessibility features. This API relies on the [ChromeSetting prototype of the type API](https://developer.chrome.com/docs/extensions/reference/types/#ChromeSetting) 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.
*
* @chrome-permission accessibilityFeatures.modify
* @chrome-permission accessibilityFeatures.read
* @chrome-platform chromeos
* @chrome-platform linux
* @chrome-platform mac
* @chrome-platform win
*/
export namespace accessibilityFeatures {
/**
* **ChromeOS only.**
*
* Spoken feedback (text-to-speech). The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*/
export const spokenFeedback: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* Enlarged cursor. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*/
export const largeCursor: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* Sticky modifier keys (like shift or alt). The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*/
export const stickyKeys: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* High contrast rendering mode. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*/
export const highContrast: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* Full screen magnification. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*/
export const screenMagnifier: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* Auto mouse click after mouse stops moving. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*/
export const autoclick: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* Virtual on-screen keyboard. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*/
export const virtualKeyboard: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* Caret highlighting. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*
* @since Chrome 51
*/
export const caretHighlight: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* Cursor highlighting. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*
* @since Chrome 51
*/
export const cursorHighlight: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* Cursor color. The value indicates whether the feature is enabled or not, doesn't indicate the color of it. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*
* @since Chrome 85
*/
export const cursorColor: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* Docked magnifier. The value indicates whether docked magnifier feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*
* @since Chrome 87
*/
export const dockedMagnifier: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* Focus highlighting. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*
* @since Chrome 51
*/
export const focusHighlight: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* Select-to-speak. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*
* @since Chrome 51
*/
export const selectToSpeak: types.ChromeSetting<boolean>;
/**
* **ChromeOS only.**
*
* Switch Access. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*
* @since Chrome 51
*/
export const switchAccess: types.ChromeSetting<boolean>;
/**
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*/
export const animationPolicy: types.ChromeSetting<"allowed" | "once" | "none">;
/**
* **ChromeOS only.**
*
* Dictation. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
*
* @since Chrome 90
*/
export const dictation: types.ChromeSetting<boolean>;
}
/**
* Use the `chrome.action` API to control the extension's icon in the Google Chrome toolbar.
*
* @since Chrome 88
* @chrome-manifest action
* @chrome-min-manifest MV3
*/
export namespace action {
export interface TabDetails {
/**
* The ID of the tab to query state for. If no tab is specified, the non-tab-specific state is returned.
*/
tabId?: number;
}
/**
* The collection of user-specified settings relating to an extension's action.
*
* @since Chrome 91
*/
export interface UserSettings {
/**
* Whether the extension's action icon is visible on browser windows' top-level toolbar (i.e., whether the extension has been 'pinned' by the user).
*/
isOnToolbar: boolean;
}
/**
* @since Chrome 130
*/
export interface UserSettingsChange {
/**
* Whether the extension's action icon is visible on browser windows' top-level toolbar (i.e., whether the extension has been 'pinned' by the user).
*/
isOnToolbar?: boolean;
}
/**
* @since Chrome 99
*/
export interface OpenPopupOptions {
/**
* The ID of the window to open the action popup in. Defaults to the currently-active window if unspecified.
*/
windowId?: number;
}
/**
* Fired when an action icon is clicked. This event will not fire if the action has a popup.
*/
export const onClicked: events.Event<(
tab: tabs.Tab,
) => void>;
/**
* Fired when user-specified settings relating to an extension's action change.
*
* @since Chrome 130
*/
export const onUserSettingsChanged: events.Event<(
change: UserSettingsChange,
) => void>;
/**
* Sets the title of the action. This shows up in the tooltip.
*/
export function setTitle(
details: {
/**
* The string the action should display when moused over.
*/
title: string,
/**
* Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
*/
tabId?: number,
},
): Promise<void>;
/**
* Sets the title of the action. This shows up in the tooltip.
*/
export function setTitle(
details: {
/**
* The string the action should display when moused over.
*/
title: string,
/**
* Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
*/
tabId?: number,
},
callback?: () => void,
): void;
/**
* Gets the title of the action.
*/
export function getTitle(
details: TabDetails,
): Promise<string>;
/**
* Gets the title of the action.
*/
export function getTitle(
details: TabDetails,
callback?: (
result: string,
) => void,
): void;
/**
* Sets the icon for the 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.
*
* @chrome-returns-extra since Chrome 96
*/
export function setIcon(
details: {
/**
* 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` \* n will be selected, where n is the size of the icon in the UI. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'16': foo}'
*/
imageData?: extensionTypes.ImageDataType | {[name: string]: any},
/**
* 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` \* n will be selected, where n is the size of the icon in the UI. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.path = {'16': foo}'
*/
path?: string | {[name: string]: any},
/**
* Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
*/
tabId?: number,
},
): Promise<void>;
/**
* Sets the icon for the 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.
*/
export function setIcon(
details: {
/**
* 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` \* n will be selected, where n is the size of the icon in the UI. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'16': foo}'
*/
imageData?: extensionTypes.ImageDataType | {[name: string]: any},
/**
* 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` \* n will be selected, where n is the size of the icon in the UI. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.path = {'16': foo}'
*/
path?: string | {[name: string]: any},
/**
* Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
*/
tabId?: number,
},
callback?: () => void,
): void;
/**
* Sets the HTML document to be opened as a popup when the user clicks on the action's icon.
*/
export function setPopup(
details: {
/**
* Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
*/
tabId?: number,
/**
* The relative path to the HTML file to show in a popup. If set to the empty string (`''`), no popup is shown.
*/
popup: string,
},
): Promise<void>;
/**
* Sets the HTML document to be opened as a popup when the user clicks on the action's icon.
*/
export function setPopup(
details: {
/**
* Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
*/
tabId?: number,
/**
* The relative path to the HTML file to show in a popup. If set to the empty string (`''`), no popup is shown.
*/
popup: string,
},
callback?: () => void,
): void;
/**
* Gets the html document set as the popup for this action.
*/
export function getPopup(
details: TabDetails,
): Promise<string>;
/**
* Gets the html document set as the popup for this action.
*/
export function getPopup(
details: TabDetails,
callback?: (
result: string,
) => void,
): void;
/**
* Sets the badge text for the action. The badge is displayed on top of the icon.
*/
export function setBadgeText(
details: {
/**
* Any number of characters can be passed, but only about four can fit in the space. If an empty string (`''`) is passed, the badge text is cleared. If `tabId` is specified and `text` is null, the text for the specified tab is cleared and defaults to the global badge text.
*/
text?: string,
/**
* Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
*/
tabId?: number,
},
): Promise<void>;
/**
* Sets the badge text for the action. The badge is displayed on top of the icon.
*/
export function setBadgeText(
details: {
/**
* Any number of characters can be passed, but only about four can fit in the space. If an empty string (`''`) is passed, the badge text is cleared. If `tabId` is specified and `text` is null, the text for the specified tab is cleared and defaults to the global badge text.
*/
text?: string,
/**
* Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
*/
tabId?: number,
},
callback?: () => void,
): void;
/**
* Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned. If [displayActionCountAsBadgeText](https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/#setExtensionActionOptions) is enabled, a placeholder text will be returned unless the [declarativeNetRequestFeedback](https://developer.chrome.com/docs/extensions/develop/concepts/declare-permissions#declarativeNetRequestFeedback) permission is present or tab-specific badge text was provided.
*/
export function getBadgeText(
details: TabDetails,
): Promise<string>;
/**
* Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned. If [displayActionCountAsBadgeText](https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/#setExtensionActionOptions) is enabled, a placeholder text will be returned unless the [declarativeNetRequestFeedback](https://developer.chrome.com/docs/extensions/develop/concepts/declare-permissions#declarativeNetRequestFeedback) permission is present or tab-specific badge text was provided.
*/
export function getBadgeText(
details: TabDetails,
callback?: (
result: string,
) => void,
): void;
/**
* Sets the background color for the badge.
*/
export function setBadgeBackgroundColor(
details: {
/**
* 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 | extensionTypes.ColorArray,
/**
* Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
*/
tabId?: number,
},
): Promise<void>;
/**
* Sets the background color for the badge.
*/
export function setBadgeBackgroundColor(
details: {
/**
* 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 | extensionTypes.ColorArray,
/**
* Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
*/
tabId?: number,
},
callback?: () => void,
): void;
/**
* Gets the background color of the action.
*/
export function getBadgeBackgroundColor(
details: TabDetails,
): Promise<extensionTypes.ColorArray>;
/**
* Gets the background color of the action.
*/
export function getBadgeBackgroundColor(
details: TabDetails,
callback?: (
result: extensionTypes.ColorArray,
) => void,
): void;
/**
* Sets the text color for the badge.
*
* @since Chrome 110
*/
export function setBadgeTextColor(
details: {
/**
* 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`. Not setting this value will cause a color to be automatically chosen that will contrast with the badge's background color so the text will be visible. Colors with alpha values equivalent to 0 will not be set and will return an error.
*/
color: string | extensionTypes.ColorArray,
/**
* Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
*/
tabId?: number,
},
): Promise<void>;
/**
* Sets the text color for the badge.
*
* @since Chrome 110
*/
export function setBadgeTextColor(
details: {
/**
* 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`. Not setting this value will cause a color to be automatically chosen that will contrast with the badge's background color so the text will be visible. Colors with alpha values equivalent to 0 will not be set and will return an error.
*/
color: string | extensionTypes.ColorArray,
/**
* Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
*/
tabId?: number,
},
callback?: () => void,
): void;
/**
* Gets the text color of the action.
*
* @since Chrome 110
*/
export function getBadgeTextColor(
details: TabDetails,
): Promise<extensionTypes.ColorArray>;
/**
* Gets the text color of the action.
*
* @since Chrome 110
*/
export function getBadgeTextColor(
details: TabDetails,
callback?: (
result: extensionTypes.ColorArray,
) => void,
): void;
/**
* Enables the action for a tab. By default, actions are enabled.
*
* @param tabId The ID of the tab for which you want to modify the action.
*/
export function enable(
tabId?: number,
): Promise<void>;
/**
* Enables the action for a tab. By default, actions are enabled.
*
* @param tabId The ID of the tab for which you want to modify the action.
*/
export function enable(
tabId?: number,
callback?: () => void,
): void;
/**
* Disables the action for a tab.
*
* @param tabId The ID of the tab for which you want to modify the action.
*/
export function disable(
tabId?: number,
): Promise<void>;
/**
* Disables the action for a tab.
*
* @param tabId The ID of the tab for which you want to modify the action.
*/
export function disable(
tabId?: number,
callback?: () => void,
): void;
/**
* Indicates whether the extension action is enabled for a tab (or globally if no `tabId` is provided). Actions enabled using only {@link declarativeContent} always return false.
*
* @param tabId The ID of the tab for which you want check enabled status.
* @since Chrome 110
*/
export function isEnabled(
tabId?: number,
): Promise<boolean>;
/**
* Indicates whether the extension action is enabled for a tab (or globally if no `tabId` is provided). Actions enabled using only {@link declarativeContent} always return false.
*
* @param tabId The ID of the tab for which you want check enabled status.
* @since Chrome 110
*/
export function isEnabled(
tabId?: number,
/**
* @param isEnabled True if the extension action is enabled.
*/
callback?: (
isEnabled: boolean,
) => void,
): void;
/**
* Returns the user-specified settings relating to an extension's action.
*
* @since Chrome 91
*/
export function getUserSettings(): Promise<UserSettings>;
/**
* Returns the user-specified settings relating to an extension's action.
*
* @since Chrome 91
*/
export function getUserSettings(
callback?: (
userSettings: UserSettings,
) => void,
): void;
/**
* Opens the extension's popup. Between Chrome 118 and Chrome 126, this is only available to policy installed extensions.
*
* @param options Specifies options for opening the popup.
* @since Chrome 127
*/
export function openPopup(
options?: OpenPopupOptions,
): Promise<void>;
/**
* Opens the extension's popup. Between Chrome 118 and Chrome 126, this is only available to policy installed extensions.
*
* @param options Specifies options for opening the popup.
* @since Chrome 127
*/
export function openPopup(
options?: OpenPopupOptions,
callback?: () => void,
): void;
}
/**
* Use the `chrome.alarms` API to schedule code to run periodically or at a specified time in the future.
*
* @chrome-permission alarms
*/
export namespace alarms {
export interface Alarm {
/**
* Name of this alarm.
*/
name: string;
/**
* 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;
/**
* If not null, the alarm is a repeating alarm and will fire again in `periodInMinutes` minutes.
*/
periodInMinutes?: number;
}
export interface AlarmCreateInfo {
/**
* Time at which the alarm should fire, in milliseconds past the epoch (e.g. `Date.now() + n`).
*/
when?: number;
/**
* Length of time in minutes after which the `onAlarm` event should fire.
*/
delayInMinutes?: number;
/**
* 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;
}
/**
* Fired when an alarm has elapsed. Useful for event pages.
*/
export const onAlarm: 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 30 seconds but may delay them an arbitrary amount more. That is, setting `delayInMinutes` or `periodInMinutes` to less than `0.5` will not be honored and will cause a warning. `when` can be set to less than 30 seconds after "now" without warning but won't actually cause the alarm to fire for at least 30 seconds.
*
* 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.
*
* @chrome-returns-extra since Chrome 111
* @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`.
* @returns Promise that resolves when the alarm has been created.
*/
export function create(
name: string,
alarmInfo: AlarmCreateInfo,
): Promise<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 30 seconds but may delay them an arbitrary amount more. That is, setting `delayInMinutes` or `periodInMinutes` to less than `0.5` will not be honored and will cause a warning. `when` can be set to less than 30 seconds after "now" without warning but won't actually cause the alarm to fire for at least 30 seconds.
*
* 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.
*
* @chrome-returns-extra since Chrome 111
* @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`.
* @returns Promise that resolves when the alarm has been created.
*/
export function create(
alarmInfo: AlarmCreateInfo,
): Promise<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 30 seconds but may delay them an arbitrary amount more. That is, setting `delayInMinutes` or `periodInMinutes` to less than `0.5` will not be honored and will cause a warning. `when` can be set to less than 30 seconds after "now" without warning but won't actually cause the alarm to fire for at least 30 seconds.
*
* 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,
/**
* @since Chrome 111
*/
callback?: () => void,
): 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 30 seconds but may delay them an arbitrary amount more. That is, setting `delayInMinutes` or `periodInMinutes` to less than `0.5` will not be honored and will cause a warning. `when` can be set to less than 30 seconds after "now" without warning but won't actually cause the alarm to fire for at least 30 seconds.
*
* 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,
/**
* @since Chrome 111
*/
callback?: () => void,
): void;
/**
* Retrieves details about the specified alarm.
*
* @chrome-returns-extra since Chrome 91
* @param name The name of the alarm to get. Defaults to the empty string.
*/
export function get(
name?: string,
): Promise<Alarm | undefined>;
/**
* Retrieves details about the specified alarm.
*
* @param name The name of the alarm to get. Defaults to the empty string.
*/
export function get(
name?: string,
callback?: (
alarm?: Alarm,
) => void,
): void;
/**
* Gets an array of all the alarms.
*
* @chrome-returns-extra since Chrome 91
*/
export function getAll(): Promise<Alarm[]>;
/**
* Gets an array of all the alarms.
*/
export function getAll(
callback?: (
alarms: Alarm[],
) => void,
): void;
/**
* Clears the alarm with the given name.
*
* @chrome-returns-extra since Chrome 91
* @param name The name of the alarm to clear. Defaults to the empty string.
*/
export function clear(
name?: string,
): Promise<boolean>;
/**
* Clears the alarm with the given name.
*
* @param name The name of the alarm to clear. Defaults to the empty string.
*/
export function clear(
name?: string,
callback?: (
wasCleared: boolean,
) => void,
): void;
/**
* Clears all alarms.
*
* @chrome-returns-extra since Chrome 91
*/
export function clearAll(): Promise<boolean>;
/**
* Clears all alarms.
*/
export function clearAll(
callback?: (
wasCleared: boolean,
) => void,
): void;
}
/**
* @chrome-disallow-service-workers
* @chrome-max-manifest MV2
*/
export namespace app {
/**
* TODO (it's a manifest)
*/
export interface Details {
}
export interface DOMWindow {
}
/**
* @since Chrome 54
*/
export type InstallState = "not_installed" | "installed" | "disabled";
/**
* @since Chrome 54
*/
export type RunningState = "running" | "cannot_run" | "ready_to_run";
/**
* @returns
*/
export function getIsInstalled(): boolean;
/**
* @chrome-returns-extra since Chrome 100
*/
export function installState(): Promise<InstallState>;
export function installState(
callback?: (
state: InstallState,
) => void,
): void;
export function runningState(): RunningState;
/**
* @returns
*/
export function getDetails(): Details | undefined;
}
/**
* Use the `chrome.app.runtime` API to manage the app lifecycle. The app runtime manages app installation, controls the event page, and can shut down the app at anytime.
*
* @chrome-platform-apps
* @chrome-platform chromeos
* @chrome-platform linux
* @chrome-platform mac
* @chrome-platform win
*/
export namespace app.runtime {
export interface LaunchItem {
/**
* Entry for the item.
*/
entry: Entry;
/**
* The MIME type of the file.
*/
type?: string;
}
/**
* Enumeration of app launch sources. This should be kept in sync with AppLaunchSource in components/services/app\_service/public/mojom/types.mojom, and GetLaunchSourceEnum() in extensions/browser/api/app\_runtime/app\_runtime\_api.cc. Note the enumeration is used in UMA histogram so entries should not be re-ordered or removed.
*/
export type LaunchSource = "untracked" | "app_launcher" | "new_tab_page" | "reload" | "restart" | "load_and_launch" | "command_line" | "file_handler" | "url_handler" | "system_tray" | "about_page" | "keyboard" | "extensions_page" | "management_api" | "ephemeral_app" | "background" | "kiosk" | "chrome_internal" | "test" | "installed_notification" | "context_menu" | "arc" | "intent_url" | "app_home_page" | "focus_mode" | "sparky";
export interface LaunchData {
/**
* The ID of the file or URL handler that the app is being invoked with. Handler IDs are the top-level keys in the `file_handlers` and/or `url_handlers` dictionaries in the manifest.
*/
id?: string;
/**
* The file entries for the `onLaunched` event triggered by a matching file handler in the `file_handlers` manifest key.
*/
items?: LaunchItem[];
/**
* The URL for the `onLaunched` event triggered by a matching URL handler in the `url_handlers` manifest key.
*/
url?: string;
/**
* The referrer URL for the `onLaunched` event triggered by a matching URL handler in the `url_handlers` manifest key.
*/
referrerUrl?: string;
/**
* Whether the app is being launched in a [Chrome OS kiosk session](https://support.google.com/chromebook/answer/3134673).
*/
isKioskSession?: boolean;
/**
* Whether the app is being launched in a [Chrome OS public session](https://support.google.com/chrome/a/answer/3017014).
*
* @since Chrome 47
*/
isPublicSession?: boolean;
/**
* Where the app is launched from.
*/
source?: LaunchSource;
}
export interface EmbedRequest {
embedderId: string;
/**
* Optional developer specified data that the app to be embedded can use when making an embedding decision.
*/
data?: any;
/**
* Allows `embedderId` to embed this app in an <appview> element. The `url` specifies the content to embed.
*/
allow(
url: string,
): void;
/**
* Prevents `embedderId` from embedding this app in an <appview> element.
*/
deny(): void;
}
/**
* Fired when an embedding app requests to embed this app. This event is only available on dev channel with the flag --enable-app-view.
*/
export const onEmbedRequested: events.Event<(
request: EmbedRequest,
) => void>;
/**
* Fired when an app is launched from the launcher.
*/
export const onLaunched: events.Event<(
launchData?: LaunchData,
) => void>;
/**
* Fired at Chrome startup to apps that were running when Chrome last shut down, or when apps have been requested to restart from their previous state for other reasons (e.g. when the user revokes access to an app's retained files the runtime will restart the app). In these situations if apps do not have an `onRestarted` handler they will be sent an `onLaunched` event instead.
*/
export const onRestarted: events.Event<() => void>;
}
/**
* Use the `chrome.app.window` API to create windows. Windows have an optional frame with title bar and size controls. They are not associated with any Chrome browser windows. See the [Window State Sample](https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/window-state) for a demonstration of these options.
*
* @chrome-platform-apps
* @chrome-platform chromeos
* @chrome-platform linux
* @chrome-platform mac
* @chrome-platform win
*/
export namespace app.window {
export interface ContentBounds {
left?: number;
top?: number;
width?: number;
height?: number;
}
export interface BoundsSpecification {
/**
* The X coordinate of the content or window.
*/
left?: number;
/**
* The Y coordinate of the content or window.
*/
top?: number;
/**
* The width of the content or window.
*/
width?: number;
/**
* The height of the content or window.
*/
height?: number;
/**
* The minimum width of the content or window.
*/
minWidth?: number;
/**
* The minimum height of the content or window.
*/
minHeight?: number;
/**
* The maximum width of the content or window.
*/
maxWidth?: number;
/**
* The maximum height of the content or window.
*/
maxHeight?: number;
}
export interface Bounds {
/**
* This property can be used to read or write the current X coordinate of the content or window.
*/
left: number;
/**
* This property can be used to read or write the current Y coordinate of the content or window.
*/
top: number;
/**
* This property can be used to read or write the current width of the content or window.
*/
width: number;
/**
* This property can be used to read or write the current height of the content or window.
*/
height: number;
/**
* This property can be used to read or write the current minimum width of the content or window. A value of `null` indicates 'unspecified'.
*/
minWidth?: number;
/**
* This property can be used to read or write the current minimum height of the content or window. A value of `null` indicates 'unspecified'.
*/
minHeight?: number;
/**
* This property can be used to read or write the current maximum width of the content or window. A value of `null` indicates 'unspecified'.
*/
maxWidth?: number;
/**
* This property can be used to read or write the current maximum height of the content or window. A value of `null` indicates 'unspecified'.
*/
maxHeight?: number;
/**
* Set the left and top position of the content or window.
*/
setPosition(
left: number,
top: number,
): void;
/**
* Set the width and height of the content or window.
*/
setSize(
width: number,
height: number,
): void;
/**
* Set the minimum size constraints of the content or window. The minimum width or height can be set to `null` to remove the constraint. A value of `undefined` will leave a constraint unchanged.
*/
setMinimumSize(
minWidth: number,
minHeight: number,
): void;
/**
* Set the maximum size constraints of the content or window. The maximum width or height can be set to `null` to remove the constraint. A value of `undefined` will leave a constraint unchanged.
*/
setMaximumSize(
maxWidth: number,
maxHeight: number,
): void;
}
export interface FrameOptions {
/**
* Frame type: `none` or `chrome` (defaults to `chrome`).
*
* For `none`, the `-webkit-app-region` CSS property can be used to apply draggability to the app's window.
*
* `-webkit-app-region: drag` can be used to mark regions draggable. `no-drag` can be used to disable this style on nested elements.
*/
type?: string;
/**
* Allows the frame color to be set. Frame coloring is only available if the frame type is `chrome`.
*
* Frame coloring is new in Chrome 36.
*/
color?: string;
/**
* Allows the frame color of the window when active to be set. Frame coloring is only available if the frame type is `chrome`.
*
* Frame coloring is only available if the frame type is `chrome`.
*
* Frame coloring is new in Chrome 36.
*/
activeColor?: string;
/**
* Allows the frame color of the window when inactive to be set differently to the active color. Frame coloring is only available if the frame type is `chrome`.
*
* `inactiveColor` must be used in conjunction with `color`.
*
* Frame coloring is new in Chrome 36.
*/
inactiveColor?: string;
}
/**
* State of a window: normal, fullscreen, maximized, minimized.
*/
export type State = "normal" | "fullscreen" | "maximized" | "minimized";
/**
* Specifies the type of window to create.
*
* @chrome-enum "shell" Default window type.
* @chrome-enum "panel" OS managed window (Deprecated).
* @since Chrome 45
*/
export type WindowType = "shell" | "panel";
export interface CreateWindowOptions {
/**
* Id to identify the window. This will be used to remember the size and position of the window and restore that geometry when a window with the same id is later opened. If a window with a given id is created while another window with the same id already exists, the currently opened window will be focused instead of creating a new window.
*/
id?: string;
/**
* Used to specify the initial position, initial size and constraints of the window's content (excluding window decorations). If an `id` is also specified and a window with a matching `id` has been shown before, the remembered bounds will be used instead.
*
* Note that the padding between the inner and outer bounds is determined by the OS. Therefore setting the same bounds property for both the `innerBounds` and `outerBounds` will result in an error.
*
* This property is new in Chrome 36.
*/
innerBounds?: BoundsSpecification;
/**
* Used to specify the initial position, initial size and constraints of the window (including window decorations such as the title bar and frame). If an `id` is also specified and a window with a matching `id` has been shown before, the remembered bounds will be used instead.
*
* Note that the padding between the inner and outer bounds is determined by the OS. Therefore setting the same bounds property for both the `innerBounds` and `outerBounds` will result in an error.
*
* This property is new in Chrome 36.
*/
outerBounds?: BoundsSpecification;
/**
* Minimum width of the window.
*
* @deprecated Use innerBounds or outerBounds.
*/
minWidth?: number;
/**
* Minimum height of the window.
*
* @deprecated Use innerBounds or outerBounds.
*/
minHeight?: number;
/**
* Maximum width of the window.
*
* @deprecated Use innerBounds or outerBounds.
*/
maxWidth?: number;
/**
* Maximum height of the window.
*
* @deprecated Use innerBounds or outerBounds.
*/
maxHeight?: number;
/**
* Type of window to create.
*
* @deprecated All app windows use the 'shell' window type
* @since Chrome 45
* @chrome-deprecated-since Chrome 69
*/
type?: WindowType;
/**
* If true, the window will have its own shelf icon. Otherwise the window will be grouped in the shelf with other windows that are associated with the app. Defaults to false. If showInShelf is set to true you need to specify an id for the window.
*
* @since Chrome 54
*/
showInShelf?: boolean;
/**
* URL of the window icon. A window can have its own icon when showInShelf is set to true. The URL should be a global or an extension local URL.
*
* @since Chrome 54
*/
icon?: string;
/**
* Frame type: `none` or `chrome` (defaults to `chrome`). For `none`, the `-webkit-app-region` CSS property can be used to apply draggability to the app's window. `-webkit-app-region: drag` can be used to mark regions draggable. `no-drag` can be used to disable this style on nested elements.
*
* Use of `FrameOptions` is new in M36.
*/
frame?: string | FrameOptions;
/**
* Size and position of the content in the window (excluding the titlebar). If an id is also specified and a window with a matching id has been shown before, the remembered bounds of the window will be used instead.
*
* @deprecated Use innerBounds or outerBounds.
*/
bounds?: ContentBounds;
/**
* The initial state of the window, allowing it to be created already fullscreen, maximized, or minimized. Defaults to 'normal'.
*/
state?: State;
/**
* If true, the window will be created in a hidden state. Call show() on the window to show it once it has been created. Defaults to false.
*/
hidden?: boolean;
/**
* If true, the window will be resizable by the user. Defaults to true.
*/
resizable?: boolean;
/**
* By default if you specify an id for the window, the window will only be created if another window with the same id doesn't already exist. If a window with the same id already exists that window is activated instead. If you do want to create multiple windows with the same id, you can set this property to false.
*
* @deprecated Multiple windows with the same id is no longer supported.
*/
singleton?: boolean;
/**
* If true, the window will stay above most other windows. If there are multiple windows of this kind, the currently focused window will be in the foreground. Requires the `alwaysOnTopWindows` permission. Defaults to false.
*
* Call `setAlwaysOnTop()` on the window to change this property after creation.
*/
alwaysOnTop?: boolean;
/**
* If true, the window will be focused when created. Defaults to true.
*/
focused?: boolean;
/**