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 <pdk...@googlemail.com> 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 chromium-extensi...@googlegroups.com.
> To unsubscribe from this group, send email to
> chromium-extensions+unsubscr...@googlegroups.com<chromium-extensions%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/chromium-extensions?hl=.
>
>
>


-- 
Marcos Aruj Alvarez
Ingeniero de Software
-------------------------------
marcos.a...@gmail.com
-----

--

You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to chromium-extensi...@googlegroups.com.
To unsubscribe from this group, send email to 
chromium-extensions+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=.


Reply via email to