diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-06 18:56:51 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-06 18:56:51 +0000 |
commit | 3bc65248b6943fe648c996175d4f13de2f32d68b (patch) | |
tree | de2b35a5c8f6766212346d4b3ebda78fed7f7f67 /chrome/test | |
parent | e90ed8ae06d460f74fc32207ddaca7e1d1de787d (diff) | |
download | chromium_src-3bc65248b6943fe648c996175d4f13de2f32d68b.zip chromium_src-3bc65248b6943fe648c996175d4f13de2f32d68b.tar.gz chromium_src-3bc65248b6943fe648c996175d4f13de2f32d68b.tar.bz2 |
Implement browserAction.setIcon(ImageData) for extensions.
BUG=23269
TEST=load the test_browser_action sample extension, and click the browser action. Watch it dynamically update.
Review URL: http://codereview.chromium.org/242150
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28136 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/data/extensions/samples/test_browser_action/background.html | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/chrome/test/data/extensions/samples/test_browser_action/background.html b/chrome/test/data/extensions/samples/test_browser_action/background.html index bbe9b24..eff9c26c 100644 --- a/chrome/test/data/extensions/samples/test_browser_action/background.html +++ b/chrome/test/data/extensions/samples/test_browser_action/background.html @@ -2,12 +2,34 @@ <head> <script> // Called when the user clicks on the browser action. - var i = 1; + var i = 0; chrome.browserAction.onClicked.addListener(function(windowId) { - chrome.browserAction.setName("Ouch" + i); i++; - chrome.browserAction.setIcon(i % 2); + i++; + chrome.browserAction.setName("Ouch" + i); + if (i < 4) { + chrome.browserAction.setIcon(i % 2); + } else { + var image = draw(i * 2, i * 4); + chrome.browserAction.setIcon(image); + } }); + + function draw(starty, startx) { + var canvas = document.getElementById('canvas'); + var context = canvas.getContext('2d'); + context.clearRect(0, 0, canvas.width, canvas.height); + context.fillStyle = "rgba(0,200,0,255)"; + context.fillRect(startx % 20, starty % 20, 8, 8); + context.fillStyle = "rgba(0,0,200,255)"; + context.fillRect((startx + 5) % 20, (starty + 5) % 20, 8, 8); + context.fillStyle = "rgba(200,0,0,255)"; + context.fillRect((startx + 10) % 20, (starty + 10) % 20, 8, 8); + return context.getImageData(0, 0, 20, 20); + } </script> </head> +<body> +<canvas id="canvas" width="20" height="20"></canvas> +</body> </html> |