| 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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 28 matching lines...) Expand all Loading... |
| 39 case "subscription.added": | 39 case "subscription.added": |
| 40 case "subscription.removed": | 40 case "subscription.removed": |
| 41 case "subscription.disabled": | 41 case "subscription.disabled": |
| 42 case "subscription.updated": | 42 case "subscription.updated": |
| 43 case "load": | 43 case "load": |
| 44 ext.webRequest.handlerBehaviorChanged(); | 44 ext.webRequest.handlerBehaviorChanged(); |
| 45 break; | 45 break; |
| 46 } | 46 } |
| 47 }); | 47 }); |
| 48 | 48 |
| 49 function onBeforeRequestAsync(url, type, page, filter) |
| 50 { |
| 51 // We can't listen to onHeadersReceived in Safari so we need to |
| 52 // check for notifications here |
| 53 if (platform != "chromium" && type == "SUBDOCUMENT") |
| 54 { |
| 55 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(url)
); |
| 56 if (notificationToShow) |
| 57 showNotification(notificationToShow); |
| 58 } |
| 59 |
| 60 if (filter) |
| 61 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page); |
| 62 } |
| 63 |
| 49 function onBeforeRequest(url, type, page, frame) | 64 function onBeforeRequest(url, type, page, frame) |
| 50 { | 65 { |
| 51 if (isFrameWhitelisted(page, frame)) | 66 if (isFrameWhitelisted(page, frame)) |
| 52 return true; | 67 return true; |
| 53 | 68 |
| 54 var docDomain = extractHostFromFrame(frame); | 69 var docDomain = extractHostFromFrame(frame); |
| 55 var key = getKey(page, frame); | 70 var key = getKey(page, frame); |
| 56 var filter = defaultMatcher.matchesAny( | 71 var filter = defaultMatcher.matchesAny( |
| 57 stringifyURL(url), | 72 stringifyURL(url), |
| 58 type, docDomain, | 73 type, docDomain, |
| 59 isThirdParty(url, docDomain), | 74 isThirdParty(url, docDomain), |
| 60 key | 75 key |
| 61 ); | 76 ); |
| 62 | 77 |
| 63 // We can't listen to onHeadersReceived in Safari so we need to | 78 setTimeout(onBeforeRequestAsync, 0, url, type, page, filter); |
| 64 // check for notifications here | |
| 65 if (platform != "chromium" && type == "SUBDOCUMENT") | |
| 66 { | |
| 67 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(url)
); | |
| 68 if (notificationToShow) | |
| 69 showNotification(notificationToShow); | |
| 70 } | |
| 71 | 79 |
| 72 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page); | |
| 73 return !(filter instanceof BlockingFilter); | 80 return !(filter instanceof BlockingFilter); |
| 74 } | 81 } |
| 75 | 82 |
| 76 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest); | 83 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest); |
| 77 | 84 |
| 78 if (platform == "chromium") | 85 if (platform == "chromium") |
| 79 { | 86 { |
| 80 function onHeadersReceived(details) | 87 function onHeadersReceived(details) |
| 81 { | 88 { |
| 82 if (details.tabId == -1) | 89 if (details.tabId == -1) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 98 processKey(header.value, page, frame); | 105 processKey(header.value, page, frame); |
| 99 } | 106 } |
| 100 | 107 |
| 101 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(new
URL(details.url))); | 108 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(new
URL(details.url))); |
| 102 if (notificationToShow) | 109 if (notificationToShow) |
| 103 showNotification(notificationToShow); | 110 showNotification(notificationToShow); |
| 104 } | 111 } |
| 105 | 112 |
| 106 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["ht
tp://*/*", "https://*/*"]}, ["responseHeaders"]); | 113 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["ht
tp://*/*", "https://*/*"]}, ["responseHeaders"]); |
| 107 } | 114 } |
| OLD | NEW |