OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 let activeNotification = null; | 27 let activeNotification = null; |
28 let activeButtons = null; | 28 let activeButtons = null; |
29 let defaultDisplayMethods = ["popup"]; | 29 let defaultDisplayMethods = ["popup"]; |
30 let displayMethods = Object.create(null); | 30 let displayMethods = Object.create(null); |
31 displayMethods.critical = ["icon", "notification", "popup"]; | 31 displayMethods.critical = ["icon", "notification", "popup"]; |
32 displayMethods.question = ["notification"]; | 32 displayMethods.question = ["notification"]; |
33 displayMethods.normal = ["notification"]; | 33 displayMethods.normal = ["notification"]; |
34 displayMethods.information = ["icon", "popup"]; | 34 displayMethods.information = ["icon", "popup"]; |
35 | 35 |
36 // Chrome on Linux does not fully support chrome.notifications until version 35 | 36 let canUseChromeNotifications = typeof chrome != "undefined" && "notifications"
in chrome; |
37 // https://code.google.com/p/chromium/issues/detail?id=291485 | |
38 let canUseChromeNotifications = (function() | |
39 { | |
40 let info = require("info"); | |
41 if (info.platform == "chromium" && "notifications" in chrome) | |
42 { | |
43 if (navigator.platform.indexOf("Linux") == -1) | |
44 return true; | |
45 if (Services.vc.compare(info.applicationVersion, "35") >= 0) | |
46 return true; | |
47 } | |
48 return false; | |
49 })(); | |
50 | 37 |
51 function prepareNotificationIconAndPopup() | 38 function prepareNotificationIconAndPopup() |
52 { | 39 { |
53 let animateIcon = shouldDisplay("icon", activeNotification.type); | 40 let animateIcon = shouldDisplay("icon", activeNotification.type); |
54 activeNotification.onClicked = function() | 41 activeNotification.onClicked = function() |
55 { | 42 { |
56 if (animateIcon) | 43 if (animateIcon) |
57 stopIconAnimation(); | 44 stopIconAnimation(); |
58 notificationClosed(); | 45 notificationClosed(); |
59 }; | 46 }; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 let methods = displayMethods[notificationType] || defaultDisplayMethods; | 262 let methods = displayMethods[notificationType] || defaultDisplayMethods; |
276 return methods.indexOf(method) > -1; | 263 return methods.indexOf(method) > -1; |
277 }; | 264 }; |
278 | 265 |
279 ext.pages.onLoading.addListener(page => | 266 ext.pages.onLoading.addListener(page => |
280 { | 267 { |
281 NotificationStorage.showNext(stringifyURL(page.url)); | 268 NotificationStorage.showNext(stringifyURL(page.url)); |
282 }); | 269 }); |
283 | 270 |
284 NotificationStorage.addShowListener(showNotification); | 271 NotificationStorage.addShowListener(showNotification); |
OLD | NEW |