Skip to content

Commit

Permalink
fix: prevent errors when extensions listen for chrome.tabs events
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Sep 5, 2023
1 parent d76a35a commit 769e417
Showing 1 changed file with 343 additions and 0 deletions.
343 changes: 343 additions & 0 deletions shell/common/extensions/api/tabs.json
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,350 @@
}
}
],
// Electron does not yet support tab events - we define them here because otherwise extensions crash when
// they try to listen for them.
"events": [
{
"name": "onCreated",
"type": "function",
"description": "Fired when a tab is created. Note that the tab's URL and tab group membership may not be set at the time this event is fired, but you can listen to onUpdated events so as to be notified when a URL is set or the tab is added to a tab group.",
"parameters": [
{
"$ref": "Tab",
"name": "tab",
"description": "Details of the tab that was created."
}
]
},
{
"name": "onUpdated",
"type": "function",
"description": "Fired when a tab is updated.",
"parameters": [
{
"type": "integer",
"name": "tabId",
"minimum": 0
},
{
"type": "object",
"name": "changeInfo",
"description": "Lists the changes to the state of the tab that was updated.",
"properties": {
"status": {
"$ref": "TabStatus",
"optional": true,
"description": "The tab's loading status."
},
"url": {
"type": "string",
"optional": true,
"description": "The tab's URL if it has changed."
},
"groupId": {
"type": "integer",
"optional": true,
"minimum": -1,
"description": "The tab's new group."
},
"pinned": {
"type": "boolean",
"optional": true,
"description": "The tab's new pinned state."
},
"audible": {
"type": "boolean",
"optional": true,
"description": "The tab's new audible state."
},
"discarded": {
"type": "boolean",
"optional": true,
"description": "The tab's new discarded state."
},
"autoDiscardable": {
"type": "boolean",
"optional": true,
"description": "The tab's new auto-discardable state."
},
"mutedInfo": {
"$ref": "MutedInfo",
"optional": true,
"description": "The tab's new muted state and the reason for the change."
},
"favIconUrl": {
"type": "string",
"optional": true,
"description": "The tab's new favicon URL."
},
"title": {
"type": "string",
"optional": true,
"description": "The tab's new title."
}
}
},
{
"$ref": "Tab",
"name": "tab",
"description": "Gives the state of the tab that was updated."
}
]
},
{
"name": "onMoved",
"type": "function",
"description": "Fired when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved. Move events are not fired for the other tabs that must move in response to the manually-moved tab. This event is not fired when a tab is moved between windows; for details, see $(ref:tabs.onDetached).",
"parameters": [
{
"type": "integer",
"name": "tabId",
"minimum": 0
},
{
"type": "object",
"name": "moveInfo",
"properties": {
"windowId": {
"type": "integer",
"minimum": 0
},
"fromIndex": {
"type": "integer",
"minimum": 0
},
"toIndex": {
"type": "integer",
"minimum": 0
}
}
}
]
},
{
"name": "onSelectionChanged",
"deprecated": "Please use $(ref:tabs.onActivated).",
"type": "function",
"description": "Fires when the selected tab in a window changes.",
"parameters": [
{
"type": "integer",
"name": "tabId",
"minimum": 0,
"description": "The ID of the tab that has become active."
},
{
"type": "object",
"name": "selectInfo",
"properties": {
"windowId": {
"type": "integer",
"minimum": 0,
"description": "The ID of the window the selected tab changed inside of."
}
}
}
]
},
{
"name": "onActiveChanged",
"deprecated": "Please use $(ref:tabs.onActivated).",
"type": "function",
"description": "Fires when the selected tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to $(ref:tabs.onUpdated) events so as to be notified when a URL is set.",
"parameters": [
{
"type": "integer",
"name": "tabId",
"minimum": 0,
"description": "The ID of the tab that has become active."
},
{
"type": "object",
"name": "selectInfo",
"properties": {
"windowId": {
"type": "integer",
"minimum": 0,
"description": "The ID of the window the selected tab changed inside of."
}
}
}
]
},
{
"name": "onActivated",
"type": "function",
"description": "Fires when the active tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events so as to be notified when a URL is set.",
"parameters": [
{
"type": "object",
"name": "activeInfo",
"properties": {
"tabId": {
"type": "integer",
"minimum": 0,
"description": "The ID of the tab that has become active."
},
"windowId": {
"type": "integer",
"minimum": 0,
"description": "The ID of the window the active tab changed inside of."
}
}
}
]
},
{
"name": "onHighlightChanged",
"deprecated": "Please use $(ref:tabs.onHighlighted).",
"type": "function",
"description": "Fired when the highlighted or selected tabs in a window changes.",
"parameters": [
{
"type": "object",
"name": "selectInfo",
"properties": {
"windowId": {
"type": "integer",
"minimum": 0,
"description": "The window whose tabs changed."
},
"tabIds": {
"type": "array",
"name": "tabIds",
"items": {
"type": "integer",
"minimum": 0
},
"description": "All highlighted tabs in the window."
}
}
}
]
},
{
"name": "onHighlighted",
"type": "function",
"description": "Fired when the highlighted or selected tabs in a window changes.",
"parameters": [
{
"type": "object",
"name": "highlightInfo",
"properties": {
"windowId": {
"type": "integer",
"minimum": 0,
"description": "The window whose tabs changed."
},
"tabIds": {
"type": "array",
"name": "tabIds",
"items": {
"type": "integer",
"minimum": 0
},
"description": "All highlighted tabs in the window."
}
}
}
]
},
{
"name": "onDetached",
"type": "function",
"description": "Fired when a tab is detached from a window; for example, because it was moved between windows.",
"parameters": [
{
"type": "integer",
"name": "tabId",
"minimum": 0
},
{
"type": "object",
"name": "detachInfo",
"properties": {
"oldWindowId": {
"type": "integer",
"minimum": 0
},
"oldPosition": {
"type": "integer",
"minimum": 0
}
}
}
]
},
{
"name": "onAttached",
"type": "function",
"description": "Fired when a tab is attached to a window; for example, because it was moved between windows.",
"parameters": [
{
"type": "integer",
"name": "tabId",
"minimum": 0
},
{
"type": "object",
"name": "attachInfo",
"properties": {
"newWindowId": {
"type": "integer",
"minimum": 0
},
"newPosition": {
"type": "integer",
"minimum": 0
}
}
}
]
},
{
"name": "onRemoved",
"type": "function",
"description": "Fired when a tab is closed.",
"parameters": [
{
"type": "integer",
"name": "tabId",
"minimum": 0
},
{
"type": "object",
"name": "removeInfo",
"properties": {
"windowId": {
"type": "integer",
"minimum": 0,
"description": "The window whose tab is closed."
},
"isWindowClosing": {
"type": "boolean",
"description": "True when the tab was closed because its parent window was closed."
}
}
}
]
},
{
"name": "onReplaced",
"type": "function",
"description": "Fired when a tab is replaced with another tab due to prerendering or instant.",
"parameters": [
{
"type": "integer",
"name": "addedTabId",
"minimum": 0
},
{
"type": "integer",
"name": "removedTabId",
"minimum": 0
}
]
},
{
"name": "onZoomChange",
"type": "function",
Expand Down

0 comments on commit 769e417

Please sign in to comment.