Index: background.js |
=================================================================== |
--- a/background.js |
+++ b/background.js |
@@ -18,7 +18,6 @@ |
with(require("filterClasses")) |
{ |
this.Filter = Filter; |
- this.ActiveFilter = ActiveFilter; |
this.RegExpFilter = RegExpFilter; |
this.BlockingFilter = BlockingFilter; |
this.WhitelistFilter = WhitelistFilter; |
@@ -351,6 +350,29 @@ |
} |
} |
+function notificationClosed() |
+{ |
+ activeNotification = null; |
+} |
+ |
+// Chrome on Linux does not fully support chrome.notifications until version 35 |
Felix Dahlke
2014/03/28 13:10:41
Since this is executed immediately, I would have e
Thomas Greiner
2014/03/28 15:57:08
Done.
|
+// https://code.google.com/p/chromium/issues/detail?id=291485 |
+var canUseChromeNotifications = (require("info").platform == "chromium" && "notifications" in chrome && (navigator.platform.indexOf("Linux") == -1 || parseInt(require("info").applicationVersion) > 34)); |
Felix Dahlke
2014/03/28 13:10:41
The outer parentheses are redundant here. And I'd
Thomas Greiner
2014/03/28 15:57:08
Done.
|
+if (canUseChromeNotifications) |
+{ |
+ chrome.notifications.onButtonClicked.addListener(notificationButtonClick); |
+ chrome.notifications.onClosed.addListener(notificationClosed); |
+ // Chrome hides notifications in notification center when clicked so we need to close them |
+ chrome.notifications.onClicked.addListener(function(id, callback) |
+ { |
+ chrome.notifications.clear(id, function(wasCleared) |
+ { |
+ if (wasCleared) |
+ notificationClosed(); |
+ }); |
+ }); |
+} |
+ |
function showNotification(notification) |
{ |
if (activeNotification && activeNotification.id === notification.id) |
@@ -374,9 +396,7 @@ |
var iconUrl = ext.getURL("icons/abp-128.png"); |
var hasLinks = activeNotification.links && activeNotification.links.length > 0; |
- // Chrome on Linux does not fully support chrome.notifications yet |
- // https://code.google.com/p/chromium/issues/detail?id=291485 |
- if (require("info").platform == "chromium" && "notifications" in chrome && navigator.platform.indexOf("Linux") == -1) |
+ if (canUseChromeNotifications) |
{ |
var opts = { |
type: "basic", |
@@ -401,7 +421,6 @@ |
} |
chrome.notifications.create("", opts, function() {}); |
- chrome.notifications.onButtonClicked.addListener(notificationButtonClick); |
} |
else if (hasWebkitNotifications && "createNotification" in webkitNotifications && activeNotification.type !== "question") |
{ |
@@ -411,6 +430,7 @@ |
var notification = webkitNotifications.createNotification(iconUrl, title, message); |
notification.show(); |
notification.addEventListener("click", openNotificationLinks, false); |
+ notification.addEventListener("close", notificationClosed, false); |
} |
else |
{ |