OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 28 matching lines...) Expand all Loading... |
39 { | 39 { |
40 if (action in importantNotifications) | 40 if (action in importantNotifications) |
41 { | 41 { |
42 // Execute delayed to prevent multiple executions in a quick succession | 42 // Execute delayed to prevent multiple executions in a quick succession |
43 if (onFilterChangeTimeout != null) | 43 if (onFilterChangeTimeout != null) |
44 window.clearTimeout(onFilterChangeTimeout); | 44 window.clearTimeout(onFilterChangeTimeout); |
45 onFilterChangeTimeout = window.setTimeout(onFilterChange, 2000); | 45 onFilterChangeTimeout = window.setTimeout(onFilterChange, 2000); |
46 } | 46 } |
47 }); | 47 }); |
48 | 48 |
49 function onBeforeRequest(url, type, tab, frame) | 49 function onBeforeRequest(url, type, page, frame) |
50 { | 50 { |
51 if (isFrameWhitelisted(tab, frame)) | 51 if (isFrameWhitelisted(page, frame)) |
52 return true; | 52 return true; |
53 | 53 |
54 var docDomain = extractHostFromURL(frame.url); | 54 var docDomain = extractHostFromURL(frame.url); |
55 var filter = defaultMatcher.matchesAny( | 55 var filter = defaultMatcher.matchesAny( |
56 url, | 56 url, |
57 type == "sub_frame" ? "SUBDOCUMENT" : type.toUpperCase(), | 57 type == "sub_frame" ? "SUBDOCUMENT" : type.toUpperCase(), |
58 docDomain, | 58 docDomain, |
59 isThirdParty(extractHostFromURL(url), docDomain) | 59 isThirdParty(extractHostFromURL(url), docDomain) |
60 ); | 60 ); |
61 | 61 |
62 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, tab); | 62 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page); |
63 return !(filter instanceof BlockingFilter); | 63 return !(filter instanceof BlockingFilter); |
64 } | 64 } |
65 | 65 |
66 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest); | 66 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest); |
67 | 67 |
68 if (require("info").platform == "chromium") | 68 if (require("info").platform == "chromium") |
69 { | 69 { |
70 function onHeadersReceived(details) | 70 function onHeadersReceived(details) |
71 { | 71 { |
72 if (details.tabId == -1) | 72 if (details.tabId == -1) |
73 return; | 73 return; |
74 | 74 |
75 if (details.type != "main_frame" && details.type != "sub_frame") | 75 if (details.type != "main_frame" && details.type != "sub_frame") |
76 return; | 76 return; |
77 | 77 |
78 var tab = new Tab({id: details.tabId}); | 78 var page = new ext.Page({id: details.tabId}); |
79 var frame = new Frame({id: details.frameId, tab: tab}); | 79 var frame = new ext.Frame({frameId: details.frameId, tabId: details.tabId}); |
80 | 80 |
81 if (frame.url != details.url) | 81 if (frame.url != details.url) |
82 return; | 82 return; |
83 | 83 |
84 for (var i = 0; i < details.responseHeaders.length; i++) | 84 for (var i = 0; i < details.responseHeaders.length; i++) |
85 { | 85 { |
86 var header = details.responseHeaders[i]; | 86 var header = details.responseHeaders[i]; |
87 if (header.name.toLowerCase() == "x-adblock-key" && header.value) | 87 if (header.name.toLowerCase() == "x-adblock-key" && header.value) |
88 processKeyException(header.value, tab, frame); | 88 processKeyException(header.value, page, frame); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["<a
ll_urls>"]}, ["responseHeaders"]); | 92 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["<a
ll_urls>"]}, ["responseHeaders"]); |
93 } | 93 } |
OLD | NEW |