Here's how I do it:
first we have this in the html:
<img id="browser-action-image"
src="browser-action-image.png" />
<canvas id="browser-action-canvas" width="19" height="19" />
We then have(using jQuery):
var canvas = $("#browser-action-canvas").get(0);
//TODO: check if canvas is ready (!= null)
if (!canvas) {
//try again later
return;
}
var canvasContext = canvas.getContext("2d");
var width = canvas.width;
var height = canvas.height;
var imageElement = $("#browser-action-image").get(0);
//TODO: check imageElement is not null
if (imageElement) {
canvasContext.save();
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
canvasContext.drawImage(imageElement, 0, 0);
canvasContext.restore();
chrome.browserAction.setIcon({
imageData: canvasContext.getImageData(
0, 0, canvas.width, canvas.height) });
}
This is working for us. We have this JS code in an updateBrowserIcon method.
If canvas is not ready, do something setTimeout(500, updateBrowserIcon) and
return, so it keeps trying.
Hope this helps.
On Wed, Nov 11, 2009 at 9:45 AM, pdknsk <[email protected]> wrote:
> Or as an alternative I'd just like iconIndex back :)
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Chromium-extensions" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<chromium-extensions%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/chromium-extensions?hl=.
>
>
>
--
Marcos Aruj Alvarez
Ingeniero de Software
-------------------------------
[email protected]
-----
--
You received this message because you are subscribed to the Google Groups
"Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/chromium-extensions?hl=.