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: Created Feb. 23, 2015, 5:18 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
« chrome/ext/background.js ('K') | « 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 platform = require("info").platform; 19 var platform = require("info").platform;
20 20
21 var onFilterChangeTimeout = null;
22 function onFilterChange()
23 {
24 onFilterChangeTimeout = null;
25 ext.webRequest.handlerBehaviorChanged();
26 }
27
28 var importantNotifications = { 21 var importantNotifications = {
29 'filter.added': true, 22 'filter.added': true,
30 'filter.removed': true, 23 'filter.removed': true,
31 'filter.disabled': true, 24 'filter.disabled': true,
32 'subscription.added': true, 25 'subscription.added': true,
33 'subscription.removed': true, 26 'subscription.removed': true,
34 'subscription.disabled': true, 27 'subscription.disabled': true,
35 'subscription.updated': true, 28 'subscription.updated': true,
36 'load': true 29 'load': true
37 }; 30 };
38 31
39 FilterNotifier.addListener(function(action) 32 FilterNotifier.addListener(function(action)
40 { 33 {
41 if (action in importantNotifications) 34 if (action in importantNotifications)
42 { 35 ext.webRequest.handlerBehaviorChanged();
43 // Execute delayed to prevent multiple executions in a quick succession
44 if (onFilterChangeTimeout != null)
45 window.clearTimeout(onFilterChangeTimeout);
46 onFilterChangeTimeout = window.setTimeout(onFilterChange, 2000);
47 }
48 }); 36 });
49 37
50 function onBeforeRequest(url, type, page, frame) 38 function onBeforeRequest(url, type, page, frame)
51 { 39 {
52 if (isFrameWhitelisted(page, frame)) 40 if (isFrameWhitelisted(page, frame))
53 return true; 41 return true;
54 42
55 var docDomain = extractHostFromFrame(frame); 43 var docDomain = extractHostFromFrame(frame);
56 var key = getKey(page, frame); 44 var key = getKey(page, frame);
57 var filter = defaultMatcher.matchesAny( 45 var filter = defaultMatcher.matchesAny(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 processKey(header.value, page, frame); 88 processKey(header.value, page, frame);
101 } 89 }
102 90
103 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(new URL(details.url))); 91 var notificationToShow = NotificationStorage.getNextToShow(stringifyURL(new URL(details.url)));
104 if (notificationToShow) 92 if (notificationToShow)
105 showNotification(notificationToShow); 93 showNotification(notificationToShow);
106 } 94 }
107 95
108 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["ht tp://*/*", "https://*/*"]}, ["responseHeaders"]); 96 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["ht tp://*/*", "https://*/*"]}, ["responseHeaders"]);
109 } 97 }
OLDNEW
« chrome/ext/background.js ('K') | « chrome/ext/background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld