| 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 whitelisting = require("whitelisting"); |
| 22 var defaultMatcher = require("matcher").defaultMatcher; |
| 23 var url = require("url"); |
| 24 var stringifyURL = url.stringifyURL; |
| 25 var isThirdParty = url.isThirdParty; |
| 26 var extractHostFromFrame = url.extractHostFromFrame; |
| 21 | 27 |
| 22 ext.webRequest.indistinguishableTypes.forEach(function(types) | 28 ext.webRequest.indistinguishableTypes.forEach(function(types) |
| 23 { | 29 { |
| 24 for (var i = 1; i < types.length; i++) | 30 for (var i = 1; i < types.length; i++) |
| 25 RegExpFilter.typeMap[types[i]] = RegExpFilter.typeMap[types[0]]; | 31 RegExpFilter.typeMap[types[i]] = RegExpFilter.typeMap[types[0]]; |
| 26 }); | 32 }); |
| 27 | 33 |
| 28 FilterNotifier.addListener(function(action, arg) | 34 FilterNotifier.addListener(function(action, arg) |
| 29 { | 35 { |
| 30 switch (action) | 36 switch (action) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 47 }); | 53 }); |
| 48 | 54 |
| 49 function onBeforeRequestAsync(url, type, page, filter) | 55 function onBeforeRequestAsync(url, type, page, filter) |
| 50 { | 56 { |
| 51 if (filter) | 57 if (filter) |
| 52 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page); | 58 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page); |
| 53 } | 59 } |
| 54 | 60 |
| 55 function onBeforeRequest(url, type, page, frame) | 61 function onBeforeRequest(url, type, page, frame) |
| 56 { | 62 { |
| 57 if (isFrameWhitelisted(page, frame)) | 63 if (whitelisting.isFrameWhitelisted(page, frame)) |
| 58 return true; | 64 return true; |
| 59 | 65 |
| 60 var docDomain = extractHostFromFrame(frame); | 66 var docDomain = extractHostFromFrame(frame); |
| 61 var key = getKey(page, frame); | 67 var key = whitelisting.getKey(page, frame); |
| 62 var specificOnly = isFrameWhitelisted(page, frame, | 68 var specificOnly = whitelisting.isFrameWhitelisted( |
| 63 RegExpFilter.typeMap.GENERICBLOCK); | 69 page, frame, RegExpFilter.typeMap.GENERICBLOCK |
| 70 ); |
| 64 var filter = defaultMatcher.matchesAny( | 71 var filter = defaultMatcher.matchesAny( |
| 65 stringifyURL(url), | 72 stringifyURL(url), |
| 66 RegExpFilter.typeMap[type], docDomain, | 73 RegExpFilter.typeMap[type], docDomain, |
| 67 isThirdParty(url, docDomain), | 74 isThirdParty(url, docDomain), |
| 68 key, | 75 key, |
| 69 specificOnly | 76 specificOnly |
| 70 ); | 77 ); |
| 71 | 78 |
| 72 setTimeout(onBeforeRequestAsync, 0, url, type, page, filter); | 79 setTimeout(onBeforeRequestAsync, 0, url, type, page, filter); |
| 73 | 80 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 96 | 103 |
| 97 chrome.webRequest.onHeadersReceived.addListener( | 104 chrome.webRequest.onHeadersReceived.addListener( |
| 98 onHeadersReceived, | 105 onHeadersReceived, |
| 99 { | 106 { |
| 100 urls: ["http://*/*", "https://*/*"], | 107 urls: ["http://*/*", "https://*/*"], |
| 101 types: ["main_frame", "sub_frame"] | 108 types: ["main_frame", "sub_frame"] |
| 102 }, | 109 }, |
| 103 ["responseHeaders"] | 110 ["responseHeaders"] |
| 104 ); | 111 ); |
| 105 } | 112 } |
| OLD | NEW |