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

Unified Diff: lib/whitelisting.js

Issue 29338491: Issue 3823 - Split up message responder code (Closed)
Patch Set: Moved get-domain-enabled-state to whitelisting module Created March 22, 2016, 8:22 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/messaging.js ('k') | metadata.common » ('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
@@ -22,6 +22,7 @@
let {defaultMatcher} = require("matcher");
let {RegExpFilter} = require("filterClasses");
let {stringifyURL, getDecodedHostname, extractHostFromFrame, isThirdParty} = require("url");
+let {port} = require("messaging");
let devtools = require("devtools");
let pagesWithKey = new ext.PageMap();
@@ -46,6 +47,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.
@@ -129,6 +131,7 @@
urlsWithKey[stringifyURL(url)] = key;
}
+let processKey =
/**
* Validates signatures given by the "X-Adblock-Key" response
* header or the "data-adblockkey" attribute of the document
@@ -151,3 +154,13 @@
if (verifyKey(key, signature, frame.url))
recordKey(page, frame.url, key);
};
+
+port.on("filters.addKey", (message, sender) =>
+{
+ processKey(message.token, sender.page, sender.frame);
+});
+
+port.on("filters.isPageWhitelisted", (message, sender) =>
+{
+ return !!checkWhitelisted(sender.page);
+});
« no previous file with comments | « lib/messaging.js ('k') | metadata.common » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld