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

Browser actions are buttons that are displayed in the main Chrome toolbar to the right of the omnibox.

Icons

Browser action icons can be up to 19px square. Larger icons will be resized to fit, but for best results, using a 19px icon is recommended.

Icons can be set two ways: using a static image or using the HTML5 canvas element. Using static images is easier for simple applications, but you can do more dynamic UIs using the canvas element.

Static images can be in any format WebKit can display. These include: png, bmp, ico, jpg, gif.

Badges

Browser actions can optionally display a badge, which is a bit of text that is layered over the icon. Badges make it easy to update the browser action to display a small amount of information about the state of the extension.

The badge APIs allow any length of text, but limiting badges to a max of four characters is recommended.

Popups

Popups allow browser actions to show additional UI when the user activates them. Popups contents are implemented using HTML and the popup is automatically sized to the content size.

Style Guide

For the best visual impact, we recommend observing the following guidelines:

  • Do use browser actions for features that make sense on most pages.
  • Don't use browser actions for features that only make sense for a few pages. Use page actions instead.
  • Do use big, colorful icons that fully utilize the 19px square space. Browser action icons should seem a little bigger and heavier than page action icons.
  • Don't attempt to mimic Chrome's monochrome "wrench" and "page" icons. This won't work well with themes, and anyway, extensions should stand out a little.
  • Do use alpha transparency to add soft edges to your icon. Remember: many users theme Chrome, so your icon should look nice on a variety of background colors.
  • Don't constantly animate your icon. That's just annoying.

Manifest

Developers declare their browser action using the following syntax:

"browser_action": {
  "default_title": "Google Mail",  // Optional. Shown in tooltip.
  "default_icon": "images/icon19.png",  // Optional.
  "popup": "popup.html"  // Optional
}

Note: Even if you don't include any of the values, you must include an empty browser_action entry in your manifest so that the system knows to reserve space for your browser action in the toolbar.

API reference: chrome.browserAction

Methods

setBadgeBackgroundColor

void chrome.browserAction.setBadgeBackgroundColor(, object details)

Sets the background color for the badge.

Parameters

details
( Type array of object )
Undocumented.
Description of this parameter from the json schema.
color
( Type array of Type array of integer paramType )
An array of four integers in the range [0,255] that make up the ARGB color for the bakground of the badge.

Returns

Callback function

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

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

setBadgeText

void chrome.browserAction.setBadgeText(, object details)

Sets the badge text for the browser action. This is printed on top of the icon.

Parameters

details
( Type array of object )
Undocumented.
Description of this parameter from the json schema.
text
( Type array of string )
Any number of characters can be passed, but only about four can fit in the space.

Returns

Callback function

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

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

setIcon

void chrome.browserAction.setIcon(, object details)

Sets the icon for the browser action. The icon can be specified either as the index of one of the icons that was pre-specified in the manifest, or as the pixel data from a Canvas element. Either the path or the imageData property must be specified.

Parameters

details
( Type array of object )
Undocumented.
Description of this parameter from the json schema.
imageData
( optional Type array of any )
Pixel data for an image. Must be an ImageData object (eg from a canvas element).
iconIndex
( optional Type array of integer )
Deprecated. The zero-based index into the |icons| vector specified in the manifest.
path
( optional Type array of string )
Relative path to an image in the extension to show in the browser action.

Returns

Callback function

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

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

setTitle

void chrome.browserAction.setTitle(, object details)

Sets the title of the browser action. Shows up in the tooltip if the browser action is visible, and in the menu item.

Parameters

details
( Type array of object )
Undocumented.
Description of this parameter from the json schema.
title
( Type array of string )
The string the browser action should display when moused over.

Returns

Callback function

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

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

Events

onClicked

chrome.browserAction.onClicked.addListener(function(Tab tab) {...});

Fired when a page action button is clicked.

Parameters

tab
( Tab array of paramType )
Undocumented.
Description of this parameter from the json schema.