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

Delta Between Two Patch Sets: webrequest.js

Issue 6615790883176448: Issue 2034 - Respect chrome.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES (Closed)
Left Patch Set: Created Feb. 23, 2015, 5:18 p.m.
Right Patch Set: Renamed overlooked variable name Created April 10, 2015, 7:02 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « chrome/ext/background.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 platform = require("info").platform; 20 var platform = require("info").platform;
20 21
21 var importantNotifications = { 22 var importantNotifications = {
22 'filter.added': true, 23 'filter.added': true,
23 'filter.removed': true, 24 'filter.removed': true,
24 'filter.disabled': true, 25 'filter.disabled': true,
25 'subscription.added': true, 26 'subscription.added': true,
26 'subscription.removed': true, 27 'subscription.removed': true,
27 'subscription.disabled': true, 28 'subscription.disabled': true,
28 'subscription.updated': true, 29 'subscription.updated': true,
29 'load': true 30 'load': true
30 }; 31 };
32
33 ext.webRequest.indistinguishableTypes.forEach(function(types)
34 {
35 for (var i = 1; i < types.length; i++)
36 RegExpFilter.typeMap[types[i]] = RegExpFilter.typeMap[types[0]];
37 });
31 38
32 FilterNotifier.addListener(function(action) 39 FilterNotifier.addListener(function(action)
33 { 40 {
34 if (action in importantNotifications) 41 if (action in importantNotifications)
35 ext.webRequest.handlerBehaviorChanged(); 42 ext.webRequest.handlerBehaviorChanged();
36 }); 43 });
37 44
38 function onBeforeRequest(url, type, page, frame) 45 function onBeforeRequest(url, type, page, frame)
39 { 46 {
40 if (isFrameWhitelisted(page, frame)) 47 if (isFrameWhitelisted(page, frame))
41 return true; 48 return true;
42 49
43 var docDomain = extractHostFromFrame(frame); 50 var docDomain = extractHostFromFrame(frame);
44 var key = getKey(page, frame); 51 var key = getKey(page, frame);
45 var filter = defaultMatcher.matchesAny( 52 var filter = defaultMatcher.matchesAny(
46 stringifyURL(url), 53 stringifyURL(url),
47 type == "sub_frame" ? "SUBDOCUMENT" : type.toUpperCase(), 54 type, docDomain,
48 docDomain,
49 isThirdParty(url, docDomain), 55 isThirdParty(url, docDomain),
50 key 56 key
51 ); 57 );
52 58
53 // We can't listen to onHeadersReceived in Safari so we need to 59 // We can't listen to onHeadersReceived in Safari so we need to
54 // check for notifications here 60 // check for notifications here
55 if (platform != "chromium" && type == "sub_frame") 61 if (platform != "chromium" && type == "SUBDOCUMENT")
56 { 62 {
57 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(url) ); 63 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(url) );
58 if (notificationToShow) 64 if (notificationToShow)
59 showNotification(notificationToShow); 65 showNotification(notificationToShow);
60 } 66 }
61 67
62 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page); 68 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page);
63 return !(filter instanceof BlockingFilter); 69 return !(filter instanceof BlockingFilter);
64 } 70 }
65 71
(...skipping 22 matching lines...) Expand all
88 processKey(header.value, page, frame); 94 processKey(header.value, page, frame);
89 } 95 }
90 96
91 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(new URL(details.url))); 97 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(new URL(details.url)));
92 if (notificationToShow) 98 if (notificationToShow)
93 showNotification(notificationToShow); 99 showNotification(notificationToShow);
94 } 100 }
95 101
96 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["ht tp://*/*", "https://*/*"]}, ["responseHeaders"]); 102 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["ht tp://*/*", "https://*/*"]}, ["responseHeaders"]);
97 } 103 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld