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 showNextNotification = require("notificationHelper").showNextNotification; | 21 var showNextNotificationForUrl = require("notificationHelper").showNextNotificat
ionForUrl; |
22 | 22 |
23 ext.webRequest.indistinguishableTypes.forEach(function(types) | 23 ext.webRequest.indistinguishableTypes.forEach(function(types) |
24 { | 24 { |
25 for (var i = 1; i < types.length; i++) | 25 for (var i = 1; i < types.length; i++) |
26 RegExpFilter.typeMap[types[i]] = RegExpFilter.typeMap[types[0]]; | 26 RegExpFilter.typeMap[types[i]] = RegExpFilter.typeMap[types[0]]; |
27 }); | 27 }); |
28 | 28 |
29 FilterNotifier.addListener(function(action, arg) | 29 FilterNotifier.addListener(function(action, arg) |
30 { | 30 { |
31 switch (action) | 31 switch (action) |
(...skipping 13 matching lines...) Expand all Loading... |
45 ext.webRequest.handlerBehaviorChanged(); | 45 ext.webRequest.handlerBehaviorChanged(); |
46 break; | 46 break; |
47 } | 47 } |
48 }); | 48 }); |
49 | 49 |
50 function onBeforeRequestAsync(url, type, page, filter) | 50 function onBeforeRequestAsync(url, type, page, filter) |
51 { | 51 { |
52 // We can't listen to onHeadersReceived in Safari so we need to | 52 // We can't listen to onHeadersReceived in Safari so we need to |
53 // check for notifications here | 53 // check for notifications here |
54 if (platform != "chromium" && type == "SUBDOCUMENT") | 54 if (platform != "chromium" && type == "SUBDOCUMENT") |
55 showNextNotification(url); | 55 showNextNotificationForUrl(url); |
56 | 56 |
57 if (filter) | 57 if (filter) |
58 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page); | 58 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page); |
59 } | 59 } |
60 | 60 |
61 function onBeforeRequest(url, type, page, frame) | 61 function onBeforeRequest(url, type, page, frame) |
62 { | 62 { |
63 if (isFrameWhitelisted(page, frame)) | 63 if (isFrameWhitelisted(page, frame)) |
64 return true; | 64 return true; |
65 | 65 |
(...skipping 23 matching lines...) Expand all Loading... |
89 if (!frame || frame.url.href != details.url) | 89 if (!frame || frame.url.href != details.url) |
90 return; | 90 return; |
91 | 91 |
92 for (var i = 0; i < details.responseHeaders.length; i++) | 92 for (var i = 0; i < details.responseHeaders.length; i++) |
93 { | 93 { |
94 var header = details.responseHeaders[i]; | 94 var header = details.responseHeaders[i]; |
95 if (header.name.toLowerCase() == "x-adblock-key" && header.value) | 95 if (header.name.toLowerCase() == "x-adblock-key" && header.value) |
96 processKey(header.value, page, frame); | 96 processKey(header.value, page, frame); |
97 } | 97 } |
98 | 98 |
99 showNextNotification(new URL(details.url)); | 99 showNextNotificationForUrl(new URL(details.url)); |
100 } | 100 } |
101 | 101 |
102 chrome.webRequest.onHeadersReceived.addListener( | 102 chrome.webRequest.onHeadersReceived.addListener( |
103 onHeadersReceived, | 103 onHeadersReceived, |
104 { | 104 { |
105 urls: ["http://*/*", "https://*/*"], | 105 urls: ["http://*/*", "https://*/*"], |
106 types: ["main_frame", "sub_frame"] | 106 types: ["main_frame", "sub_frame"] |
107 }, | 107 }, |
108 ["responseHeaders"] | 108 ["responseHeaders"] |
109 ); | 109 ); |
110 } | 110 } |
OLD | NEW |