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

Unified Diff: lib/whitelisting.js

Issue 29321504: Issue 2738 - Pass bit masks to matching functions (Closed)
Patch Set: Updated to match adblockplus changes and addressed feedback Created July 12, 2015, 2:25 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
Index: lib/whitelisting.js
diff --git a/lib/whitelisting.js b/lib/whitelisting.js
index 129e775847c2229e272be68113210d439ef32fb4..c16984821e29dcc6cdc96014f3e4d1fbe2323b2c 100644
--- a/lib/whitelisting.js
+++ b/lib/whitelisting.js
@@ -18,6 +18,7 @@
/** @module whitelisting */
let {defaultMatcher} = require("matcher");
+let {RegExpFilter} = require("filterClasses");
let {stringifyURL, getDecodedHostname, extractHostFromFrame, isThirdParty} = require("url");
let pagesWithKey = new ext.PageMap();
@@ -26,14 +27,15 @@ let pagesWithKey = new ext.PageMap();
* Checks whether a page is whitelisted.
*
* @param {Page} page
+ * @param {Number} [typeMask=RegExpFilter.typeMap.DOCUMENT] Bit mask of request / content types to match
* @return {WhitelistFilter} The active filter whitelisting this page or null
*/
-exports.isPageWhitelisted = function(page)
+exports.isPageWhitelisted = function(page, typeMask)
Sebastian Noack 2015/07/13 16:41:50 Sorry if my previous comment was misleading. But s
kzar 2015/07/14 09:22:24 Done.
{
let url = page.url;
return defaultMatcher.whitelist.matchesAny(
- stringifyURL(url), "DOCUMENT",
+ stringifyURL(url), typeMask || RegExpFilter.typeMap.DOCUMENT,
getDecodedHostname(url), false, null
);
};
@@ -43,11 +45,10 @@ exports.isPageWhitelisted = function(page)
*
* @param {Page} page
* @param {Frame} frame
- * @param {string} [type=DOCUMENT] The request type to check whether
- * the frame is whitelisted for.
+ * @param {Number} [typeMask=RegExpFilter.typeMap.DOCUMENT] Bit mask of request / content types to match
Sebastian Noack 2015/07/13 16:41:50 Nit: Please use lowercase when referring to primit
kzar 2015/07/14 09:22:24 Done.
* @return {Boolean}
*/
-exports.isFrameWhitelisted = function(page, frame, type)
+exports.isFrameWhitelisted = function(page, frame, typeMask)
{
while (frame)
{
@@ -56,7 +57,7 @@ exports.isFrameWhitelisted = function(page, frame, type)
let documentHost = extractHostFromFrame(parent) || getDecodedHostname(url);
let filter = defaultMatcher.whitelist.matchesAny(
- stringifyURL(url), type || "DOCUMENT",
+ stringifyURL(url), typeMask || RegExpFilter.typeMap.DOCUMENT,
documentHost, isThirdParty(url, documentHost),
getKey(page, frame)
);
« lib/filterComposer.js ('K') | « lib/filterComposer.js ('k') | popupBlocker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld