The Chromium Projects

Except as otherwise noted, the content of this page is licensed under a Creative Commons Attribution 2.5 license, and examples are licensed under the BSD License.

The Chromium OS designs and code are preliminary. Expect them to evolve.
For Developers‎ > ‎Design Documents‎ > ‎Extensions‎ > ‎

Tabs API


This page is obsolete. Please see the new version at:

http://code.google.com/chrome/extensions/tabs.html

Overview

The tabs API allows you to manipulate the tabs within browser windows

Status

Partially implemented.

Details

Note: Many tab APIs take an optional windowId parameter. If windowId is unspecified, it defaults to the window the API is called from, or to the highest window if the API is called from a background page.

chrome.tabs.

    struct Tab {
      int id
      int windowId
      int index
      bool selected
      string url
      string title
      string favIconUrl
    }

    void get(int id, [void callback(Tab)])
    void getSelected([int windowId], void callback(Tab))
    void getAllInWindow([int windowId], void callback(Tab[]))

    void create([{[string url], [int windowId], [int index], [bool selected]}],
                [void callback(Tab)])
    void update(int id, {[string url], [bool selected]}, [void callback()])
    void move(int id, {[int index], [int windowId]})
    void remove(int id)

    // Will *NOT* be followed by tab-attached - it is implied.
    // *MAY* be followed by tab-selection-changed.
    event onCreated(Tab)

    event onUpdated(int tabId, Object changedProps)

    // Tabs can only "move" within a window.
    event onTabMoved(int tabId, {int windowId, int fromIndex, int toIndex})

    // Sends (tabId, {windowId}).
    event onSelectionChanged(int tabId, {int windowId})

    // *MAY* be followed by tab-selection-changed.
    event onAttached(int tabId, {int newWindowId, int newPosition})

    // *WILL* be followed by tab-selection-changed.
    event onDetached(int tabId, {int oldWindowId, int oldPosition})

    // *WILL* be followed by tab-selection-changed.
    // Will *NOT* be followed or preceded by tab-detached.
    event onRemoved(int tabId)