forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtabs.js
593 lines (539 loc) · 21.2 KB
/
tabs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file was generated by:
// tools/json_schema_compiler/compiler.py.
// NOTE: The format of types has changed. 'FooType' is now
// 'chrome.tabs.FooType'.
// Please run the closure compiler before committing changes.
// See https://chromium.googlesource.com/chromium/src/+/master/docs/closure_compilation.md
// IMPORTANT NOTE: Work-around for crbug.com/543822
// s/chrome.tabs.extensionTypes.ImageDetails/chrome.extensionTypes.ImageDetails/
// s/chrome.tabs.extensionTypes.InjectDetails/chrome.extensionTypes.InjectDetails/
// s/chrome.tabs.runtime.Port/chrome.runtime.Port/
// s/chrome.tabs.windows.Window/chrome.windows.Window/
/** @fileoverview Externs generated from namespace: tabs */
/** @const */
chrome.tabs = {};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/tabs#type-TabStatus
*/
chrome.tabs.TabStatus = {
UNLOADED: 'unloaded',
LOADING: 'loading',
COMPLETE: 'complete',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/tabs#type-MutedInfoReason
*/
chrome.tabs.MutedInfoReason = {
USER: 'user',
CAPTURE: 'capture',
EXTENSION: 'extension',
};
/**
* The tab's muted state and the reason for the last state change.
* @typedef {{
* muted: boolean,
* reason: (!chrome.tabs.MutedInfoReason|undefined),
* extensionId: (string|undefined)
* }}
* @see https://developer.chrome.com/extensions/tabs#type-MutedInfo
*/
chrome.tabs.MutedInfo;
/**
* @typedef {{
* id: (number|undefined),
* index: number,
* groupId: number,
* windowId: number,
* openerTabId: (number|undefined),
* selected: boolean,
* highlighted: boolean,
* active: boolean,
* pinned: boolean,
* audible: (boolean|undefined),
* discarded: boolean,
* autoDiscardable: boolean,
* mutedInfo: (!chrome.tabs.MutedInfo|undefined),
* url: (string|undefined),
* pendingUrl: (string|undefined),
* title: (string|undefined),
* favIconUrl: (string|undefined),
* status: (!chrome.tabs.TabStatus|undefined),
* incognito: boolean,
* width: (number|undefined),
* height: (number|undefined),
* sessionId: (string|undefined)
* }}
* @see https://developer.chrome.com/extensions/tabs#type-Tab
*/
chrome.tabs.Tab;
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/tabs#type-ZoomSettingsMode
*/
chrome.tabs.ZoomSettingsMode = {
AUTOMATIC: 'automatic',
MANUAL: 'manual',
DISABLED: 'disabled',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/tabs#type-ZoomSettingsScope
*/
chrome.tabs.ZoomSettingsScope = {
PER_ORIGIN: 'per-origin',
PER_TAB: 'per-tab',
};
/**
* Defines how zoom changes in a tab are handled and at what scope.
* @typedef {{
* mode: (!chrome.tabs.ZoomSettingsMode|undefined),
* scope: (!chrome.tabs.ZoomSettingsScope|undefined),
* defaultZoomFactor: (number|undefined)
* }}
* @see https://developer.chrome.com/extensions/tabs#type-ZoomSettings
*/
chrome.tabs.ZoomSettings;
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/tabs#type-WindowType
*/
chrome.tabs.WindowType = {
NORMAL: 'normal',
POPUP: 'popup',
PANEL: 'panel',
APP: 'app',
DEVTOOLS: 'devtools',
};
/**
* An ID that represents the absence of a browser tab.
* @type {number}
* @see https://developer.chrome.com/extensions/tabs#type-TAB_ID_NONE
*/
chrome.tabs.TAB_ID_NONE;
/**
* Retrieves details about the specified tab.
* @param {number} tabId
* @param {function(!chrome.tabs.Tab): void} callback
* @see https://developer.chrome.com/extensions/tabs#method-get
*/
chrome.tabs.get = function(tabId, callback) {};
/**
* 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).
* @param {function((!chrome.tabs.Tab|undefined)): void} callback
* @see https://developer.chrome.com/extensions/tabs#method-getCurrent
*/
chrome.tabs.getCurrent = function(callback) {};
/**
* 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'>Content Script Messaging</a>.
* @param {number} tabId
* @param {{
* name: (string|undefined),
* frameId: (number|undefined)
* }=} connectInfo
* @return {!chrome.runtime.Port} 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.
* @see https://developer.chrome.com/extensions/tabs#method-connect
*/
chrome.tabs.connect = function(tabId, connectInfo) {};
/**
* 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.
* @param {number} tabId
* @param {*} request
* @param {function(*): void=} responseCallback
* @deprecated Please use $(ref:runtime.sendMessage).
* @see https://developer.chrome.com/extensions/tabs#method-sendRequest
*/
chrome.tabs.sendRequest = function(tabId, request, responseCallback) {};
/**
* 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.
* @param {number} tabId
* @param {*} message The message to send. This message should be a JSON-ifiable
* object.
* @param {{
* frameId: (number|undefined)
* }=} options
* @param {function(*): void=} responseCallback
* @see https://developer.chrome.com/extensions/tabs#method-sendMessage
*/
chrome.tabs.sendMessage = function(tabId, message, options, responseCallback) {};
/**
* Gets the tab that is selected in the specified window.
* @param {?number|undefined} windowId Defaults to the <a
* href='windows#current-window'>current window</a>.
* @param {function(!chrome.tabs.Tab): void} callback
* @deprecated Please use $(ref:tabs.query) <code>{active: true}</code>.
* @see https://developer.chrome.com/extensions/tabs#method-getSelected
*/
chrome.tabs.getSelected = function(windowId, callback) {};
/**
* Gets details about all tabs in the specified window.
* @param {?number|undefined} windowId Defaults to the <a
* href='windows#current-window'>current window</a>.
* @param {function(!Array<!chrome.tabs.Tab>): void} callback
* @deprecated Please use $(ref:tabs.query) <code>{windowId: windowId}</code>.
* @see https://developer.chrome.com/extensions/tabs#method-getAllInWindow
*/
chrome.tabs.getAllInWindow = function(windowId, callback) {};
/**
* Creates a new tab.
* @param {{
* windowId: (number|undefined),
* index: (number|undefined),
* url: (string|undefined),
* active: (boolean|undefined),
* selected: (boolean|undefined),
* pinned: (boolean|undefined),
* openerTabId: (number|undefined)
* }} createProperties
* @param {function(!chrome.tabs.Tab): void=} callback
* @see https://developer.chrome.com/extensions/tabs#method-create
*/
chrome.tabs.create = function(createProperties, callback) {};
/**
* Duplicates a tab.
* @param {number} tabId The ID of the tab to duplicate.
* @param {function((!chrome.tabs.Tab|undefined)): void=} callback
* @see https://developer.chrome.com/extensions/tabs#method-duplicate
*/
chrome.tabs.duplicate = function(tabId, callback) {};
/**
* Gets all tabs that have the specified properties, or all tabs if no
* properties are specified.
* @param {{
* active: (boolean|undefined),
* pinned: (boolean|undefined),
* audible: (boolean|undefined),
* muted: (boolean|undefined),
* highlighted: (boolean|undefined),
* discarded: (boolean|undefined),
* autoDiscardable: (boolean|undefined),
* currentWindow: (boolean|undefined),
* lastFocusedWindow: (boolean|undefined),
* status: (!chrome.tabs.TabStatus|undefined),
* title: (string|undefined),
* url: ((string|!Array<string>)|undefined),
* groupId: (number|undefined),
* windowId: (number|undefined),
* windowType: (!chrome.tabs.WindowType|undefined),
* index: (number|undefined)
* }} queryInfo
* @param {function(!Array<!chrome.tabs.Tab>): void} callback
* @see https://developer.chrome.com/extensions/tabs#method-query
*/
chrome.tabs.query = function(queryInfo, callback) {};
/**
* Highlights the given tabs and focuses on the first of group. Will appear to
* do nothing if the specified tab is currently active.
* @param {{
* windowId: (number|undefined),
* tabs: (!Array<number>|number)
* }} highlightInfo
* @param {function(!chrome.windows.Window): void=} callback
* @see https://developer.chrome.com/extensions/tabs#method-highlight
*/
chrome.tabs.highlight = function(highlightInfo, callback) {};
/**
* Modifies the properties of a tab. Properties that are not specified in
* <var>updateProperties</var> are not modified.
* @param {?number|undefined} tabId Defaults to the selected tab of the <a
* href='windows#current-window'>current window</a>.
* @param {{
* url: (string|undefined),
* active: (boolean|undefined),
* highlighted: (boolean|undefined),
* selected: (boolean|undefined),
* pinned: (boolean|undefined),
* muted: (boolean|undefined),
* openerTabId: (number|undefined),
* autoDiscardable: (boolean|undefined)
* }} updateProperties
* @param {function((!chrome.tabs.Tab|undefined)): void=} callback
* @see https://developer.chrome.com/extensions/tabs#method-update
*/
chrome.tabs.update = function(tabId, updateProperties, callback) {};
/**
* 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.
* @param {(number|!Array<number>)} tabIds The tab ID or list of tab IDs to
* move.
* @param {{
* windowId: (number|undefined),
* index: number
* }} moveProperties
* @param {function((!chrome.tabs.Tab|!Array<!chrome.tabs.Tab>)): void=}
* callback
* @see https://developer.chrome.com/extensions/tabs#method-move
*/
chrome.tabs.move = function(tabIds, moveProperties, callback) {};
/**
* Reload a tab.
* @param {number=} tabId The ID of the tab to reload; defaults to the selected
* tab of the current window.
* @param {{
* bypassCache: (boolean|undefined)
* }=} reloadProperties
* @param {function(): void=} callback
* @see https://developer.chrome.com/extensions/tabs#method-reload
*/
chrome.tabs.reload = function(tabId, reloadProperties, callback) {};
/**
* Closes one or more tabs.
* @param {(number|!Array<number>)} tabIds The tab ID or list of tab IDs to
* close.
* @param {function(): void=} callback
* @see https://developer.chrome.com/extensions/tabs#method-remove
*/
chrome.tabs.remove = function(tabIds, callback) {};
/**
* Adds one or more tabs to a specified group, or if no group is specified, adds
* the given tabs to a newly created group.
* @param {{
* tabIds: (number|!Array<number>),
* groupId: (number|undefined),
* createProperties: ({
* windowId: (number|undefined)
* }|undefined)
* }} options
* @param {function(number): void=} callback
* @see https://developer.chrome.com/extensions/tabs#method-group
*/
chrome.tabs.group = function(options, callback) {};
/**
* Removes one or more tabs from their respective groups. If any groups become
* empty, they are deleted.
* @param {(number|!Array<number>)} tabIds The tab ID or list of tab IDs to
* remove from their respective groups.
* @param {function(): void=} callback
* @see https://developer.chrome.com/extensions/tabs#method-ungroup
*/
chrome.tabs.ungroup = function(tabIds, callback) {};
/**
* Detects the primary language of the content in a tab.
* @param {?number|undefined} tabId Defaults to the active tab of the <a
* href='windows#current-window'>current window</a>.
* @param {function(string): void} callback
* @see https://developer.chrome.com/extensions/tabs#method-detectLanguage
*/
chrome.tabs.detectLanguage = function(tabId, callback) {};
/**
* Captures the visible area of the currently active tab in the specified
* window. In order to call this method, the extension must have either the <a
* href='declare_permissions'><all_urls></a> permission or the <a
* href='activeTab'>activeTab</a> permission. In addition to sites that
* extensions can normally access, this method allows extensions to capture
* sensitive sites that are otherwise restricted, including chrome:-scheme
* pages, other extensions' pages, and data: URLs. These sensitive sites can
* only be captured with the activeTab permission. File URLs may be captured
* only if the extension has been granted file access.
* @param {?number|undefined} windowId The target window. Defaults to the <a
* href='windows#current-window'>current window</a>.
* @param {?chrome.extensionTypes.ImageDetails|undefined} options
* @param {function(string): void} callback
* @see https://developer.chrome.com/extensions/tabs#method-captureVisibleTab
*/
chrome.tabs.captureVisibleTab = function(windowId, options, callback) {};
/**
* Injects JavaScript code into a page. For details, see the <a
* href='content_scripts#pi'>programmatic injection</a> section of the content
* scripts doc.
* @param {?number|undefined} tabId The ID of the tab in which to run the
* script; defaults to the active tab of the current window.
* @param {!chrome.extensionTypes.InjectDetails} details 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.
* @param {function((!Array<*>|undefined)): void=} callback Called after all the
* JavaScript has been executed.
* @see https://developer.chrome.com/extensions/tabs#method-executeScript
*/
chrome.tabs.executeScript = function(tabId, details, callback) {};
/**
* Injects CSS into a page. For details, see the <a
* href='content_scripts#pi'>programmatic injection</a> section of the content
* scripts doc.
* @param {?number|undefined} tabId The ID of the tab in which to insert the
* CSS; defaults to the active tab of the current window.
* @param {!chrome.extensionTypes.InjectDetails} details 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.
* @param {function(): void=} callback Called when all the CSS has been
* inserted.
* @see https://developer.chrome.com/extensions/tabs#method-insertCSS
*/
chrome.tabs.insertCSS = function(tabId, details, callback) {};
/**
* Zooms a specified tab.
* @param {?number|undefined} tabId The ID of the tab to zoom; defaults to the
* active tab of the current window.
* @param {number} zoomFactor The new zoom factor. A value of <code>0</code>
* sets the tab to its current default zoom factor. Values greater than
* <code>0</code> specify a (possibly non-default) zoom factor for the tab.
* @param {function(): void=} callback Called after the zoom factor has been
* changed.
* @see https://developer.chrome.com/extensions/tabs#method-setZoom
*/
chrome.tabs.setZoom = function(tabId, zoomFactor, callback) {};
/**
* Gets the current zoom factor of a specified tab.
* @param {?number|undefined} tabId The ID of the tab to get the current zoom
* factor from; defaults to the active tab of the current window.
* @param {function(number): void} callback Called with the tab's current zoom
* factor after it has been fetched.
* @see https://developer.chrome.com/extensions/tabs#method-getZoom
*/
chrome.tabs.getZoom = function(tabId, callback) {};
/**
* Sets the zoom settings for a specified tab, which define how zoom changes are
* handled. These settings are reset to defaults upon navigating the tab.
* @param {?number|undefined} tabId The ID of the tab to change the zoom
* settings for; defaults to the active tab of the current window.
* @param {!chrome.tabs.ZoomSettings} zoomSettings Defines how zoom changes are
* handled and at what scope.
* @param {function(): void=} callback Called after the zoom settings are
* changed.
* @see https://developer.chrome.com/extensions/tabs#method-setZoomSettings
*/
chrome.tabs.setZoomSettings = function(tabId, zoomSettings, callback) {};
/**
* Gets the current zoom settings of a specified tab.
* @param {?number|undefined} tabId The ID of the tab to get the current zoom
* settings from; defaults to the active tab of the current window.
* @param {function(!chrome.tabs.ZoomSettings): void} callback Called with the
* tab's current zoom settings.
* @see https://developer.chrome.com/extensions/tabs#method-getZoomSettings
*/
chrome.tabs.getZoomSettings = function(tabId, callback) {};
/**
* Discards a tab from memory. Discarded tabs are still visible on the tab strip
* and are reloaded when activated.
* @param {number=} tabId The ID of the tab to be discarded. If specified, the
* tab is discarded unless it is active or already discarded. If omitted,
* the browser discards the least important tab. This can fail if no
* discardable tabs exist.
* @param {function((!chrome.tabs.Tab|undefined)): void=} callback Called after
* the operation is completed.
* @see https://developer.chrome.com/extensions/tabs#method-discard
*/
chrome.tabs.discard = function(tabId, callback) {};
/**
* Go foward to the next page, if one is available.
* @param {number=} tabId The ID of the tab to navigate forward; defaults to the
* selected tab of the current window.
* @param {function(): void=} callback
* @see https://developer.chrome.com/extensions/tabs#method-goForward
*/
chrome.tabs.goForward = function(tabId, callback) {};
/**
* Go back to the previous page, if one is available.
* @param {number=} tabId The ID of the tab to navigate back; defaults to the
* selected tab of the current window.
* @param {function(): void=} callback
* @see https://developer.chrome.com/extensions/tabs#method-goBack
*/
chrome.tabs.goBack = function(tabId, callback) {};
/**
* Fired when a tab is created. Note that the tab's URL 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.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onCreated
*/
chrome.tabs.onCreated;
/**
* Fired when a tab is updated.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onUpdated
*/
chrome.tabs.onUpdated;
/**
* 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).
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onMoved
*/
chrome.tabs.onMoved;
/**
* Fires when the selected tab in a window changes.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onSelectionChanged
*/
chrome.tabs.onSelectionChanged;
/**
* 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.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onActiveChanged
*/
chrome.tabs.onActiveChanged;
/**
* 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.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onActivated
*/
chrome.tabs.onActivated;
/**
* Fired when the highlighted or selected tabs in a window changes.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onHighlightChanged
*/
chrome.tabs.onHighlightChanged;
/**
* Fired when the highlighted or selected tabs in a window changes.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onHighlighted
*/
chrome.tabs.onHighlighted;
/**
* Fired when a tab is detached from a window; for example, because it was moved
* between windows.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onDetached
*/
chrome.tabs.onDetached;
/**
* Fired when a tab is attached to a window; for example, because it was moved
* between windows.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onAttached
*/
chrome.tabs.onAttached;
/**
* Fired when a tab is closed.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onRemoved
*/
chrome.tabs.onRemoved;
/**
* Fired when a tab is replaced with another tab due to prerendering or instant.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onReplaced
*/
chrome.tabs.onReplaced;
/**
* Fired when a tab is zoomed.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/tabs#event-onZoomChange
*/
chrome.tabs.onZoomChange;