| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 notification.show(); | 340 notification.show(); |
| 341 notification.addEventListener("close", prepareNotificationIconAndPopup, fa
lse); | 341 notification.addEventListener("close", prepareNotificationIconAndPopup, fa
lse); |
| 342 return; | 342 return; |
| 343 } | 343 } |
| 344 | 344 |
| 345 var texts = Notification.getLocalizedTexts(notification); | 345 var texts = Notification.getLocalizedTexts(notification); |
| 346 var title = texts.title || ""; | 346 var title = texts.title || ""; |
| 347 var message = texts.message ? texts.message.replace(/<\/?(a|strong)>/g, "")
: ""; | 347 var message = texts.message ? texts.message.replace(/<\/?(a|strong)>/g, "")
: ""; |
| 348 var iconUrl = ext.getURL("icons/abp-128.png"); | 348 var iconUrl = ext.getURL("icons/abp-128.png"); |
| 349 var hasLinks = activeNotification.links && activeNotification.links.length >
0; | 349 var hasLinks = activeNotification.links && activeNotification.links.length >
0; |
| 350 if ("browserNotifications" in ext) | 350 // Chrome on Linux does not fully support chrome.notifications yet |
| 351 // https://code.google.com/p/chromium/issues/detail?id=291485 |
| 352 if (require("info").platform == "chromium" && |
| 353 "notifications" in chrome && |
| 354 navigator.platform.indexOf("Linux") == -1) |
| 351 { | 355 { |
| 352 var opts = { | 356 var opts = { |
| 353 type: "basic", | 357 type: "basic", |
| 354 title: title, | 358 title: title, |
| 355 message: message, | 359 message: message, |
| 356 iconUrl: iconUrl, | 360 iconUrl: iconUrl, |
| 357 buttons: [] | 361 buttons: [] |
| 358 }; | 362 }; |
| 359 var regex = /<a>(.*?)<\/a>/g; | 363 var regex = /<a>(.*?)<\/a>/g; |
| 360 var plainMessage = texts.message || ""; | 364 var plainMessage = texts.message || ""; |
| 361 var match; | 365 var match; |
| 362 while (match = regex.exec(plainMessage)) | 366 while (match = regex.exec(plainMessage)) |
| 363 opts.buttons.push({title: match[1]}); | 367 opts.buttons.push({title: match[1]}); |
| 364 | 368 |
| 365 var notification = ext.browserNotifications; | 369 var notification = chrome.notifications; |
| 366 notification.create("", opts, function() {}); | 370 notification.create("", opts, function() {}); |
| 367 notification.onClosed.addListener(prepareNotificationIconAndPopup); | 371 notification.onClosed.addListener(prepareNotificationIconAndPopup); |
| 368 notification.onButtonClicked.addListener(notificationButtonClick); | 372 notification.onButtonClicked.addListener(notificationButtonClick); |
| 369 } | 373 } |
| 370 else if (hasWebkitNotifications && "createNotification" in webkitNotificatio
ns) | 374 else if (hasWebkitNotifications && "createNotification" in webkitNotificatio
ns) |
| 371 { | 375 { |
| 372 if (hasLinks) | 376 if (hasLinks) |
| 373 message += " " + ext.i18n.getMessage("notification_without_buttons"); | 377 message += " " + ext.i18n.getMessage("notification_without_buttons"); |
| 374 | 378 |
| 375 var notification = webkitNotifications.createNotification(iconUrl, title,
message); | 379 var notification = webkitNotifications.createNotification(iconUrl, title,
message); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 tab.sendMessage({type: "clickhide-deactivate"}); | 496 tab.sendMessage({type: "clickhide-deactivate"}); |
| 493 refreshIconAndContextMenu(tab); | 497 refreshIconAndContextMenu(tab); |
| 494 }); | 498 }); |
| 495 | 499 |
| 496 setTimeout(function() | 500 setTimeout(function() |
| 497 { | 501 { |
| 498 var notificationToShow = Notification.getNextToShow(); | 502 var notificationToShow = Notification.getNextToShow(); |
| 499 if (notificationToShow) | 503 if (notificationToShow) |
| 500 showNotification(notificationToShow); | 504 showNotification(notificationToShow); |
| 501 }, 3 * 60 * 1000); | 505 }, 3 * 60 * 1000); |
| OLD | NEW |