The problem comes when browser action clicks need different actions by
tab, too. I think this is a likely use case, given that you can
already set per-tab state. For example, you may grey-out the button
for some tabs; in those tabs, clicking it may need to do something
different than when the button is not greyed out.
Since Chrome is already keeping per-tab state for the browser action,
could we modify the API to either attach some state per tab
(chrome.browserAction.setData({data: {foo: bar}}, tabId: tabId})), or
alternatively to at least read the state of the browser action for a
tab? That is, have chrome.browserAction.{getBadgeText,getIcon,getTitle}
(tabId). Even just having those methods would avoid having to keep tab
state separately in the background page.
An alternative that may be more general is to add an API to
chrome.tabs for setting arbitrary tab data that lives only until a tab
changes URL or is removed. Why not just do this yourself in the
background page? It's bug-prone (you have to keep track of tabRemoved
events; tabUpdated gets called twice (loading and complete), for
example), and seems general enough to be added to the API.
Thoughts?
Thanks,
matias
1) Page actions are supposed to be used for actions that occur on a
tab-by-tab basis. Browser actions are supposed to be used for more
general things that affect the entire browser.
2) Assuming you're right that browser action state is saved per tab,
this sounds reasonable to me. I think something like this would
suffice:
chrome.browserAction.getInfo(tab, function (object) {});
"tab" is a tab, or defaults to the current-selected tab. "object" is
details about the browser action, like icon, text, etc.
The proposal to store state in the tab object itself also sounds okay.
That could be a function call, or an object attached directly to the
tab, like this:
tab.data.isDisabled = true;
--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.