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

Unified Diff: webrequest.js

Issue 8691076: Make sure to indicate to Chrome when our filters change (Closed)
Patch Set: Created Oct. 30, 2012, 9:51 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
@@ -14,16 +14,45 @@
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
chrome.webRequest.onBeforeRequest.addListener(onBeforeRequest, {urls: ["http://*/*", "https://*/*"]}, ["blocking"]);
chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["http://*/*", "https://*/*"]}, ["responseHeaders"]);
chrome.tabs.onRemoved.addListener(forgetTab);
+var onFilterChangeTimeout = null;
+function onFilterChange()
+{
+ onFilterChangeTimeout = null;
+ chrome.webRequest.handlerBehaviorChanged();
+}
+
+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
+};
+
+require("filterNotifier").FilterNotifier.addListener(function(action)
+{
+ if (action in importantNotifications)
+ {
+ // Execute delayed to prevent multiple executions in a quick succession
+ if (onFilterChangeTimeout != null)
+ window.clearTimeout(onFilterChangeTimeout);
+ window.setTimeout(onFilterChange, 2000);
Thomas Greiner 2012/10/30 10:17:22 set onFilterChangeTimeout variable otherwise it wi
+ }
+});
+
var frames = {};
function onBeforeRequest(details)
{
if (details.tabId == -1)
return {};
var type = details.type;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld