How could this API be abused?
How would you implement your desired features if this API didn't exist?
By injecting a frame into the page’s DOM and manipulating its contents, but it might cause undesirable side effects for pages which expect certain DOM structure.
Are you willing and able to develop and maintain this API?
Yes.
Will the API work on all platforms?
Yes, it supposed to work on all platforms Chrome supports.
Draft API spec
This API is available as an experiment, so it is accessible for the extension’s background page as chrome.experimental.sidebar.*.
Sidebar content is associated with the particular extension so no extension can access a sidebar created by another extension. Sidebar content is identified by tabId, tabId identifies a tab the sidebar should be associated with.
UI design is TBD.
Methods
show
chrome.experimental.sidebar.show
Shows sidebar mini tab (in 'shown' state) for the specified tab. Has no effect if already expanded, otherwise changes status to 'shown'.
Parameters
details ( optional object )
tabId ( optional integer )
The tab id for the tab to show the sidebar for. Uses the current selected tab when omitted.
expand
chrome.experimental.sidebar.expand
Expands sidebar and switches to the specified content (if it was displaying another extension's sidebar content) for the specified tab. Extension is allowed to expand sidebar only in response to an explicit user gesture.
Parameters
details ( optional object )
tabId ( optional integer )
The tab id for the tab to expand the sidebar for. Uses the current selected tab when omitted.
collapse
chrome.experimental.sidebar.collapse
Collapses sidebar for the specified tab. Has no effect if sidebar is not in its 'active' state (see getState).
Parameters
details ( optional object )
tabId ( optional integer )
The tab id for the tab to collapse the sidebar for. Uses the current selected tab when omitted.
hide
chrome.experimental.sidebar.hide
Hides sidebar's mini tab for the specified tab and collapses sidebar if it was in 'active' state (see getState). Has no effect if the sidebar is already hidden.
Parameters
details ( optional object )
tabId ( optional integer )
The tab id for the tab to hide the sidebar for. Uses the current selected tab when omitted.
setIcon
chrome.experimental.sidebar.setIcon
Sets sidebar's mini tab icon for the specified tab. Extension icon is used by default.
Parameters
details ( object )
tabId ( optional integer )
The tab id for the tab to set attributes for. Uses the current selected tab when omitted.
path ( optional string )
Relative path to an image in the extension to show on the sidebar's mini tab. Only one of the imagePath/imageData parameters all owed. The extension's icon is used by default. The preferred size of the icon is 16x16 pixels, any other size will be scaled to 16x16.
imageData ( optional ImageData )
Pixel data for an image to show on the sidebar's mini tab. Must be an ImageData object (for example, from a <code>canvas</code> element). Only one of the imagePath/imageData parameters all owed. The extension's icon is used by default. The preferred size of the icon is 16x16 pixels, any other size will be scaled to 16x16.
setTitle
chrome.experimental.sidebar.setTitle
Sets sidebar's mini tab title for the specified tab. Extension name is used by default.
Parameters
details ( object )
tabId ( optional integer )
The tab id for the tab to set attributes for. Uses the current selected tab when omitted.
title ( string )
The sidebar's title. It is displayed in a tooltip over the sidebar's mini tab.
setBadgeText
chrome.experimental.sidebar.setBadgeText
Sets sidebar's mini tab badge text for the specified tab.
Parameters
details ( object )
tabId ( optional integer )
The tab id for the tab to set attributes for. Uses the current selected tab when omitted.
text ( string )
The sidebar's badge text. The badge is displayed on top of the sidebar's icon on the mini tab.
navigate
chrome.experimental.sidebar.navigate
Navigates sidebar for the specified tab to the specified URL. URL can be either a relative path or a full URL.
Parameters
details ( object )
tabId ( optional integer )
The tab id for the tab to navigate sidebar for. Uses the current selected tab when omitted.
url ( string )
URL to navigate sidebar content to.
getState
chrome.experimental.sidebar.getState
Returns current sidebar state for the specified tab.
Parameters
details ( optional object )
tabId ( optional integer )
The tab id for the tab to check sidebar visibility for. Uses the current selected tab when omitted.
callback ( function )
Callback function
The callback parameter should specify a function that looks like this:
function(string result) {...});
result ( enumerated string ["hidden", "shown", "active"] )
'hidden' indicates sidebar is not defined for the specified tab (show was never called or hide() was called). Nothing is displayed for this sidebar.
'shown' means sidebar is defined for the specified tab; mini tab is displayed for this sidebar. Sidebar UI is either collapsed or displaying a content of some other extension's sidebar.
'active' indicates that sidebar is defined for the specified tab; sidebar UI is expanded and displaying this sidebar's content.
Events
onStateChanged
chrome.experimental.sidebar.onStateChanged.addListener(function(object details) {...});
Notifies about sidebar state changes.
Parameters
details ( object )
tabId ( integer )
The tab id for the tab to sidebar state changed for.
state ( enumerated string ["hidden", "shown", "active"] )
See getState() for more details.
Example: