| 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-present eyeo GmbH |    3  * Copyright (C) 2006-present 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  189     let texts = NotificationStorage.getLocalizedTexts(notification); |  189     let texts = NotificationStorage.getLocalizedTexts(notification); | 
|  190     let title = texts.title || ""; |  190     let title = texts.title || ""; | 
|  191     let message = (texts.message || "").replace(/<\/?(a|strong)>/g, ""); |  191     let message = (texts.message || "").replace(/<\/?(a|strong)>/g, ""); | 
|  192     let iconUrl = browser.extension.getURL("icons/detailed/abp-128.png"); |  192     let iconUrl = browser.extension.getURL("icons/detailed/abp-128.png"); | 
|  193     let linkCount = (activeNotification.links || []).length; |  193     let linkCount = (activeNotification.links || []).length; | 
|  194  |  194  | 
|  195     if ("notifications" in browser) |  195     if ("notifications" in browser) | 
|  196     { |  196     { | 
|  197       activeButtons = getNotificationButtons(activeNotification.type, |  197       activeButtons = getNotificationButtons(activeNotification.type, | 
|  198                                              texts.message); |  198                                              texts.message); | 
|  199       browser.notifications.create("", { |  199       let notificationOptions = { | 
|  200         type: "basic", |  200         type: "basic", | 
|  201         title, |  201         title, | 
|  202         iconUrl, |  202         iconUrl, | 
|  203         message, |  203         message, | 
|  204         buttons: activeButtons.map(button => ({title: button.title})), |  204         buttons: activeButtons.map(button => ({title: button.title})), | 
|  205         // We use the highest priority to prevent the notification |  205         // We use the highest priority to prevent the notification | 
|  206         // from closing automatically. |  206         // from closing automatically. | 
|  207         priority: 2 |  207         priority: 2 | 
 |  208       }; | 
 |  209       browser.notifications.create("", notificationOptions, () => | 
 |  210       { | 
 |  211         // Opera does not support the addtition of buttons to notifications. | 
 |  212         // Question type notfications always include buttons. | 
 |  213         if (browser.runtime.lastError && activeNotification.type != "question") | 
 |  214         { | 
 |  215           delete notificationOptions.buttons; | 
 |  216           browser.notifications.create("", notificationOptions); | 
 |  217         } | 
|  208       }); |  218       }); | 
|  209     } |  219     } | 
|  210     else if ("Notification" in window && activeNotification.type != "question") |  220     else if ("Notification" in window && activeNotification.type != "question") | 
|  211     { |  221     { | 
|  212       if (linkCount > 0) |  222       if (linkCount > 0) | 
|  213       { |  223       { | 
|  214         message += " " + browser.i18n.getMessage( |  224         message += " " + browser.i18n.getMessage( | 
|  215           "notification_without_buttons" |  225           "notification_without_buttons" | 
|  216         ); |  226         ); | 
|  217       } |  227       } | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  283   let methods = displayMethods[notificationType] || defaultDisplayMethods; |  293   let methods = displayMethods[notificationType] || defaultDisplayMethods; | 
|  284   return methods.includes(method); |  294   return methods.includes(method); | 
|  285 }; |  295 }; | 
|  286  |  296  | 
|  287 ext.pages.onLoading.addListener(page => |  297 ext.pages.onLoading.addListener(page => | 
|  288 { |  298 { | 
|  289   NotificationStorage.showNext(stringifyURL(page.url)); |  299   NotificationStorage.showNext(stringifyURL(page.url)); | 
|  290 }); |  300 }); | 
|  291  |  301  | 
|  292 NotificationStorage.addShowListener(showNotification); |  302 NotificationStorage.addShowListener(showNotification); | 
| OLD | NEW |