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

Unified Diff: lib/whitelisting.js

Issue 29338764: Issue 3842 - Split up the logic updating the icon and context menu (Closed)
Patch Set: Reorder cases Created March 21, 2016, 10:49 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 | « lib/icon.js ('k') | popup.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/whitelisting.js
===================================================================
--- a/lib/whitelisting.js
+++ b/lib/whitelisting.js
@@ -21,6 +21,8 @@
let {defaultMatcher} = require("matcher");
let {RegExpFilter} = require("filterClasses");
+let {DownloadableSubscription} = require("subscriptionClasses");
+let {FilterNotifier} = require("filterNotifier");
let {stringifyURL, getDecodedHostname, extractHostFromFrame, isThirdParty} = require("url");
let {port} = require("messaging");
let devtools = require("devtools");
@@ -81,6 +83,44 @@
return match(page, page.url, typeMask);
};
+function revalidateWhitelistingState(page)
+{
+ FilterNotifier.triggerListeners(
+ "page.WhitelistingStateRevalidate", page,
+ match(page, page.url, RegExpFilter.typeMap.DOCUMENT)
+ );
+}
+
+let revalidating = false;
+FilterNotifier.addListener((action, arg) =>
+{
+ switch (action)
+ {
+ case "subscription.added":
+ if (arg instanceof DownloadableSubscription && !arg.lastDownload)
+ break;
+ case "subscription.removed":
+ case "subscription.disabled":
+ case "subscription.updated":
+ case "filter.added":
+ case "filter.removed":
+ case "filter.disabled":
+ case "load":
+ if (!revalidating)
+ {
+ revalidating = true;
+ ext.pages.query({}, pages =>
+ {
+ revalidating = false;
+ for (let page of pages)
+ revalidateWhitelistingState(page);
+ });
+ }
+ }
+});
+
+ext.pages.onLoading.addListener(revalidateWhitelistingState);
+
let getKey =
/**
* Gets the public key, previously recorded for the given page
« no previous file with comments | « lib/icon.js ('k') | popup.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld