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

Side by Side Diff: webrequest.js

Issue 6615790883176448: Issue 2034 - Respect chrome.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « chrome/ext/background.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 <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 21
22 var onFilterChangeTimeout = null;
23 function onFilterChange()
24 {
25 onFilterChangeTimeout = null;
26 ext.webRequest.handlerBehaviorChanged();
27 }
28
29 var importantNotifications = { 22 var importantNotifications = {
30 'filter.added': true, 23 'filter.added': true,
31 'filter.removed': true, 24 'filter.removed': true,
32 'filter.disabled': true, 25 'filter.disabled': true,
33 'subscription.added': true, 26 'subscription.added': true,
34 'subscription.removed': true, 27 'subscription.removed': true,
35 'subscription.disabled': true, 28 'subscription.disabled': true,
36 'subscription.updated': true, 29 'subscription.updated': true,
37 'load': true 30 'load': true
38 }; 31 };
39 32
40 ext.webRequest.indistinguishableTypes.forEach(function(types) 33 ext.webRequest.indistinguishableTypes.forEach(function(types)
41 { 34 {
42 for (var i = 1; i < types.length; i++) 35 for (var i = 1; i < types.length; i++)
43 RegExpFilter.typeMap[types[i]] = RegExpFilter.typeMap[types[0]]; 36 RegExpFilter.typeMap[types[i]] = RegExpFilter.typeMap[types[0]];
44 }); 37 });
45 38
46 FilterNotifier.addListener(function(action) 39 FilterNotifier.addListener(function(action)
47 { 40 {
48 if (action in importantNotifications) 41 if (action in importantNotifications)
49 { 42 ext.webRequest.handlerBehaviorChanged();
50 // Execute delayed to prevent multiple executions in a quick succession
51 if (onFilterChangeTimeout != null)
52 window.clearTimeout(onFilterChangeTimeout);
53 onFilterChangeTimeout = window.setTimeout(onFilterChange, 2000);
54 }
55 }); 43 });
56 44
57 function onBeforeRequest(url, type, page, frame) 45 function onBeforeRequest(url, type, page, frame)
58 { 46 {
59 if (isFrameWhitelisted(page, frame)) 47 if (isFrameWhitelisted(page, frame))
60 return true; 48 return true;
61 49
62 var docDomain = extractHostFromFrame(frame); 50 var docDomain = extractHostFromFrame(frame);
63 var key = getKey(page, frame); 51 var key = getKey(page, frame);
64 var filter = defaultMatcher.matchesAny( 52 var filter = defaultMatcher.matchesAny(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 processKey(header.value, page, frame); 94 processKey(header.value, page, frame);
107 } 95 }
108 96
109 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(new URL(details.url))); 97 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(new URL(details.url)));
110 if (notificationToShow) 98 if (notificationToShow)
111 showNotification(notificationToShow); 99 showNotification(notificationToShow);
112 } 100 }
113 101
114 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["ht tp://*/*", "https://*/*"]}, ["responseHeaders"]); 102 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["ht tp://*/*", "https://*/*"]}, ["responseHeaders"]);
115 } 103 }
OLDNEW
« no previous file with comments | « chrome/ext/background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld