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

Unified Diff: webrequest.js

Issue 4938965924708352: Issue 2297 - Call chrome.webRequst.behaviorChanged() only for request filter changes (Closed)
Patch Set: Created April 10, 2015, 10:24 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrequest.js
===================================================================
--- a/webrequest.js
+++ b/webrequest.js
@@ -19,27 +19,31 @@
var RegExpFilter = require("filterClasses").RegExpFilter;
var platform = require("info").platform;
-var importantNotifications = {
- 'filter.added': true,
- 'filter.removed': true,
- 'filter.disabled': true,
- 'subscription.added': true,
- 'subscription.removed': true,
- 'subscription.disabled': true,
- 'subscription.updated': true,
- 'load': true
-};
-
ext.webRequest.indistinguishableTypes.forEach(function(types)
{
for (var i = 1; i < types.length; i++)
RegExpFilter.typeMap[types[i]] = RegExpFilter.typeMap[types[0]];
});
-FilterNotifier.addListener(function(action)
+FilterNotifier.addListener(function(action, arg)
{
- if (action in importantNotifications)
- ext.webRequest.handlerBehaviorChanged();
+ switch (action)
+ {
+ case "filter.added":
+ case "filter.removed":
+ case "filter.disabled":
+ // Only request blocking/whitelisting filters have
+ // an effect on the webRequest handler behavior.
+ if (!(arg instanceof RegExpFilter))
+ break;
+ case "subscription.added":
+ case "subscription.removed":
+ case "subscription.disabled":
+ case "subscription.updated":
+ case "load":
+ ext.webRequest.handlerBehaviorChanged();
+ break;
+ }
});
function onBeforeRequest(url, type, page, frame)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld