chrome.extension API reference

Properties

lastError

chrome.extension.lastError
lastError
( optional Type array of object )
Set for the lifetime of a callback if an ansychronous extension api has resulted in an error. If no error has occured lastError will be undefined.
message
( Type array of string )
Description of the error that has taken place.

Methods

connect

Port chrome.extension.connect(, string name)

Attempts to connect to other listeners within the extension (listeners may be toolstrips or the extension's background page). This is primarily useful for content scripts connecting to their extension processes. Extensions may connect to content scripts embedded in tabs via chrome.tabs.connectToTab.

Parameters

name
( optional Type array of string )
Will be passed into onConnect for extension processes that are listening for the connection event.

Returns

name
( Port array of string )
Port through which messages can be sent and received with the extension.

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(Type param1, Type param2) {...});

getViews

array of object chrome.extension.getViews(, )

Returns an array of the global JavaScript objects for each of the views running inside the current extension. This includes toolstrips, background pages, and tabs.

Parameters

paramName
( optional Type array of paramType )
Undocumented.
Description of this parameter from the json schema.

Returns

name
( Type array of Type array of object string )
Array of global objects

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(Type param1, Type param2) {...});

getBackgroundPage

object chrome.extension.getBackgroundPage(, )

Returns the global JavaScript object for the background page running inside the current extension. Returns null if the extension has no backround page.

Parameters

paramName
( optional Type array of paramType )
Undocumented.
Description of this parameter from the json schema.

Returns

name
( Type array of object )
Undocumented.
Will be passed into onConnect for extension processes that are listening for the connection event.

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(Type param1, Type param2) {...});

getToolstrips

array of object chrome.extension.getToolstrips(, integer windowId)

Returns an array of the global JavaScript objects for each of the toolstrip views running inside the current extension. If windowId is specified, returns only the toolstrips attached to the specified window.

Parameters

windowId
( optional Type array of integer )
Undocumented.
Description of this parameter from the json schema.

Returns

name
( Type array of Type array of object string )
Array of global objects

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(Type param1, Type param2) {...});

getTabContentses

array of object chrome.extension.getTabContentses(, integer windowId)

Returns an array of the global JavaScript objects for each of the tab contents views running inside the current extension. If windowId is specified, returns only the tab contentses attached to the specified window.

Parameters

windowId
( optional Type array of integer )
Undocumented.
Description of this parameter from the json schema.

Returns

name
( Type array of Type array of object string )
Array of global objects

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(Type param1, Type param2) {...});

Events

onConnect

chrome.extension.onConnect.addListener(function(Port port) {...});

Fired when a connection is made from either an extension process or a content script.

Parameters

port
( Port array of string )
Undocumented.
Will be passed into onConnect for extension processes that are listening for the connection event.

Types

Port

name
( Type array of object )
An object which allows two way communication with other pages.
name
( Type array of string )
Undocumented.
Will be passed into onConnect for extension processes that are listening for the connection event.
onDisconnect
( Type array of object )
Undocumented.
Will be passed into onConnect for extension processes that are listening for the connection event.
onMessage
( Type array of object )
Undocumented.
Will be passed into onConnect for extension processes that are listening for the connection event.
postMessage
( Type array of function )
Undocumented.
Will be passed into onConnect for extension processes that are listening for the connection event.