Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3981)

Unified Diff: chrome/test/data/extensions/samples/test_browser_action/background.html

Issue 242150: Implement browserAction.setIcon(ImageData) for extensions. (Closed)
Patch Set: common function Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/resources/extension_process_bindings.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/samples/test_browser_action/background.html
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 bbe9b24116f8397017c617eea163bd807f3eb64f..eff9c26c15a0fbd3bf2c4dde7d6fd10f63e33c46 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>
« no previous file with comments | « chrome/renderer/resources/extension_process_bindings.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698