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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chrome/renderer/resources/extension_process_bindings.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script> 3 <script>
4 // Called when the user clicks on the browser action. 4 // Called when the user clicks on the browser action.
5 var i = 1; 5 var i = 0;
6 chrome.browserAction.onClicked.addListener(function(windowId) { 6 chrome.browserAction.onClicked.addListener(function(windowId) {
7 chrome.browserAction.setName("Ouch" + i); i++; 7 i++;
8 chrome.browserAction.setIcon(i % 2); 8 chrome.browserAction.setName("Ouch" + i);
9 if (i < 4) {
10 chrome.browserAction.setIcon(i % 2);
11 } else {
12 var image = draw(i * 2, i * 4);
13 chrome.browserAction.setIcon(image);
14 }
9 }); 15 });
16
17 function draw(starty, startx) {
18 var canvas = document.getElementById('canvas');
19 var context = canvas.getContext('2d');
20 context.clearRect(0, 0, canvas.width, canvas.height);
21 context.fillStyle = "rgba(0,200,0,255)";
22 context.fillRect(startx % 20, starty % 20, 8, 8);
23 context.fillStyle = "rgba(0,0,200,255)";
24 context.fillRect((startx + 5) % 20, (starty + 5) % 20, 8, 8);
25 context.fillStyle = "rgba(200,0,0,255)";
26 context.fillRect((startx + 10) % 20, (starty + 10) % 20, 8, 8);
27 return context.getImageData(0, 0, 20, 20);
28 }
10 </script> 29 </script>
11 </head> 30 </head>
31 <body>
32 <canvas id="canvas" width="20" height="20"></canvas>
33 </body>
12 </html> 34 </html>
13 35
OLDNEW
« 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