1[
2  {
3    "namespace": "tabs",
4    "description": "The tabs API.",
5    "types": [
6      {
7        "id": "Tab",
8        "type": "object",
9        "properties": {
10          "id": {"type": "integer", "minimum": 0, "description": "The ID of the tab. Tab IDs are unique within a browser session."},
11          "index": {"type": "integer", "minimum": 0, "description": "The zero-based index of the tab within its window."},
12          "windowId": {"type": "integer", "minimum": 0, "description": "The ID of the window the tab is contained within."},
13          "selected": {"type": "boolean", "description": "Whether the tab is selected.", "nodoc": true},
14          "highlighted": {"type": "boolean", "description": "Whether the tab is highlighted."},
15          "active": {"type": "boolean", "description": "Whether the tab is active in its window."},
16          "pinned": {"type": "boolean", "description": "Whether the tab is pinned."},
17          "url": {"type": "string", "description": "The URL the tab is displaying."},
18          "title": {"type": "string", "optional": true, "description": "The title of the tab. This may not be available if the tab is loading."},
19          "favIconUrl": {"type": "string", "optional": true, "description": "The URL of the tab's favicon. This may not be available if the tab is loading."},
20          "status": {"type": "string", "optional": true, "description": "Either <em>loading</em> or <em>complete</em>."},
21          "incognito": {"type": "boolean", "description": "Whether the tab is in an incognito window."}
22        }
23      }
24    ],
25    "functions": [
26      {
27        "name": "get",
28        "type": "function",
29        "description": "Retrieves details about the specified tab.",
30        "parameters": [
31          {
32            "type": "integer",
33            "name": "tabId",
34            "minimum": 0
35          },
36          {
37            "type": "function",
38            "name": "callback",
39            "parameters": [
40              {"name": "tab", "$ref": "Tab"}
41            ]
42          }
43        ]
44      },
45      {
46        "name": "getCurrent",
47        "type": "function",
48        "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).",
49        "parameters": [
50          {
51            "type": "function",
52            "name": "callback",
53            "parameters": [
54              {
55                "name": "tab",
56                "$ref": "Tab",
57                "optional": true
58              }
59            ]
60          }
61        ]
62      },
63      {
64        "name": "connect",
65        "nocompile": true,
66        "type": "function",
67        "description": "Connects to the content script(s) in the specified tab. The <a href='extension.html#event-onConnect'>chrome.runtime.onConnect</a> event is fired in each content script running in the specified tab for the current extension. For more details, see <a href='content_scripts.html#messaging'>Content Script Messaging</a>.",
68        "parameters": [
69          {
70            "type": "integer",
71            "name": "tabId",
72            "minimum": 0
73          },
74          {
75            "type": "object",
76            "name": "connectInfo",
77            "properties": {
78              "name": { "type": "string", "optional": true, "description": "Will be passed into onConnect for content scripts that are listening for the connection event." }
79            },
80            "optional": true
81          }
82        ],
83        "returns": {
84          "$ref": "Port",
85          "description": "A port that can be used to communicate with the content scripts running in the specified tab. The port's <a href='extension.html#type-Port'>onDisconnect</a> event is fired if the tab closes or does not exist. "
86        }
87      },
88      {
89        "name": "sendRequest",
90        "nocompile": true,
91        "type": "function",
92        "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 <a href='extension.html#event-onRequest'>chrome.extension.onRequest</a> event is fired in each content script running in the specified tab for the current extension.",
93        "parameters": [
94          {
95            "type": "integer",
96            "name": "tabId",
97            "minimum": 0
98          },
99          {
100            "type": "any",
101            "name": "request"
102          },
103          {
104            "type": "function",
105            "name": "responseCallback",
106            "optional": true,
107            "parameters": [
108              {
109                "name": "response",
110                "type": "any",
111                "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 <a href='extension.html#property-lastError'>chrome.runtime.lastError</a> will be set to the error message."
112              }
113            ]
114          }
115        ]
116      },
117      {
118        "name": "getSelected",
119        "nodoc": true,
120        "type": "function",
121        "description": "Deprecated. Please use query({'active': true}). Gets the tab that is selected in the specified window.",
122        "parameters": [
123          {
124            "type": "integer",
125            "name": "windowId",
126            "minimum": 0,
127            "optional": true,
128            "description": "Defaults to the <a href='windows.html#current-window'>current window</a>."
129          },
130          {
131            "type": "function",
132            "name": "callback",
133            "parameters": [
134              {"name": "tab", "$ref": "Tab"}
135            ]
136          }
137        ]
138      },
139      {
140        "name": "getAllInWindow",
141        "type": "function",
142        "nodoc": true,
143        "description": "Deprecated. Please use query({'windowId': windowId}). Gets details about all tabs in the specified window.",
144        "parameters": [
145          {
146            "type": "integer",
147            "name": "windowId",
148            "minimum": 0,
149            "optional": true,
150            "description": "Defaults to the <a href='windows.html#current-window'>current window</a>."
151            },
152          {
153            "type": "function",
154            "name": "callback",
155            "parameters": [
156              {"name": "tabs", "type": "array", "items": { "$ref": "Tab" } }
157            ]
158          }
159        ]
160      },
161      {
162        "name": "create",
163        "type": "function",
164        "description": "Creates a new tab. Note: This function can be used without requesting the 'tabs' permission in the manifest.",
165        "parameters": [
166          {
167            "type": "object",
168            "name": "createProperties",
169            "properties": {
170              "windowId": {
171                "type": "integer",
172                "minimum": 0,
173                "optional": true,
174                "description": "The window to create the new tab in. Defaults to the <a href='windows.html#current-window'>current window</a>."
175              },
176              "index": {
177                "type": "integer",
178                "minimum": 0,
179                "optional": true,
180                "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."
181              },
182              "url": {
183                "type": "string",
184                "optional": true,
185                "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."
186              },
187              "active": {
188                "type": "boolean",
189                "optional": true,
190                "description": "Whether the tab should become the active tab in the window. Defaults to <var>true</var>"
191              },
192              "selected": {
193                "nodoc": true,
194                "type": "boolean",
195                "optional": true,
196                "description": "Whether the tab should become the selected tab in the window. Defaults to <var>true</var>"
197              },
198              "pinned": {
199                "type": "boolean",
200                "optional": true,
201                "description": "Whether the tab should be pinned. Defaults to <var>false</var>"
202              }
203            }
204          },
205          {
206            "type": "function",
207            "name": "callback",
208            "optional": true,
209            "parameters": [
210              {
211                "name": "tab",
212                "$ref": "Tab",
213                "description": "Details about the created tab. Will contain the ID of the new tab."
214              }
215            ]
216          }
217        ]
218      },
219      {
220        "name": "query",
221        "type": "function",
222        "description": "Gets all tabs that have the specified properties, or all tabs if no properties are specified.",
223        "parameters": [
224          {
225            "type": "object",
226            "name": "queryInfo",
227            "properties": {
228              "active": {
229                "type": "boolean",
230                "optional": true,
231                "description": "Whether the tabs are active in their windows."
232              },
233              "pinned": {
234                "type": "boolean",
235                "optional": true,
236                "description": "Whether the tabs are pinned."
237              },
238              "highlighted": {
239                "type": "boolean",
240                "optional": true,
241                "description": "Whether the tabs are highlighted."
242              },
243              "status": {
244                "type": "string",
245                "optional": true,
246                "enum": ["loading", "complete"],
247                "description": "Whether the tabs have completed loading."
248              },
249              "title": {
250                "type": "string",
251                "optional": true,
252                "description": "Match page titles against a pattern."
253              },
254              "url": {
255                "type": "string",
256                "optional": true,
257                "description": "Match tabs against a URL pattern."
258              },
259              "windowId": {
260                "type": "integer",
261                "optional": true,
262                "minimum": 0,
263                "description": "The ID of the parent window."
264              },
265              "windowType": {
266                "type": "string",
267                "optional": true,
268                "enum": ["normal", "popup", "panel", "app"],
269                "description": "The type of window the tabs are in."
270              }
271            }
272          },
273          {
274            "type": "function",
275            "name": "callback",
276            "parameters": [
277              {
278                "name": "result",
279                "type": "array",
280                "items": {
281                  "$ref": "Tab"
282                }
283              }
284            ]
285          }
286        ]
287      },
288      {
289        "name": "highlight",
290        "type": "function",
291        "description": "Highlights the given tabs.",
292        "parameters": [
293          {
294            "type": "object",
295            "name": "highlightInfo",
296            "properties": {
297               "windowId": {
298                 "type": "integer",
299                 "description": "The window that contains the tabs."
300               },
301               "tabs": {
302                 "description": "One or more tab indices to highlight.",
303                 "choices": [
304                   {"type": "array", "items": {"type": "integer", "minimum": 0}},
305                   {"type": "integer"}
306                 ]
307               }
308             }
309           },
310           {
311             "type": "function",
312             "name": "callback",
313             "parameters": [
314               {
315                 "name": "window",
316                 "$ref": "Window",
317                 "description": "Contains details about the window whose tabs were highlighted."
318               }
319             ]
320           }
321        ]
322      },
323      {
324        "name": "update",
325        "type": "function",
326        "description": "Modifies the properties of a tab. Properties that are not specified in <var>updateProperties</var> are not modified. Note: This function can be used without requesting the 'tabs' permission in the manifest.",
327        "parameters": [
328          {
329            "type": "integer",
330            "name": "tabId",
331            "minimum": 0,
332            "optional": true,
333            "description": "Defaults to the selected tab of the <a href='windows.html#current-window'>current window</a>."
334          },
335          {
336            "type": "object",
337            "name": "updateProperties",
338            "properties": {
339              "url": {
340                "optional": true,
341                "type": "string",
342                "description": "A URL to navigate the tab to."
343              },
344              "active": {
345                "type": "boolean",
346                "optional": true,
347                "description": "Whether the tab should be active."
348              },
349              "highlighted": {
350                "type": "boolean",
351                "optional": true,
352                "description": "Adds or removes the tab from the current selection."
353              },
354              "selected": {
355                "nodoc": true,
356                "type": "boolean",
357                "optional": true,
358                "description": "Whether the tab should be selected."
359              },
360              "pinned": {
361                "type": "boolean",
362                "optional": true,
363                "description": "Whether the tab should be pinned."
364              }
365            }
366          },
367          {
368            "type": "function",
369            "name": "callback",
370            "optional": true,
371            "parameters": [
372              {
373                "name": "tab",
374                "$ref": "Tab",
375                "optional": true,
376                "description": "Details about the updated tab, or <code>null</code> if the 'tabs' permission has not been requested."
377              }
378            ]
379          }
380        ]
381      },
382      {
383        "name": "move",
384        "type": "function",
385        "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.",
386        "parameters": [
387          {
388            "name": "tabIds",
389            "description": "The tab or list of tabs to move.",
390            "choices": [
391              {"type": "integer", "minimum": 0},
392              {"type": "array", "items": {"type": "integer", "minimum": 0}}
393            ]
394          },
395          {
396            "type": "object",
397            "name": "moveProperties",
398            "properties": {
399              "windowId": {
400                "type": "integer",
401                "minimum": 0,
402                "optional": true,
403                "description": "Defaults to the window the tab is currently in."
404              },
405              "index": {
406                "type": "integer",
407                "minimum": 0,
408                "description": "The position to move the window to. The provided value will be clamped to between zero and the number of tabs in the window."
409              }
410            }
411          },
412          {
413            "type": "function",
414            "name": "callback",
415            "optional": true,
416            "parameters": [
417              {
418                "name": "tabs",
419                "description": "Details about the moved tabs.",
420                "choices": [
421                  {"$ref": "Tab"},
422                  {"type": "array", "items": {"$ref": "Tab"}}
423                ]
424              }
425            ]
426          }
427        ]
428      },
429      {
430        "name": "reload",
431        "type": "function",
432        "description": "Reload a tab.",
433        "parameters": [
434          {"type": "integer", "name": "tabId", "optional": true, "description": "The ID of the tab to reload; defaults to the selected tab of the current window."},
435          {
436            "type": "object",
437            "name": "reloadProperties",
438            "optional": true,
439            "properties": {
440              "bypassCache": {
441                "type": "boolean",
442                "optional": true,
443                "description": "Whether using any local cache. Default is false."
444              }
445            }
446          },
447          {"type": "function", "name": "callback", "optional": true, "parameters": []}
448        ]
449      },
450      {
451        "name": "remove",
452        "type": "function",
453        "description": "Closes one or more tabs. Note: This function can be used without requesting the 'tabs' permission in the manifest.",
454        "parameters": [
455          {
456            "name": "tabIds",
457            "description": "The tab or list of tabs to close.",
458            "choices": [
459              {"type": "integer", "minimum": 0},
460              {"type": "array", "items": {"type": "integer", "minimum": 0}}
461            ]
462          },
463          {"type": "function", "name": "callback", "optional": true, "parameters": []}
464        ]
465      },
466      {
467        "name": "detectLanguage",
468        "type": "function",
469        "description": "Detects the primary language of the content in a tab.",
470        "parameters": [
471          {
472            "type": "integer",
473            "name": "tabId",
474            "minimum": 0,
475            "optional": true,
476            "description": "Defaults to the active tab of the <a href='windows.html#current-window'>current window</a>."
477          },
478          {
479            "type": "function",
480            "name": "callback",
481            "parameters": [
482              {
483                "type": "string",
484                "name": "language",
485                "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."
486              }
487            ]
488          }
489        ]
490      },
491      {
492        "name": "captureVisibleTab",
493        "type": "function",
494        "description": "Captures the visible area of the currently active tab in the specified window. You must have <a href='manifest.html#permissions'>&lt;all_urls&gt;</a> permission to use this method.",
495        "parameters": [
496          {
497            "type": "integer",
498            "name": "windowId",
499            "minimum": 0,
500            "optional": true,
501            "description": "The target window. Defaults to the <a href='windows.html#current-window'>current window</a>."
502          },
503          {
504            "type": "object",
505            "name": "options",
506            "optional": true,
507            "description": "Set parameters of image capture, such as the format of the resulting image.",
508            "properties": {
509              "format": {
510                "type": "string",
511                "optional": true,
512                "enum": ["jpeg", "png"],
513                "description": "The format of the resulting image.  Default is jpeg."
514              },
515              "quality": {
516                "type": "integer",
517                "name": "quality",
518                "optional": true,
519                "minimum": 0,
520                "maximum": 100,
521                "description": "When format is 'jpeg', controls the quality of the resulting image.  This value is ignored for PNG images.  As quality is decreased, the resulting image will have more visual artifacts, and the number of bytes needed to store it will decrease."
522              }
523            }
524          },
525          {
526            "type": "function", "name": "callback", "parameters": [
527              {"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."}
528            ]
529          }
530        ]
531      },
532      {
533        "name": "executeScript",
534        "type": "function",
535        "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.",
536        "parameters": [
537          {"type": "integer", "name": "tabId", "optional": true, "description": "The ID of the tab in which to run the script; defaults to the active tab of the current window."},
538          {
539            "type": "object",
540            "name": "details",
541            "description": "Details of the script to run. Either the code or the file property must be set, but both may not be set at the same time.",
542            "properties": {
543              "code": {"type": "string", "optional": true, "description": "JavaScript code to execute."},
544              "file": {"type": "string", "optional": true, "description": "JavaScript file to execute."},
545              "allFrames": {"type": "boolean", "optional": true, "description": "If allFrames is true, this function injects script into all frames of current page. By default, it's false and script is injected only into the top main frame."}
546            }
547          },
548          {
549            "type": "function",
550            "name": "callback",
551            "optional": true,
552            "description": "Called after all the JavaScript has been executed.",
553            "parameters": []
554          }
555        ]
556      },
557      {
558        "name": "insertCSS",
559        "type": "function",
560        "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.",
561        "parameters": [
562          {"type": "integer", "name": "tabId", "optional": true, "description": "The ID of the tab in which to insert the CSS; defaults to the active tab of the current window."},
563          {
564            "type": "object",
565            "name": "details",
566            "description": "Details of the CSS text to insert. Either the code or the file property must be set, but both may not be set at the same time.",
567            "properties": {
568              "code": {"type": "string", "optional": true, "description": "CSS code to be injected."},
569              "file": {"type": "string", "optional": true, "description": "CSS file to be injected."},
570              "allFrames": {"type": "boolean", "optional": true, "description": "If allFrames is true, this function injects CSS text into all frames of current page. By default, it's false and CSS is injected only into the top main frame."}
571            }
572          },
573          {
574            "type": "function",
575            "name": "callback",
576            "optional": true,
577            "description": "Called when all the CSS has been inserted.",
578            "parameters": []
579          }
580        ]
581      }
582    ],
583    "events": [
584      {
585        "name": "onCreated",
586        "type": "function",
587        "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.",
588        "parameters": [
589          {
590            "$ref": "Tab",
591            "name": "tab",
592            "description": "Details of the tab that was created."
593          }
594        ]
595      },
596      {
597        "name": "onUpdated",
598        "type": "function",
599        "description": "Fired when a tab is updated.",
600        "parameters": [
601          {"type": "integer", "name": "tabId", "minimum": 0},
602          {
603            "type": "object",
604            "name": "changeInfo",
605            "description": "Lists the changes to the state of the tab that was updated.",
606            "properties": {
607              "status": {
608                "type": "string",
609                "optional": true,
610                "description": "The status of the tab. Can be either <em>loading</em> or <em>complete</em>."
611              },
612              "url": {
613                "type": "string",
614                "optional": true,
615                "description": "The tab's URL if it has changed."
616              },
617              "pinned": {
618                "type": "boolean",
619                "optional": true,
620                "description": "The tab's new pinned state."
621              }
622            }
623          },
624          {
625            "$ref": "Tab",
626            "name": "tab",
627            "description": "Gives the state of the tab that was updated."
628          }
629        ]
630      },
631      {
632        "name": "onMoved",
633        "type": "function",
634        "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 <a href='#event-onDetached'>onDetached</a>.",
635        "parameters": [
636          {"type": "integer", "name": "tabId", "minimum": 0},
637          {
638            "type": "object",
639            "name": "moveInfo",
640            "properties": {
641              "windowId": {"type": "integer", "minimum": 0},
642              "fromIndex": {"type": "integer", "minimum": 0},
643              "toIndex": {"type": "integer", "minimum": 0}
644            }
645          }
646        ]
647      },
648      {
649        "name": "onSelectionChanged",
650        "nodoc": true,
651        "type": "function",
652        "description": "Deprecated. Please use onActiveChanged.",
653        "parameters": [
654          {
655            "type": "integer",
656            "name": "tabId",
657            "minimum": 0,
658            "description": "The ID of the tab that has become active."
659          },
660          {
661            "type": "object",
662            "name": "selectInfo",
663            "properties": {
664              "windowId": {
665                "type": "integer",
666                "minimum": 0,
667                "description": "The ID of the window the selected tab changed inside of."
668              }
669            }
670          }
671        ]
672      },
673      {
674        "name": "onActiveChanged",
675        "type": "function",
676        "description": "Fires when the selected tab in a window changes.",
677        "parameters": [
678          {
679            "type": "integer",
680            "name": "tabId",
681            "minimum": 0,
682            "description": "The ID of the tab that has become active."
683          },
684          {
685            "type": "object",
686            "name": "selectInfo",
687            "properties": {
688              "windowId": {
689                "type": "integer",
690                "minimum": 0,
691                "description": "The ID of the window the selected tab changed inside of."
692              }
693            }
694          }
695        ]
696      },
697      {
698        "name": "onHighlightChanged",
699        "type": "function",
700        "description": "Fired when the highlighted or selected tabs in a window changes.",
701        "parameters": [
702          {
703            "type": "object",
704            "name": "selectInfo",
705            "properties": {
706              "windowId": {
707                "type": "integer",
708                "minimum": 0,
709                "description": "The window whose tabs changed."
710              },
711              "tabIds": {
712                "type": "array",
713                "name": "tabIds",
714                "items": {"type": "integer", "minimum": 0},
715                "description": "All highlighted tabs in the window."
716              }
717            }
718          }
719        ]
720      },
721      {
722        "name": "onDetached",
723        "type": "function",
724        "description": "Fired when a tab is detached from a window, for example because it is being moved between windows.",
725        "parameters": [
726          {"type": "integer", "name": "tabId", "minimum": 0},
727          {
728            "type": "object",
729            "name": "detachInfo",
730            "properties": {
731              "oldWindowId": {"type": "integer", "minimum": 0},
732              "oldPosition": {"type": "integer", "minimum": 0}
733            }
734          }
735        ]
736      },
737      {
738        "name": "onAttached",
739        "type": "function",
740        "description": "Fired when a tab is attached to a window, for example because it was moved between windows.",
741        "parameters": [
742          {"type": "integer", "name": "tabId", "minimum": 0},
743          {
744            "type": "object",
745            "name": "attachInfo",
746            "properties": {
747              "newWindowId": {"type": "integer", "minimum": 0},
748              "newPosition": {"type": "integer", "minimum": 0}
749            }
750          }
751        ]
752      },
753      {
754        "name": "onRemoved",
755        "type": "function",
756        "description": "Fired when a tab is closed. Note: A listener can be registered for this event without requesting the 'tabs' permission in the manifest.",
757        "parameters": [
758          {"type": "integer", "name": "tabId", "minimum": 0},
759          {
760            "type": "object",
761            "name": "removeInfo",
762            "properties": {
763              "isWindowClosing": {"type": "boolean", "description": "True when the tab is being closed because its window is being closed." }
764            }
765          }
766        ]
767      }
768    ]
769  }
770]
771