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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 return !(filter instanceof BlockingFilter); | 80 return !(filter instanceof BlockingFilter); |
81 } | 81 } |
82 | 82 |
83 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest); | 83 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest); |
84 | 84 |
85 if (platform == "chromium") | 85 if (platform == "chromium") |
86 { | 86 { |
87 function onHeadersReceived(details) | 87 function onHeadersReceived(details) |
88 { | 88 { |
89 if (details.tabId == -1) | |
90 return; | |
91 | |
92 if (details.type != "main_frame" && details.type != "sub_frame") | |
93 return; | |
94 | |
95 var page = new ext.Page({id: details.tabId}); | 89 var page = new ext.Page({id: details.tabId}); |
96 var frame = ext.getFrame(details.tabId, details.frameId); | 90 var frame = ext.getFrame(details.tabId, details.frameId); |
97 | 91 |
98 if (!frame || frame.url.href != details.url) | 92 if (!frame || frame.url.href != details.url) |
99 return; | 93 return; |
100 | 94 |
101 for (var i = 0; i < details.responseHeaders.length; i++) | 95 for (var i = 0; i < details.responseHeaders.length; i++) |
102 { | 96 { |
103 var header = details.responseHeaders[i]; | 97 var header = details.responseHeaders[i]; |
104 if (header.name.toLowerCase() == "x-adblock-key" && header.value) | 98 if (header.name.toLowerCase() == "x-adblock-key" && header.value) |
105 processKey(header.value, page, frame); | 99 processKey(header.value, page, frame); |
106 } | 100 } |
107 | 101 |
108 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(new
URL(details.url))); | 102 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(new
URL(details.url))); |
109 if (notificationToShow) | 103 if (notificationToShow) |
110 showNotification(notificationToShow); | 104 showNotification(notificationToShow); |
111 } | 105 } |
112 | 106 |
113 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["ht
tp://*/*", "https://*/*"]}, ["responseHeaders"]); | 107 chrome.webRequest.onHeadersReceived.addListener( |
| 108 onHeadersReceived, |
| 109 { |
| 110 urls: ["http://*/*", "https://*/*"], |
| 111 types: ["main_frame", "sub_frame"] |
| 112 }, |
| 113 ["responseHeaders"] |
| 114 ); |
114 } | 115 } |
OLD | NEW |