| Index: background.js |
| =================================================================== |
| --- a/background.js |
| +++ b/background.js |
| @@ -351,6 +351,22 @@ |
| } |
| } |
| +function imgToBase64(url, callback) |
| +{ |
| + var canvas = document.createElement("CANVAS"), |
|
Wladimir Palant
2014/03/28 14:18:29
Nit: document.createElement("canvas") please (lowe
saroyanm
2014/03/28 15:16:02
Done.
|
| + ctx = canvas.getContext("2d"), |
| + img = new Image; |
| + img.src = url; |
| + img.onload = function() |
| + { |
| + canvas.height = img.height; |
| + canvas.width = img.width; |
| + ctx.drawImage(img, 0, 0); |
| + callback(canvas.toDataURL("image/png")); |
| + canvas = null; |
| + }; |
| +} |
| + |
| function showNotification(notification) |
| { |
| if (activeNotification && activeNotification.id === notification.id) |
| @@ -382,7 +398,6 @@ |
| type: "basic", |
| title: title, |
| message: message, |
| - iconUrl: iconUrl, |
| buttons: [], |
| priority: 2 // We use the highest priority to prevent the notification from closing automatically |
| }; |
| @@ -400,17 +415,24 @@ |
| opts.buttons.push({title: match[1]}); |
| } |
| - chrome.notifications.create("", opts, function() {}); |
| - chrome.notifications.onButtonClicked.addListener(notificationButtonClick); |
| + imgToBase64(iconUrl, function(iconData) |
| + { |
| + opts["iconUrl"] = iconData; |
| + chrome.notifications.create("", opts, function() {}); |
| + chrome.notifications.onButtonClicked.addListener(notificationButtonClick); |
| + }); |
| } |
| else if (hasWebkitNotifications && "createNotification" in webkitNotifications && activeNotification.type !== "question") |
| { |
| if (hasLinks) |
| message += " " + ext.i18n.getMessage("notification_without_buttons"); |
| - var notification = webkitNotifications.createNotification(iconUrl, title, message); |
| - notification.show(); |
| - notification.addEventListener("click", openNotificationLinks, false); |
| + imgToBase64(iconUrl, function(iconData) |
| + { |
| + var notification = webkitNotifications.createNotification(iconData, title, message); |
| + notification.show(); |
| + notification.addEventListener("click", openNotificationLinks, false); |
| + }); |
| } |
| else |
| { |