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: Created March 19, 2016, 8:33 p.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
« lib/filterComposer.js ('K') | « 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,7 @@
let {defaultMatcher} = require("matcher");
let {RegExpFilter} = require("filterClasses");
+let {FilterNotifier} = require("filterNotifier");
let {stringifyURL, getDecodedHostname, extractHostFromFrame, isThirdParty} = require("url");
let {port} = require("messaging");
let devtools = require("devtools");
@@ -47,6 +48,7 @@
return filter;
}
+let checkWhitelisted =
/**
* Gets the active whitelisting filter for the document associated
* with the given page/frame, or null if it's not whitelisted.
@@ -81,6 +83,27 @@
return match(page, page.url, typeMask);
};
+FilterNotifier.addListener(action =>
+{
+ if (action == "load" || action == "save")
+ ext.pages.query({}, pages =>
+ {
+ for (let page of pages)
+ FilterNotifier.triggerListeners(
+ "page.WhitelistingStateRevalidate",
+ page, checkWhitelisted(page)
+ );
+ });
+});
+
+ext.pages.onLoading.addListener(page =>
+{
+ FilterNotifier.triggerListeners(
+ "page.WhitelistingStateRevalidate",
+ page, checkWhitelisted(page)
+ );
+});
+
let getKey =
/**
* Gets the public key, previously recorded for the given page
« lib/filterComposer.js ('K') | « lib/icon.js ('k') | popup.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld