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: Iterate over size in inner loop Created Jan. 26, 2016, 5:09 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..c4b704e4da7528781e301a26008361f742a27ffd 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,40 +193,32 @@ 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() {});
- });
+ }, function() {});
Sebastian Noack 2016/01/26 17:23:14 While changing this code, note that the callback i
kzar 2016/01/26 17:35:10 Done.
}
else if ("Notification" in window && activeNotification.type != "question")
{
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