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

Unified Diff: lib/contentPolicy.js

Issue 5840485868371968: Issue 616 - Add $generichide + $genericblock filter options and enforce them. (Closed)
Patch Set: Rebased onto typeMask changes Created July 14, 2015, 4:41 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
« no previous file with comments | « no previous file | lib/filterClasses.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/contentPolicy.js
diff --git a/lib/contentPolicy.js b/lib/contentPolicy.js
index b0498da6ec3bf66b35e35d8d8114e99ad3477707..a0741a97a138c2ce656965a6ee2713efe05368f3 100644
--- a/lib/contentPolicy.js
+++ b/lib/contentPolicy.js
@@ -162,6 +162,7 @@ let Policy = exports.Policy =
let docDomain = getHostname(wndLocation);
let match = null;
let [sitekey, sitekeyWnd] = getSitekey(wnd);
+ let genericblock = { match: null };
Sebastian Noack 2015/07/14 17:23:33 Also it might be a bad idea performance-wise to cr
Sebastian Noack 2015/07/14 17:23:33 Nit: We don't add spaces at the beginning/end of a
kzar 2015/07/15 11:56:20 Acknowledged.
if (!match && Prefs.enabled)
{
let testWnd = wnd;
@@ -180,6 +181,17 @@ let Policy = exports.Policy =
RequestNotifier.addNodeData(testWnd.document, topWnd, Policy.type.DOCUMENT, getHostname(parentWndLocation), false, testWndLocation, match);
return true;
}
+ else if (!(genericblock.match instanceof WhitelistFilter) && contentType != Policy.type.ELEMHIDE)
Sebastian Noack 2015/07/14 17:23:33 Wouldn't genericblock.match alway be null here, he
kzar 2015/07/15 11:56:21 You're right, I think I was emulating some of the
+ {
+ let parentDocDomain = getHostname(parentWndLocation);
+ genericblock.match = defaultMatcher.matchesAny(testWndLocation, RegExpFilter.typeMap.GENERICBLOCK, parentDocDomain, false);
+ if (genericblock.match instanceof WhitelistFilter)
+ {
+ genericblock.parentDocDomain = parentDocDomain;
+ genericblock.testWnd = testWnd;
+ genericblock.testWndLocation = testWndLocation;
+ }
+ }
if (testWnd.parent == testWnd)
break;
@@ -208,7 +220,12 @@ let Policy = exports.Policy =
let testWndLocation = parentWndLocation;
parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWindowLocation(testWnd.parent));
let parentDocDomain = getHostname(parentWndLocation);
+
match = defaultMatcher.matchesAny(testWndLocation, RegExpFilter.typeMap.ELEMHIDE, parentDocDomain, false, sitekey);
+
+ if (!(match instanceof WhitelistFilter) && (!location.domains || location.domains[""]))
+ match = defaultMatcher.matchesAny(testWndLocation, RegExpFilter.typeMap.GENERICHIDE, parentDocDomain, false);
+
if (match instanceof WhitelistFilter)
{
FilterStorage.increaseHitCount(match, wnd);
@@ -243,11 +260,27 @@ let Policy = exports.Policy =
if (!match && Prefs.enabled && contentType in Policy.typeMask)
{
match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentType], docDomain, thirdParty, sitekey);
- if (match instanceof BlockingFilter && node.ownerDocument && !(contentType in Policy.nonVisual))
+ if (match instanceof BlockingFilter)
{
- let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fastcollapse);
- if (collapse || prefCollapse)
- schedulePostProcess(node);
+ if ((!match.domains || match.domains[""]) && genericblock.match instanceof WhitelistFilter)
+ {
+ FilterStorage.increaseHitCount(genericblock.match, wnd);
+ RequestNotifier.addNodeData(
+ genericblock.testWnd.document,
+ topWnd, contentType,
+ genericblock.parentDocDomain,
+ false, genericblock.testWndLocation,
+ genericblock.match
+ );
+ return true;
+ }
+
+ if (node.ownerDocument && !(contentType in Policy.nonVisual))
+ {
+ let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fastcollapse);
+ if (collapse || prefCollapse)
+ schedulePostProcess(node);
+ }
}
// Track mouse events for objects
« no previous file with comments | « no previous file | lib/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld