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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 setTimeout(onBeforeRequestAsync, 0, page, urlString, | 84 setTimeout(onBeforeRequestAsync, 0, page, urlString, |
85 type, docDomain, | 85 type, docDomain, |
86 thirdParty, key, | 86 thirdParty, key, |
87 specificOnly, filter); | 87 specificOnly, filter); |
88 | 88 |
89 return !(filter instanceof BlockingFilter); | 89 return !(filter instanceof BlockingFilter); |
90 } | 90 } |
91 | 91 |
92 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest); | 92 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest); |
93 | 93 |
94 if (platform == "chromium") | 94 if (typeof chrome == "object") |
95 { | 95 { |
96 function onHeadersReceived(details) | 96 function onHeadersReceived(details) |
97 { | 97 { |
98 var page = new ext.Page({id: details.tabId}); | 98 var page = new ext.Page({id: details.tabId}); |
99 var frame = ext.getFrame(details.tabId, details.frameId); | 99 var frame = ext.getFrame(details.tabId, details.frameId); |
100 | 100 |
101 if (!frame || frame.url.href != details.url) | 101 if (!frame || frame.url.href != details.url) |
102 return; | 102 return; |
103 | 103 |
104 for (var i = 0; i < details.responseHeaders.length; i++) | 104 for (var i = 0; i < details.responseHeaders.length; i++) |
105 { | 105 { |
106 var header = details.responseHeaders[i]; | 106 var header = details.responseHeaders[i]; |
107 if (header.name.toLowerCase() == "x-adblock-key" && header.value) | 107 if (header.name.toLowerCase() == "x-adblock-key" && header.value) |
108 processKey(header.value, page, frame); | 108 processKey(header.value, page, frame); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 chrome.webRequest.onHeadersReceived.addListener( | 112 chrome.webRequest.onHeadersReceived.addListener( |
113 onHeadersReceived, | 113 onHeadersReceived, |
114 { | 114 { |
115 urls: ["http://*/*", "https://*/*"], | 115 urls: ["http://*/*", "https://*/*"], |
116 types: ["main_frame", "sub_frame"] | 116 types: ["main_frame", "sub_frame"] |
117 }, | 117 }, |
118 ["responseHeaders"] | 118 ["responseHeaders"] |
119 ); | 119 ); |
120 } | 120 } |
OLD | NEW |