Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: webrequest.js

Issue 6393086494113792: Issue 154 - Added devtools panel showing blocked and blockable items (Closed)
Patch Set: Moved UI to adblockplusui repo Created Jan. 7, 2015, 1:46 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « popupBlocker.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 platform = require("info").platform; 19 var platform = require("info").platform;
20 var logRequest = require("devtools").logRequest;
20 21
21 var onFilterChangeTimeout = null; 22 var onFilterChangeTimeout = null;
22 function onFilterChange() 23 function onFilterChange()
23 { 24 {
24 onFilterChangeTimeout = null; 25 onFilterChangeTimeout = null;
25 ext.webRequest.handlerBehaviorChanged(); 26 ext.webRequest.handlerBehaviorChanged();
26 } 27 }
27 28
28 var importantNotifications = { 29 var importantNotifications = {
29 'filter.added': true, 30 'filter.added': true,
(...skipping 15 matching lines...) Expand all
45 window.clearTimeout(onFilterChangeTimeout); 46 window.clearTimeout(onFilterChangeTimeout);
46 onFilterChangeTimeout = window.setTimeout(onFilterChange, 2000); 47 onFilterChangeTimeout = window.setTimeout(onFilterChange, 2000);
47 } 48 }
48 }); 49 });
49 50
50 function onBeforeRequest(url, type, page, frame) 51 function onBeforeRequest(url, type, page, frame)
51 { 52 {
52 if (isFrameWhitelisted(page, frame)) 53 if (isFrameWhitelisted(page, frame))
53 return true; 54 return true;
54 55
56 var reqType = type == "sub_frame" ? "SUBDOCUMENT" : type.toUpperCase();
55 var docDomain = extractHostFromFrame(frame); 57 var docDomain = extractHostFromFrame(frame);
56 var key = getKey(page, frame); 58 var key = getKey(page, frame);
57 var filter = defaultMatcher.matchesAny( 59 var filter = defaultMatcher.matchesAny(
58 url, 60 url,
59 type == "sub_frame" ? "SUBDOCUMENT" : type.toUpperCase(), 61 reqType,
60 docDomain, 62 docDomain,
61 isThirdParty(extractHostFromURL(url), docDomain), 63 isThirdParty(extractHostFromURL(url), docDomain),
62 key 64 key
63 ); 65 );
64 66
65 // We can't listen to onHeadersReceived in Safari so we need to 67 // We can't listen to onHeadersReceived in Safari so we need to
66 // check for notifications here 68 // check for notifications here
67 if (platform != "chromium" && type == "sub_frame") 69 if (platform != "chromium" && type == "sub_frame")
68 { 70 {
69 var notificationToShow = Notification.getNextToShow(url); 71 var notificationToShow = Notification.getNextToShow(url);
70 if (notificationToShow) 72 if (notificationToShow)
71 showNotification(notificationToShow); 73 showNotification(notificationToShow);
72 } 74 }
73 75
76 logRequest(page._id, url, reqType, docDomain, key, filter);
74 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page); 77 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page);
78
75 return !(filter instanceof BlockingFilter); 79 return !(filter instanceof BlockingFilter);
76 } 80 }
77 81
78 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest); 82 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest);
79 83
80 if (platform == "chromium") 84 if (platform == "chromium")
81 { 85 {
82 function onHeadersReceived(details) 86 function onHeadersReceived(details)
83 { 87 {
84 if (details.tabId == -1) 88 if (details.tabId == -1)
(...skipping 15 matching lines...) Expand all
100 processKey(header.value, page, frame); 104 processKey(header.value, page, frame);
101 } 105 }
102 106
103 var notificationToShow = Notification.getNextToShow(details.url); 107 var notificationToShow = Notification.getNextToShow(details.url);
104 if (notificationToShow) 108 if (notificationToShow)
105 showNotification(notificationToShow); 109 showNotification(notificationToShow);
106 } 110 }
107 111
108 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["ht tp://*/*", "https://*/*"]}, ["responseHeaders"]); 112 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["ht tp://*/*", "https://*/*"]}, ["responseHeaders"]);
109 } 113 }
OLDNEW
« no previous file with comments | « popupBlocker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld