| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 var FilterNotifier = require("filterNotifier").FilterNotifier; | 18 var FilterNotifier = require("filterNotifier").FilterNotifier; |
| 19 var RegExpFilter = require("filterClasses").RegExpFilter; | 19 var RegExpFilter = require("filterClasses").RegExpFilter; |
| 20 var platform = require("info").platform; | 20 var platform = require("info").platform; |
| 21 var showNextNotificationForUrl = require("notificationHelper").showNextNotificat
ionForUrl; | |
| 22 | 21 |
| 23 ext.webRequest.indistinguishableTypes.forEach(function(types) | 22 ext.webRequest.indistinguishableTypes.forEach(function(types) |
| 24 { | 23 { |
| 25 for (var i = 1; i < types.length; i++) | 24 for (var i = 1; i < types.length; i++) |
| 26 RegExpFilter.typeMap[types[i]] = RegExpFilter.typeMap[types[0]]; | 25 RegExpFilter.typeMap[types[i]] = RegExpFilter.typeMap[types[0]]; |
| 27 }); | 26 }); |
| 28 | 27 |
| 29 FilterNotifier.addListener(function(action, arg) | 28 FilterNotifier.addListener(function(action, arg) |
| 30 { | 29 { |
| 31 switch (action) | 30 switch (action) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 case "subscription.disabled": | 41 case "subscription.disabled": |
| 43 case "subscription.updated": | 42 case "subscription.updated": |
| 44 case "load": | 43 case "load": |
| 45 ext.webRequest.handlerBehaviorChanged(); | 44 ext.webRequest.handlerBehaviorChanged(); |
| 46 break; | 45 break; |
| 47 } | 46 } |
| 48 }); | 47 }); |
| 49 | 48 |
| 50 function onBeforeRequestAsync(url, type, page, filter) | 49 function onBeforeRequestAsync(url, type, page, filter) |
| 51 { | 50 { |
| 52 // We can't listen to onHeadersReceived in Safari so we need to | |
| 53 // check for notifications here | |
| 54 if (platform != "chromium" && type == "SUBDOCUMENT") | |
| 55 showNextNotificationForUrl(url); | |
| 56 | |
| 57 if (filter) | 51 if (filter) |
| 58 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page); | 52 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page); |
| 59 } | 53 } |
| 60 | 54 |
| 61 function onBeforeRequest(url, type, page, frame) | 55 function onBeforeRequest(url, type, page, frame) |
| 62 { | 56 { |
| 63 if (isFrameWhitelisted(page, frame)) | 57 if (isFrameWhitelisted(page, frame)) |
| 64 return true; | 58 return true; |
| 65 | 59 |
| 66 var docDomain = extractHostFromFrame(frame); | 60 var docDomain = extractHostFromFrame(frame); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 91 | 85 |
| 92 if (!frame || frame.url.href != details.url) | 86 if (!frame || frame.url.href != details.url) |
| 93 return; | 87 return; |
| 94 | 88 |
| 95 for (var i = 0; i < details.responseHeaders.length; i++) | 89 for (var i = 0; i < details.responseHeaders.length; i++) |
| 96 { | 90 { |
| 97 var header = details.responseHeaders[i]; | 91 var header = details.responseHeaders[i]; |
| 98 if (header.name.toLowerCase() == "x-adblock-key" && header.value) | 92 if (header.name.toLowerCase() == "x-adblock-key" && header.value) |
| 99 processKey(header.value, page, frame); | 93 processKey(header.value, page, frame); |
| 100 } | 94 } |
| 101 | |
| 102 showNextNotificationForUrl(new URL(details.url)); | |
| 103 } | 95 } |
| 104 | 96 |
| 105 chrome.webRequest.onHeadersReceived.addListener( | 97 chrome.webRequest.onHeadersReceived.addListener( |
| 106 onHeadersReceived, | 98 onHeadersReceived, |
| 107 { | 99 { |
| 108 urls: ["http://*/*", "https://*/*"], | 100 urls: ["http://*/*", "https://*/*"], |
| 109 types: ["main_frame", "sub_frame"] | 101 types: ["main_frame", "sub_frame"] |
| 110 }, | 102 }, |
| 111 ["responseHeaders"] | 103 ["responseHeaders"] |
| 112 ); | 104 ); |
| 113 } | 105 } |
| OLD | NEW |