Left: | ||
Right: |
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 ( https:/ /code.google.com/p/chromium/issues/detail?id=291485 ) |
351 if (require("info").platform == "chromium" && "notifications" in chrome && n avigator.platform.indexOf("Linux") == -1) | |
Sebastian Noack
2014/03/06 09:58:31
Nit: Those are two very long lines. We usually try
saroyanm
2014/03/06 10:11:15
Will keep in mind,thanks.
Done.
| |
351 { | 352 { |
352 var opts = { | 353 var opts = { |
353 type: "basic", | 354 type: "basic", |
354 title: title, | 355 title: title, |
355 message: message, | 356 message: message, |
356 iconUrl: iconUrl, | 357 iconUrl: iconUrl, |
357 buttons: [] | 358 buttons: [] |
358 }; | 359 }; |
359 var regex = /<a>(.*?)<\/a>/g; | 360 var regex = /<a>(.*?)<\/a>/g; |
360 var plainMessage = texts.message || ""; | 361 var plainMessage = texts.message || ""; |
361 var match; | 362 var match; |
362 while (match = regex.exec(plainMessage)) | 363 while (match = regex.exec(plainMessage)) |
363 opts.buttons.push({title: match[1]}); | 364 opts.buttons.push({title: match[1]}); |
364 | 365 |
365 var notification = ext.browserNotifications; | 366 var notification = chrome.notifications; |
366 notification.create("", opts, function() {}); | 367 notification.create("", opts, function() {}); |
367 notification.onClosed.addListener(prepareNotificationIconAndPopup); | 368 notification.onClosed.addListener(prepareNotificationIconAndPopup); |
368 notification.onButtonClicked.addListener(notificationButtonClick); | 369 notification.onButtonClicked.addListener(notificationButtonClick); |
369 } | 370 } |
370 else if (hasWebkitNotifications && "createNotification" in webkitNotificatio ns) | 371 else if (hasWebkitNotifications && "createNotification" in webkitNotificatio ns) |
371 { | 372 { |
372 if (hasLinks) | 373 if (hasLinks) |
373 message += " " + ext.i18n.getMessage("notification_without_buttons"); | 374 message += " " + ext.i18n.getMessage("notification_without_buttons"); |
374 | 375 |
375 var notification = webkitNotifications.createNotification(iconUrl, title, message); | 376 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"}); | 493 tab.sendMessage({type: "clickhide-deactivate"}); |
493 refreshIconAndContextMenu(tab); | 494 refreshIconAndContextMenu(tab); |
494 }); | 495 }); |
495 | 496 |
496 setTimeout(function() | 497 setTimeout(function() |
497 { | 498 { |
498 var notificationToShow = Notification.getNextToShow(); | 499 var notificationToShow = Notification.getNextToShow(); |
499 if (notificationToShow) | 500 if (notificationToShow) |
500 showNotification(notificationToShow); | 501 showNotification(notificationToShow); |
501 }, 3 * 60 * 1000); | 502 }, 3 * 60 * 1000); |
OLD | NEW |