1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 "description": "Use the <code>chrome.tabs</code> API to interact with the browser's tab system. You can use this API to create, modify, and rearrange tabs in the browser.",
14 "id": {"type": "integer", "minimum": 0, "optional": true, "description": "The ID of the tab. Tab IDs are unique within a browser session. Under some circumstances a Tab may not be assigned an ID, for example when querying foreign tabs using the $(ref:sessions) API, in which case a session ID may be present."},
15 // TODO(kalman): Investigate how this is ending up as -1 (based on window type? a bug?) and whether it should be optional instead.
16 "index": {"type": "integer", "minimum": -1, "description": "The zero-based index of the tab within its window."},
17 "windowId": {"type": "integer", "minimum": 0, "description": "The ID of the window the tab is contained within."},
18 "openerTabId": {"type": "integer", "minimum": 0, "optional": true, "description": "The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists."},
19 "selected": {"type": "boolean", "description": "Whether the tab is selected.", "deprecated": "Please use $(ref:tabs.Tab.highlighted)."},
20 "highlighted": {"type": "boolean", "description": "Whether the tab is highlighted."},
21 "active": {"type": "boolean", "description": "Whether the tab is active in its window. (Does not necessarily mean the window is focused.)"},
22 "pinned": {"type": "boolean", "description": "Whether the tab is pinned."},
23 "url": {"type": "string", "optional": true, "description": "The URL the tab is displaying. This property is only present if the extension's manifest includes the <code>\"tabs\"</code> permission."},
24 "title": {"type": "string", "optional": true, "optional": true, "description": "The title of the tab. This property is only present if the extension's manifest includes the <code>\"tabs\"</code> permission."},
25 "favIconUrl": {"type": "string", "optional": true, "optional": true, "description": "The URL of the tab's favicon. This property is only present if the extension's manifest includes the <code>\"tabs\"</code> permission. It may also be an empty string if the tab is loading."},
26 "status": {"type": "string", "optional": true, "description": "Either <em>loading</em> or <em>complete</em>."},
27 "incognito": {"type": "boolean", "description": "Whether the tab is in an incognito window."},
28 "width": {"type": "integer", "optional": true, "description": "The width of the tab in pixels."},
29 "height": {"type": "integer", "optional": true, "description": "The height of the tab in pixels."},
30 "sessionId": {"type": "string", "optional": true, "description": "The session ID used to uniquely identify a Tab obtained from the $(ref:sessions) API."}
34 "id": "InjectDetails",
36 "description": "Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time.",
38 "code": {"type": "string", "optional": true, "description": "JavaScript or CSS code to inject.<br><br><b>Warning:</b><br>Be careful using the <code>code</code> parameter. Incorrect use of it may open your extension to <a href=\"https://en.wikipedia.org/wiki/Cross-site_scripting\">cross site scripting</a> attacks."},
39 "file": {"type": "string", "optional": true, "description": "JavaScript or CSS file to inject."},
40 "allFrames": {"type": "boolean", "optional": true, "description": "If allFrames is <code>true</code>, implies that the JavaScript or CSS should be injected into all frames of current page. By default, it's <code>false</code> and is only injected into the top frame."},
44 "enum": ["document_start", "document_end", "document_idle"],
45 "description": "The soonest that the JavaScript or CSS will be injected into the tab. Defaults to \"document_idle\"."
54 "description": "Retrieves details about the specified tab.",
65 {"name": "tab", "$ref": "Tab"}
73 "description": "Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example: a background page or popup view).",
92 "description": "Connects to the content script(s) in the specified tab. The $(ref:runtime.onConnect) event is fired in each content script running in the specified tab for the current extension. For more details, see <a href='messaging.html'>Content Script Messaging</a>.",
101 "name": "connectInfo",
103 "name": { "type": "string", "optional": true, "description": "Will be passed into onConnect for content scripts that are listening for the connection event." }
109 "$ref": "runtime.Port",
110 "description": "A port that can be used to communicate with the content scripts running in the specified tab. The port's $(ref:runtime.Port) event is fired if the tab closes or does not exist. "
114 "name": "sendRequest",
115 "deprecated": "Please use $(ref:runtime.sendMessage).",
118 "description": "Sends a single request to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The $(ref:extension.onRequest) event is fired in each content script running in the specified tab for the current extension.",
131 "name": "responseCallback",
137 "description": "The JSON response object sent by the handler of the request. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and $(ref:runtime.lastError) will be set to the error message."
144 "name": "sendMessage",
147 "description": "Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The $(ref:runtime.onMessage) event is fired in each content script running in the specified tab for the current extension.",
160 "name": "responseCallback",
166 "description": "The JSON response object sent by the handler of the message. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and $(ref:runtime.lastError) will be set to the error message."
173 "name": "getSelected",
174 "deprecated": "Please use $(ref:tabs.query) <code>{active: true}</code>.",
176 "description": "Gets the tab that is selected in the specified window.",
183 "description": "Defaults to the <a href='windows.html#current-window'>current window</a>."
189 {"name": "tab", "$ref": "Tab"}
195 "name": "getAllInWindow",
197 "deprecated": "Please use $(ref:tabs.query) <code>{windowId: windowId}</code>.",
198 "description": "Gets details about all tabs in the specified window.",
205 "description": "Defaults to the <a href='windows.html#current-window'>current window</a>."
211 {"name": "tabs", "type": "array", "items": { "$ref": "Tab" } }
219 "description": "Creates a new tab.",
223 "name": "createProperties",
229 "description": "The window to create the new tab in. Defaults to the <a href='windows.html#current-window'>current window</a>."
235 "description": "The position the tab should take in the window. The provided value will be clamped to between zero and the number of tabs in the window."
240 "description": "The URL to navigate the tab to initially. Fully-qualified URLs must include a scheme (i.e. 'http://www.google.com', not 'www.google.com'). Relative URLs will be relative to the current page within the extension. Defaults to the New Tab Page."
245 "description": "Whether the tab should become the active tab in the window. Does not affect whether the window is focused (see $(ref:windows.update)). Defaults to <var>true</var>."
248 "deprecated": "Please use <em>active</em>.",
251 "description": "Whether the tab should become the selected tab in the window. Defaults to <var>true</var>"
256 "description": "Whether the tab should be pinned. Defaults to <var>false</var>"
262 "description": "The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as the newly created tab."
274 "description": "Details about the created tab. Will contain the ID of the new tab."
283 "description": "Duplicates a tab.",
289 "description": "The ID of the tab which is to be duplicated."
299 "description": "Details about the duplicated tab. The $(ref:tabs.Tab) object doesn't contain <code>url</code>, <code>title</code> and <code>favIconUrl</code> if the <code>\"tabs\"</code> permission has not been requested.",
309 "description": "Gets all tabs that have the specified properties, or all tabs if no properties are specified.",
318 "description": "Whether the tabs are active in their windows."
323 "description": "Whether the tabs are pinned."
328 "description": "Whether the tabs are highlighted."
333 "description": "Whether the tabs are in the <a href='windows.html#current-window'>current window</a>."
335 "lastFocusedWindow": {
338 "description": "Whether the tabs are in the last focused window."
343 "enum": ["loading", "complete"],
344 "description": "Whether the tabs have completed loading."
349 "description": "Match page titles against a pattern."
354 "description": "Match tabs against a <a href='match_patterns.html'>URL pattern</a>. Note that fragment identifiers are not matched."
360 "description": "The ID of the parent window, or $(ref:windows.WINDOW_ID_CURRENT) for the <a href='windows.html#current-window'>current window</a>."
365 "enum": ["normal", "popup", "panel", "app"],
366 "description": "The type of window the tabs are in."
372 "description": "The position of the tabs within their windows."
394 "description": "Highlights the given tabs.",
398 "name": "highlightInfo",
403 "description": "The window that contains the tabs.",
407 "description": "One or more tab indices to highlight.",
409 {"type": "array", "items": {"type": "integer", "minimum": 0}},
421 "$ref": "windows.Window",
422 "description": "Contains details about the window whose tabs were highlighted."
431 "description": "Modifies the properties of a tab. Properties that are not specified in <var>updateProperties</var> are not modified.",
438 "description": "Defaults to the selected tab of the <a href='windows.html#current-window'>current window</a>."
442 "name": "updateProperties",
447 "description": "A URL to navigate the tab to."
452 "description": "Whether the tab should be active. Does not affect whether the window is focused (see $(ref:windows.update))."
457 "description": "Adds or removes the tab from the current selection."
460 "deprecated": "Please use <em>highlighted</em>.",
463 "description": "Whether the tab should be selected."
468 "description": "Whether the tab should be pinned."
474 "description": "The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab."
487 "description": "Details about the updated tab. The $(ref:tabs.Tab) object doesn't contain <code>url</code>, <code>title</code> and <code>favIconUrl</code> if the <code>\"tabs\"</code> permission has not been requested."
496 "description": "Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === \"normal\") windows.",
500 "description": "The tab or list of tabs to move.",
502 {"type": "integer", "minimum": 0},
503 {"type": "array", "items": {"type": "integer", "minimum": 0}}
508 "name": "moveProperties",
514 "description": "Defaults to the window the tab is currently in."
519 "description": "The position to move the window to. -1 will place the tab at the end of the window."
530 "description": "Details about the moved tabs.",
533 {"type": "array", "items": {"$ref": "Tab"}}
543 "description": "Reload a tab.",
545 {"type": "integer", "name": "tabId", "minimum": 0, "optional": true, "description": "The ID of the tab to reload; defaults to the selected tab of the current window."},
548 "name": "reloadProperties",
554 "description": "Whether using any local cache. Default is false."
558 {"type": "function", "name": "callback", "optional": true, "parameters": []}
564 "description": "Closes one or more tabs.",
568 "description": "The tab or list of tabs to close.",
570 {"type": "integer", "minimum": 0},
571 {"type": "array", "items": {"type": "integer", "minimum": 0}}
574 {"type": "function", "name": "callback", "optional": true, "parameters": []}
578 "name": "detectLanguage",
580 "description": "Detects the primary language of the content in a tab.",
587 "description": "Defaults to the active tab of the <a href='windows.html#current-window'>current window</a>."
596 "description": "An ISO language code such as <code>en</code> or <code>fr</code>. For a complete list of languages supported by this method, see <a href='http://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc'>kLanguageInfoTable</a>. The 2nd to 4th columns will be checked and the first non-NULL value will be returned except for Simplified Chinese for which zh-CN will be returned. For an unknown language, <code>und</code> will be returned."
603 "name": "captureVisibleTab",
605 "description": "Captures the visible area of the currently active tab in the specified window. You must have <a href='declare_permissions.html'><all_urls></a> permission to use this method.",
612 "description": "The target window. Defaults to the <a href='windows.html#current-window'>current window</a>."
615 "$ref": "types.ImageDetails",
620 "type": "function", "name": "callback", "parameters": [
621 {"type": "string", "name": "dataUrl", "description": "A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display."}
627 "name": "executeScript",
629 "description": "Injects JavaScript code into a page. For details, see the <a href='content_scripts.html#pi'>programmatic injection</a> section of the content scripts doc.",
631 {"type": "integer", "name": "tabId", "minimum": 0, "optional": true, "description": "The ID of the tab in which to run the script; defaults to the active tab of the current window."},
633 "$ref": "tabs.InjectDetails",
635 "description": "Details of the script to run."
641 "description": "Called after all the JavaScript has been executed.",
647 "items": {"type": "any", "minimum": 0},
648 "description": "The result of the script in every injected frame."
657 "description": "Injects CSS into a page. For details, see the <a href='content_scripts.html#pi'>programmatic injection</a> section of the content scripts doc.",
659 {"type": "integer", "name": "tabId", "minimum": 0, "optional": true, "description": "The ID of the tab in which to insert the CSS; defaults to the active tab of the current window."},
661 "$ref": "tabs.InjectDetails",
663 "description": "Details of the CSS text to insert."
669 "description": "Called when all the CSS has been inserted.",
679 "description": "Fired when a tab is created. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set.",
684 "description": "Details of the tab that was created."
691 "description": "Fired when a tab is updated.",
693 {"type": "integer", "name": "tabId", "minimum": 0},
696 "name": "changeInfo",
697 "description": "Lists the changes to the state of the tab that was updated.",
702 "description": "The status of the tab. Can be either <em>loading</em> or <em>complete</em>."
707 "description": "The tab's URL if it has changed."
712 "description": "The tab's new pinned state."
717 "description": "The tab's new favicon URL."
724 "description": "Gives the state of the tab that was updated."
731 "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. This event is not fired when a tab is moved between windows. For that, see $(ref:tabs.onDetached).",
733 {"type": "integer", "name": "tabId", "minimum": 0},
738 "windowId": {"type": "integer", "minimum": 0},
739 "fromIndex": {"type": "integer", "minimum": 0},
740 "toIndex": {"type": "integer", "minimum": 0}
746 "name": "onSelectionChanged",
747 "deprecated": "Please use $(ref:tabs.onActivated).",
749 "description": "Fires when the selected tab in a window changes.",
755 "description": "The ID of the tab that has become active."
759 "name": "selectInfo",
764 "description": "The ID of the window the selected tab changed inside of."
771 "name": "onActiveChanged",
772 "deprecated": "Please use $(ref:tabs.onActivated).",
774 "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 to be notified when a URL is set.",
780 "description": "The ID of the tab that has become active."
784 "name": "selectInfo",
789 "description": "The ID of the window the selected tab changed inside of."
796 "name": "onActivated",
798 "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 to be notified when a URL is set.",
802 "name": "activeInfo",
807 "description": "The ID of the tab that has become active."
812 "description": "The ID of the window the active tab changed inside of."
819 "name": "onHighlightChanged",
820 "deprecated": "Please use $(ref:tabs.onHighlighted).",
822 "description": "Fired when the highlighted or selected tabs in a window changes.",
826 "name": "selectInfo",
831 "description": "The window whose tabs changed."
836 "items": {"type": "integer", "minimum": 0},
837 "description": "All highlighted tabs in the window."
844 "name": "onHighlighted",
846 "description": "Fired when the highlighted or selected tabs in a window changes.",
850 "name": "highlightInfo",
855 "description": "The window whose tabs changed."
860 "items": {"type": "integer", "minimum": 0},
861 "description": "All highlighted tabs in the window."
868 "name": "onDetached",
870 "description": "Fired when a tab is detached from a window, for example because it is being moved between windows.",
872 {"type": "integer", "name": "tabId", "minimum": 0},
875 "name": "detachInfo",
877 "oldWindowId": {"type": "integer", "minimum": 0},
878 "oldPosition": {"type": "integer", "minimum": 0}
884 "name": "onAttached",
886 "description": "Fired when a tab is attached to a window, for example because it was moved between windows.",
888 {"type": "integer", "name": "tabId", "minimum": 0},
891 "name": "attachInfo",
893 "newWindowId": {"type": "integer", "minimum": 0},
894 "newPosition": {"type": "integer", "minimum": 0}
902 "description": "Fired when a tab is closed.",
904 {"type": "integer", "name": "tabId", "minimum": 0},
907 "name": "removeInfo",
909 "windowId": {"type": "integer", "minimum": 0, "description": "The window whose tab is closed." },
910 "isWindowClosing": {"type": "boolean", "description": "True when the tab is being closed because its window is being closed." }
916 "name": "onReplaced",
918 "description": "Fired when a tab is replaced with another tab due to prerendering or instant.",
920 {"type": "integer", "name": "addedTabId", "minimum": 0},
921 {"type": "integer", "name": "removedTabId", "minimum": 0}