Dart Documentationchrome.tabsChromeTabs

ChromeTabs class

class ChromeTabs extends ChromeApi {
 static final JsObject _tabs = chrome['tabs'];

 ChromeTabs._();

 bool get available => _tabs != null;

 /**
  * Retrieves details about the specified tab.
  */
 Future<Tab> get(int tabId) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<Tab>.oneArg(_createTab);
   _tabs.callMethod('get', [tabId, completer.callback]);
   return completer.future;
 }

 /**
  * 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).
  */
 Future<Tab> getCurrent() {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<Tab>.oneArg(_createTab);
   _tabs.callMethod('getCurrent', [completer.callback]);
   return completer.future;
 }

 /**
  * Connects to the content script(s) in the specified tab. The
  * [runtime.onConnect] event is fired in each content script running in the
  * specified tab for the current extension. For more details, see [Content
  * Script Messaging](messaging.html).
  * 
  * Returns:
  * A port that can be used to communicate with the content scripts running in
  * the specified tab. The port's [runtime.Port] event is fired if the tab
  * closes or does not exist.
  */
 Port connect(int tabId, [TabsConnectParams connectInfo]) {
   if (_tabs == null) _throwNotAvailable();

   return _createPort(_tabs.callMethod('connect', [tabId, jsify(connectInfo)]));
 }

 /**
  * Deprecated: Please use sendMessage.
  * 
  * Returns:
  * 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 [runtime.lastError] will be set to the error message.
  */
 Future<dynamic> sendRequest(int tabId, dynamic request) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<dynamic>.oneArg();
   _tabs.callMethod('sendRequest', [tabId, jsify(request), completer.callback]);
   return completer.future;
 }

 /**
  * 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
  * [runtime.onMessage] event is fired in each content script running in the
  * specified tab for the current extension.
  * 
  * Returns:
  * 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 [runtime.lastError] will be set to the error message.
  */
 Future<dynamic> sendMessage(int tabId, dynamic message) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<dynamic>.oneArg();
   _tabs.callMethod('sendMessage', [tabId, jsify(message), completer.callback]);
   return completer.future;
 }

 /**
  * Deprecated. Please use query({'active': true}). Gets the tab that is
  * selected in the specified window.
  * 
  * [windowId] Defaults to the [current window](windows.html#current-window).
  */
 Future<Tab> getSelected([int windowId]) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<Tab>.oneArg(_createTab);
   _tabs.callMethod('getSelected', [windowId, completer.callback]);
   return completer.future;
 }

 /**
  * Deprecated. Please use query({'windowId': windowId}). Gets details about
  * all tabs in the specified window.
  * 
  * [windowId] Defaults to the [current window](windows.html#current-window).
  */
 Future<List<Tab>> getAllInWindow([int windowId]) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<List<Tab>>.oneArg((e) => listify(e, _createTab));
   _tabs.callMethod('getAllInWindow', [windowId, completer.callback]);
   return completer.future;
 }

 /**
  * Creates a new tab.
  * 
  * Returns:
  * Details about the created tab. Will contain the ID of the new tab.
  */
 Future<Tab> create(TabsCreateParams createProperties) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<Tab>.oneArg(_createTab);
   _tabs.callMethod('create', [jsify(createProperties), completer.callback]);
   return completer.future;
 }

 /**
  * Duplicates a tab.
  * 
  * [tabId] The ID of the tab which is to be duplicated.
  * 
  * Returns:
  * Details about the duplicated tab. The [tabs.Tab] object doesn't contain
  * `url`, `title` and `favIconUrl` if the `"tabs"` permission has not been
  * requested.
  */
 Future<Tab> duplicate(int tabId) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<Tab>.oneArg(_createTab);
   _tabs.callMethod('duplicate', [tabId, completer.callback]);
   return completer.future;
 }

 /**
  * Gets all tabs that have the specified properties, or all tabs if no
  * properties are specified.
  */
 Future<List<Tab>> query(TabsQueryParams queryInfo) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<List<Tab>>.oneArg((e) => listify(e, _createTab));
   _tabs.callMethod('query', [jsify(queryInfo), completer.callback]);
   return completer.future;
 }

 /**
  * Highlights the given tabs.
  * 
  * Returns:
  * Contains details about the window whose tabs were highlighted.
  */
 Future<Window> highlight(TabsHighlightParams highlightInfo) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<Window>.oneArg(_createWindow);
   _tabs.callMethod('highlight', [jsify(highlightInfo), completer.callback]);
   return completer.future;
 }

 /**
  * Modifies the properties of a tab. Properties that are not specified in
  * [updateProperties] are not modified.
  * 
  * [tabId] Defaults to the selected tab of the [current
  * window](windows.html#current-window).
  * 
  * Returns:
  * Details about the updated tab. The [tabs.Tab] object doesn't contain `url`,
  * `title` and `favIconUrl` if the `"tabs"` permission has not been requested.
  */
 Future<Tab> update(TabsUpdateParams updateProperties, [int tabId]) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<Tab>.oneArg(_createTab);
   _tabs.callMethod('update', [tabId, jsify(updateProperties), completer.callback]);
   return completer.future;
 }

 /**
  * 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.
  * 
  * [tabIds] The tab or list of tabs to move.
  * 
  * Returns:
  * Details about the moved tabs.
  */
 Future<dynamic> move(dynamic tabIds, TabsMoveParams moveProperties) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<dynamic>.oneArg();
   _tabs.callMethod('move', [jsify(tabIds), jsify(moveProperties), completer.callback]);
   return completer.future;
 }

 /**
  * Reload a tab.
  * 
  * [tabId] The ID of the tab to reload; defaults to the selected tab of the
  * current window.
  */
 Future reload([int tabId, TabsReloadParams reloadProperties]) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter.noArgs();
   _tabs.callMethod('reload', [tabId, jsify(reloadProperties), completer.callback]);
   return completer.future;
 }

 /**
  * Closes one or more tabs.
  * 
  * [tabIds] The tab or list of tabs to close.
  */
 Future remove(dynamic tabIds) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter.noArgs();
   _tabs.callMethod('remove', [jsify(tabIds), completer.callback]);
   return completer.future;
 }

 /**
  * Detects the primary language of the content in a tab.
  * 
  * [tabId] Defaults to the active tab of the [current
  * window](windows.html#current-window).
  * 
  * Returns:
  * An ISO language code such as `en` or `fr`. For a complete list of languages
  * supported by this method, see
  * [kLanguageInfoTable](http://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc).
  * 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, `und` will be returned.
  */
 Future<String> detectLanguage([int tabId]) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<String>.oneArg();
   _tabs.callMethod('detectLanguage', [tabId, completer.callback]);
   return completer.future;
 }

 /**
  * Captures the visible area of the currently active tab in the specified
  * window. You must have [host permission](declare_permissions.html) for the
  * URL displayed by the tab.
  * 
  * [windowId] The target window. Defaults to the [current
  * window](windows.html#current-window).
  * 
  * [options] Set parameters of image capture, such as the format of the
  * resulting image.
  * 
  * Returns:
  * 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.
  */
 Future<String> captureVisibleTab([int windowId, TabsCaptureVisibleTabParams options]) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<String>.oneArg();
   _tabs.callMethod('captureVisibleTab', [windowId, jsify(options), completer.callback]);
   return completer.future;
 }

 /**
  * Injects JavaScript code into a page. For details, see the [programmatic
  * injection](content_scripts.html#pi) section of the content scripts doc.
  * 
  * [tabId] The ID of the tab in which to run the script; defaults to the
  * active tab of the current window.
  * 
  * [details] Details of the script to run.
  * 
  * Returns:
  * The result of the script in every injected frame.
  */
 Future<List<dynamic>> executeScript(InjectDetails details, [int tabId]) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter<List<dynamic>>.oneArg(listify);
   _tabs.callMethod('executeScript', [tabId, jsify(details), completer.callback]);
   return completer.future;
 }

 /**
  * Injects CSS into a page. For details, see the [programmatic
  * injection](content_scripts.html#pi) section of the content scripts doc.
  * 
  * [tabId] The ID of the tab in which to insert the CSS; defaults to the
  * active tab of the current window.
  * 
  * [details] Details of the CSS text to insert.
  */
 Future insertCSS(InjectDetails details, [int tabId]) {
   if (_tabs == null) _throwNotAvailable();

   var completer = new ChromeCompleter.noArgs();
   _tabs.callMethod('insertCSS', [tabId, jsify(details), completer.callback]);
   return completer.future;
 }

 /**
  * 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.
  */
 Stream<Tab> get onCreated => _onCreated.stream;

 final ChromeStreamController<Tab> _onCreated =
     new ChromeStreamController<Tab>.oneArg(_tabs, 'onCreated', _createTab);

 /**
  * Fired when a tab is updated.
  */
 Stream<OnUpdatedEvent> get onUpdated => _onUpdated.stream;

 final ChromeStreamController<OnUpdatedEvent> _onUpdated =
     new ChromeStreamController<OnUpdatedEvent>.threeArgs(_tabs, 'onUpdated', _createOnUpdatedEvent);

 /**
  * 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 [onDetached.]
  */
 Stream<TabsOnMovedEvent> get onMoved => _onMoved.stream;

 final ChromeStreamController<TabsOnMovedEvent> _onMoved =
     new ChromeStreamController<TabsOnMovedEvent>.twoArgs(_tabs, 'onMoved', _createOnMovedEvent);

 /**
  * Deprecated. Please use onActivated.
  */
 Stream<OnSelectionChangedEvent> get onSelectionChanged => _onSelectionChanged.stream;

 final ChromeStreamController<OnSelectionChangedEvent> _onSelectionChanged =
     new ChromeStreamController<OnSelectionChangedEvent>.twoArgs(_tabs, 'onSelectionChanged', _createOnSelectionChangedEvent);

 /**
  * Deprecated. Please use onActivated.
  */
 Stream<OnActiveChangedEvent> get onActiveChanged => _onActiveChanged.stream;

 final ChromeStreamController<OnActiveChangedEvent> _onActiveChanged =
     new ChromeStreamController<OnActiveChangedEvent>.twoArgs(_tabs, 'onActiveChanged', _createOnActiveChangedEvent);

 /**
  * 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.
  */
 Stream<Map> get onActivated => _onActivated.stream;

 final ChromeStreamController<Map> _onActivated =
     new ChromeStreamController<Map>.oneArg(_tabs, 'onActivated', mapify);

 /**
  * Deprecated. Please use onHighlighted.
  */
 Stream<Map> get onHighlightChanged => _onHighlightChanged.stream;

 final ChromeStreamController<Map> _onHighlightChanged =
     new ChromeStreamController<Map>.oneArg(_tabs, 'onHighlightChanged', mapify);

 /**
  * Fired when the highlighted or selected tabs in a window changes.
  */
 Stream<Map> get onHighlighted => _onHighlighted.stream;

 final ChromeStreamController<Map> _onHighlighted =
     new ChromeStreamController<Map>.oneArg(_tabs, 'onHighlighted', mapify);

 /**
  * Fired when a tab is detached from a window, for example because it is being
  * moved between windows.
  */
 Stream<OnDetachedEvent> get onDetached => _onDetached.stream;

 final ChromeStreamController<OnDetachedEvent> _onDetached =
     new ChromeStreamController<OnDetachedEvent>.twoArgs(_tabs, 'onDetached', _createOnDetachedEvent);

 /**
  * Fired when a tab is attached to a window, for example because it was moved
  * between windows.
  */
 Stream<OnAttachedEvent> get onAttached => _onAttached.stream;

 final ChromeStreamController<OnAttachedEvent> _onAttached =
     new ChromeStreamController<OnAttachedEvent>.twoArgs(_tabs, 'onAttached', _createOnAttachedEvent);

 /**
  * Fired when a tab is closed.
  */
 Stream<TabsOnRemovedEvent> get onRemoved => _onRemoved.stream;

 final ChromeStreamController<TabsOnRemovedEvent> _onRemoved =
     new ChromeStreamController<TabsOnRemovedEvent>.twoArgs(_tabs, 'onRemoved', _createOnRemovedEvent);

 /**
  * Fired when a tab is replaced with another tab due to prerendering or
  * instant.
  */
 Stream<OnReplacedEvent> get onReplaced => _onReplaced.stream;

 final ChromeStreamController<OnReplacedEvent> _onReplaced =
     new ChromeStreamController<OnReplacedEvent>.twoArgs(_tabs, 'onReplaced', _createOnReplacedEvent);

 void _throwNotAvailable() {
   throw new UnsupportedError("'chrome.tabs' is not available");
 }
}

Extends

ChromeApi > ChromeTabs

Properties

final bool available #

Returns true if the API is available. The common causes of an API not being avilable are:

  • a permission is missing in the application's manifest.json file
  • the API is defined on a newer version of Chrome then the current runtime
docs inherited from ChromeApi
bool get available => _tabs != null;

final Stream<Map> onActivated #

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.

Stream<Map> get onActivated => _onActivated.stream;

final Stream<OnActiveChangedEvent> onActiveChanged #

Deprecated. Please use onActivated.

Stream<OnActiveChangedEvent> get onActiveChanged => _onActiveChanged.stream;

final Stream<OnAttachedEvent> onAttached #

Fired when a tab is attached to a window, for example because it was moved between windows.

Stream<OnAttachedEvent> get onAttached => _onAttached.stream;

final Stream<Tab> onCreated #

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.

Stream<Tab> get onCreated => _onCreated.stream;

final Stream<OnDetachedEvent> onDetached #

Fired when a tab is detached from a window, for example because it is being moved between windows.

Stream<OnDetachedEvent> get onDetached => _onDetached.stream;

final Stream<Map> onHighlightChanged #

Deprecated. Please use onHighlighted.

Stream<Map> get onHighlightChanged => _onHighlightChanged.stream;

final Stream<Map> onHighlighted #

Fired when the highlighted or selected tabs in a window changes.

Stream<Map> get onHighlighted => _onHighlighted.stream;

final Stream<TabsOnMovedEvent> onMoved #

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 onDetached.

Stream<TabsOnMovedEvent> get onMoved => _onMoved.stream;

final Stream<TabsOnRemovedEvent> onRemoved #

Fired when a tab is closed.

Stream<TabsOnRemovedEvent> get onRemoved => _onRemoved.stream;

final Stream<OnReplacedEvent> onReplaced #

Fired when a tab is replaced with another tab due to prerendering or instant.

Stream<OnReplacedEvent> get onReplaced => _onReplaced.stream;

final Stream<OnSelectionChangedEvent> onSelectionChanged #

Deprecated. Please use onActivated.

Stream<OnSelectionChangedEvent> get onSelectionChanged => _onSelectionChanged.stream;

final Stream<OnUpdatedEvent> onUpdated #

Fired when a tab is updated.

Stream<OnUpdatedEvent> get onUpdated => _onUpdated.stream;

Methods

Future<String> captureVisibleTab([int windowId, TabsCaptureVisibleTabParams options]) #

Captures the visible area of the currently active tab in the specified window. You must have host permission for the URL displayed by the tab.

windowId The target window. Defaults to the current window.

options Set parameters of image capture, such as the format of the resulting image.

Returns: 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.

Future<String> captureVisibleTab([int windowId, TabsCaptureVisibleTabParams options]) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<String>.oneArg();
 _tabs.callMethod('captureVisibleTab', [windowId, jsify(options), completer.callback]);
 return completer.future;
}

Port connect(int tabId, [TabsConnectParams connectInfo]) #

Connects to the content script(s) in the specified tab. The runtime.onConnect event is fired in each content script running in the specified tab for the current extension. For more details, see Content Script Messaging.

Returns: A port that can be used to communicate with the content scripts running in the specified tab. The port's runtime.Port event is fired if the tab closes or does not exist.

Port connect(int tabId, [TabsConnectParams connectInfo]) {
 if (_tabs == null) _throwNotAvailable();

 return _createPort(_tabs.callMethod('connect', [tabId, jsify(connectInfo)]));
}

Future<Tab> create(TabsCreateParams createProperties) #

Creates a new tab.

Returns: Details about the created tab. Will contain the ID of the new tab.

Future<Tab> create(TabsCreateParams createProperties) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<Tab>.oneArg(_createTab);
 _tabs.callMethod('create', [jsify(createProperties), completer.callback]);
 return completer.future;
}

Future<String> detectLanguage([int tabId]) #

Detects the primary language of the content in a tab.

tabId Defaults to the active tab of the current window.

Returns: An ISO language code such as en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. 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, und will be returned.

Future<String> detectLanguage([int tabId]) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<String>.oneArg();
 _tabs.callMethod('detectLanguage', [tabId, completer.callback]);
 return completer.future;
}

Future<Tab> duplicate(int tabId) #

Duplicates a tab.

tabId The ID of the tab which is to be duplicated.

Returns: Details about the duplicated tab. The tabs.Tab object doesn't contain url, title and favIconUrl if the "tabs" permission has not been requested.

Future<Tab> duplicate(int tabId) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<Tab>.oneArg(_createTab);
 _tabs.callMethod('duplicate', [tabId, completer.callback]);
 return completer.future;
}

Future<List<dynamic>> executeScript(InjectDetails details, [int tabId]) #

Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.

tabId The ID of the tab in which to run the script; defaults to the active tab of the current window.

details Details of the script to run.

Returns: The result of the script in every injected frame.

Future<List<dynamic>> executeScript(InjectDetails details, [int tabId]) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<List<dynamic>>.oneArg(listify);
 _tabs.callMethod('executeScript', [tabId, jsify(details), completer.callback]);
 return completer.future;
}

Future<Tab> get(int tabId) #

Retrieves details about the specified tab.

Future<Tab> get(int tabId) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<Tab>.oneArg(_createTab);
 _tabs.callMethod('get', [tabId, completer.callback]);
 return completer.future;
}

Future<List<Tab>> getAllInWindow([int windowId]) #

Deprecated. Please use query({'windowId': windowId}). Gets details about all tabs in the specified window.

windowId Defaults to the current window.

Future<List<Tab>> getAllInWindow([int windowId]) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<List<Tab>>.oneArg((e) => listify(e, _createTab));
 _tabs.callMethod('getAllInWindow', [windowId, completer.callback]);
 return completer.future;
}

Future<Tab> getCurrent() #

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).

Future<Tab> getCurrent() {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<Tab>.oneArg(_createTab);
 _tabs.callMethod('getCurrent', [completer.callback]);
 return completer.future;
}

Future<Tab> getSelected([int windowId]) #

Deprecated. Please use query({'active': true}). Gets the tab that is selected in the specified window.

windowId Defaults to the current window.

Future<Tab> getSelected([int windowId]) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<Tab>.oneArg(_createTab);
 _tabs.callMethod('getSelected', [windowId, completer.callback]);
 return completer.future;
}

Future<Window> highlight(TabsHighlightParams highlightInfo) #

Highlights the given tabs.

Returns: Contains details about the window whose tabs were highlighted.

Future<Window> highlight(TabsHighlightParams highlightInfo) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<Window>.oneArg(_createWindow);
 _tabs.callMethod('highlight', [jsify(highlightInfo), completer.callback]);
 return completer.future;
}

Future insertCSS(InjectDetails details, [int tabId]) #

Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.

tabId The ID of the tab in which to insert the CSS; defaults to the active tab of the current window.

details Details of the CSS text to insert.

Future insertCSS(InjectDetails details, [int tabId]) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter.noArgs();
 _tabs.callMethod('insertCSS', [tabId, jsify(details), completer.callback]);
 return completer.future;
}

Future<dynamic> move(tabIds, TabsMoveParams moveProperties) #

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.

tabIds The tab or list of tabs to move.

Returns: Details about the moved tabs.

Future<dynamic> move(dynamic tabIds, TabsMoveParams moveProperties) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<dynamic>.oneArg();
 _tabs.callMethod('move', [jsify(tabIds), jsify(moveProperties), completer.callback]);
 return completer.future;
}

Future<List<Tab>> query(TabsQueryParams queryInfo) #

Gets all tabs that have the specified properties, or all tabs if no properties are specified.

Future<List<Tab>> query(TabsQueryParams queryInfo) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<List<Tab>>.oneArg((e) => listify(e, _createTab));
 _tabs.callMethod('query', [jsify(queryInfo), completer.callback]);
 return completer.future;
}

Future reload([int tabId, TabsReloadParams reloadProperties]) #

Reload a tab.

tabId The ID of the tab to reload; defaults to the selected tab of the current window.

Future reload([int tabId, TabsReloadParams reloadProperties]) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter.noArgs();
 _tabs.callMethod('reload', [tabId, jsify(reloadProperties), completer.callback]);
 return completer.future;
}

Future remove(tabIds) #

Closes one or more tabs.

tabIds The tab or list of tabs to close.

Future remove(dynamic tabIds) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter.noArgs();
 _tabs.callMethod('remove', [jsify(tabIds), completer.callback]);
 return completer.future;
}

Future<dynamic> sendMessage(int tabId, message) #

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 runtime.onMessage event is fired in each content script running in the specified tab for the current extension.

Returns: 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 runtime.lastError will be set to the error message.

Future<dynamic> sendMessage(int tabId, dynamic message) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<dynamic>.oneArg();
 _tabs.callMethod('sendMessage', [tabId, jsify(message), completer.callback]);
 return completer.future;
}

Future<dynamic> sendRequest(int tabId, request) #

Deprecated: Please use sendMessage.

Returns: 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 runtime.lastError will be set to the error message.

Future<dynamic> sendRequest(int tabId, dynamic request) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<dynamic>.oneArg();
 _tabs.callMethod('sendRequest', [tabId, jsify(request), completer.callback]);
 return completer.future;
}

Future<Tab> update(TabsUpdateParams updateProperties, [int tabId]) #

Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.

tabId Defaults to the selected tab of the current window.

Returns: Details about the updated tab. The tabs.Tab object doesn't contain url, title and favIconUrl if the "tabs" permission has not been requested.

Future<Tab> update(TabsUpdateParams updateProperties, [int tabId]) {
 if (_tabs == null) _throwNotAvailable();

 var completer = new ChromeCompleter<Tab>.oneArg(_createTab);
 _tabs.callMethod('update', [tabId, jsify(updateProperties), completer.callback]);
 return completer.future;
}