Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/notificationHelper.js

Issue 29334223: Issue 3532 - Generate animation images at runtime (Closed)
Patch Set: Fix onActivated dispatch for Safari Created Jan. 26, 2016, 6:05 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/icon.js ('k') | metadata.chrome » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/notificationHelper.js
diff --git a/lib/notificationHelper.js b/lib/notificationHelper.js
index cfe93ae8611bf6a92e2f74f17f1f3de13b1d1756..d7bb5f924c247a34553da7322373254308ab7363 100644
--- a/lib/notificationHelper.js
+++ b/lib/notificationHelper.js
@@ -152,22 +152,6 @@ function notificationClosed()
activeNotification = null;
}
-function imgToBase64(url, callback)
-{
- let canvas = document.createElement("canvas"),
- 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 initChromeNotifications()
{
// Chrome hides notifications in notification center when clicked so we need to clear them
@@ -209,18 +193,13 @@ function showNotification(notification)
if (canUseChromeNotifications)
{
activeButtons = getNotificationButtons(activeNotification.type, texts.message);
- let opts = {
+ chrome.notifications.create("", {
type: "basic",
title: title,
+ iconUrl: iconUrl,
message: message,
buttons: activeButtons.map(button => ({title: button.title})),
priority: 2 // We use the highest priority to prevent the notification from closing automatically
- };
-
- imgToBase64(iconUrl, function(iconData)
- {
- opts.iconUrl = iconData;
- chrome.notifications.create("", opts, function() {});
});
}
else if ("Notification" in window && activeNotification.type != "question")
@@ -228,21 +207,18 @@ function showNotification(notification)
if (linkCount > 0)
message += " " + ext.i18n.getMessage("notification_without_buttons");
- imgToBase64(iconUrl, function(iconData)
- {
- let notification = new Notification(
- title,
- {
- lang: Utils.appLocale,
- dir: ext.i18n.getMessage("@@bidi_dir"),
- body: message,
- icon: iconData
- }
- );
+ let notification = new Notification(
+ title,
+ {
+ lang: Utils.appLocale,
+ dir: ext.i18n.getMessage("@@bidi_dir"),
+ body: message,
+ icon: iconUrl
+ }
+ );
- notification.addEventListener("click", openNotificationLinks);
- notification.addEventListener("close", notificationClosed);
- });
+ notification.addEventListener("click", openNotificationLinks);
+ notification.addEventListener("close", notificationClosed);
}
else
{
« no previous file with comments | « lib/icon.js ('k') | metadata.chrome » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld