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 const {initAntiAdblockNotification} = require("antiadblockInit"); | 26 const {initAntiAdblockNotification} = require("antiadblockInit"); |
27 const {Prefs} = require("prefs"); | 27 const {Prefs} = require("prefs"); |
28 | 28 |
29 let activeNotification = null; | 29 let activeNotification = null; |
30 let activeButtons = null; | 30 let activeButtons = null; |
31 let defaultDisplayMethods = ["popup"]; | 31 let defaultDisplayMethods = ["popup"]; |
32 let displayMethods = Object.create(null); | 32 let displayMethods = Object.create(null); |
33 displayMethods.critical = ["icon", "notification", "popup"]; | 33 displayMethods.critical = ["icon", "notification", "popup"]; |
34 displayMethods.question = ["notification"]; | 34 displayMethods.question = ["notification"]; |
35 displayMethods.normal = ["notification"]; | 35 displayMethods.normal = ["notification"]; |
| 36 displayMethods.relentless = ["notification"]; |
36 displayMethods.information = ["icon", "popup"]; | 37 displayMethods.information = ["icon", "popup"]; |
37 | 38 |
38 function prepareNotificationIconAndPopup() | 39 function prepareNotificationIconAndPopup() |
39 { | 40 { |
40 let animateIcon = shouldDisplay("icon", activeNotification.type); | 41 let animateIcon = shouldDisplay("icon", activeNotification.type); |
41 activeNotification.onClicked = () => | 42 activeNotification.onClicked = () => |
42 { | 43 { |
43 if (animateIcon) | 44 if (animateIcon) |
44 stopIconAnimation(); | 45 stopIconAnimation(); |
45 notificationClosed(); | 46 notificationClosed(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 let maxButtons = (notificationType == "critical") ? 2 : 1; | 80 let maxButtons = (notificationType == "critical") ? 2 : 1; |
80 if (buttons.length > maxButtons) | 81 if (buttons.length > maxButtons) |
81 { | 82 { |
82 buttons = [ | 83 buttons = [ |
83 { | 84 { |
84 type: "open-all", | 85 type: "open-all", |
85 title: ext.i18n.getMessage("notification_open_all") | 86 title: ext.i18n.getMessage("notification_open_all") |
86 } | 87 } |
87 ]; | 88 ]; |
88 } | 89 } |
89 if (notificationType != "critical") | 90 if (["critical", "relentless"].indexOf(notificationType) == -1) |
90 { | 91 { |
91 buttons.push({ | 92 buttons.push({ |
92 type: "configure", | 93 type: "configure", |
93 title: ext.i18n.getMessage("notification_configure") | 94 title: ext.i18n.getMessage("notification_configure") |
94 }); | 95 }); |
95 } | 96 } |
96 } | 97 } |
97 | 98 |
98 return buttons; | 99 return buttons; |
99 } | 100 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 message += "\n\n" + ext.i18n.getMessage("notification_with_buttons"); | 220 message += "\n\n" + ext.i18n.getMessage("notification_with_buttons"); |
220 | 221 |
221 let approved = confirm(message); | 222 let approved = confirm(message); |
222 if (activeNotification.type == "question") | 223 if (activeNotification.type == "question") |
223 notificationButtonClick(approved ? 0 : 1); | 224 notificationButtonClick(approved ? 0 : 1); |
224 else if (approved) | 225 else if (approved) |
225 openNotificationLinks(); | 226 openNotificationLinks(); |
226 } | 227 } |
227 } | 228 } |
228 prepareNotificationIconAndPopup(); | 229 prepareNotificationIconAndPopup(); |
| 230 |
| 231 if (notification.type !== "question") |
| 232 NotificationStorage.markAsShown(notification.id); |
229 }; | 233 }; |
230 | 234 |
231 /** | 235 /** |
232 * Initializes the notification system. | 236 * Initializes the notification system. |
233 */ | 237 */ |
234 exports.initNotifications = () => | 238 exports.initNotifications = () => |
235 { | 239 { |
236 if ("notifications" in chrome) | 240 if ("notifications" in chrome) |
237 initChromeNotifications(); | 241 initChromeNotifications(); |
238 initAntiAdblockNotification(); | 242 initAntiAdblockNotification(); |
(...skipping 20 matching lines...) Expand all Loading... |
259 let methods = displayMethods[notificationType] || defaultDisplayMethods; | 263 let methods = displayMethods[notificationType] || defaultDisplayMethods; |
260 return methods.indexOf(method) > -1; | 264 return methods.indexOf(method) > -1; |
261 }; | 265 }; |
262 | 266 |
263 ext.pages.onLoading.addListener(page => | 267 ext.pages.onLoading.addListener(page => |
264 { | 268 { |
265 NotificationStorage.showNext(stringifyURL(page.url)); | 269 NotificationStorage.showNext(stringifyURL(page.url)); |
266 }); | 270 }); |
267 | 271 |
268 NotificationStorage.addShowListener(showNotification); | 272 NotificationStorage.addShowListener(showNotification); |
OLD | NEW |