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

Unified Diff: lib/contentPolicy.js

Issue 29329527: Issue 3208 - Consider private browsing in contentPolicy module rather than filterStorage (Closed)
Patch Set: Created Oct. 29, 2015, 8:32 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/filterStorage.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/contentPolicy.js
===================================================================
--- a/lib/contentPolicy.js
+++ b/lib/contentPolicy.js
@@ -18,16 +18,17 @@
/**
* @fileOverview Content policy implementation, responsible for blocking things.
*/
"use strict";
let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
+let {PrivateBrowsingUtils} = Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm", {});
let {Utils} = require("utils");
let {Prefs} = require("prefs");
let {FilterStorage} = require("filterStorage");
let {BlockingFilter, WhitelistFilter, RegExpFilter} = require("filterClasses");
let {defaultMatcher} = require("matcher");
let {objectMouseEventHander} = require("objectTabs");
let {RequestNotifier} = require("requestNotifier");
@@ -137,16 +138,22 @@ var Policy = exports.Policy =
let url = getWindowLocation(wnd);
let index = url.indexOf("#");
if (index >= 0)
url = url.substring(0, index);
return url;
}
+ function addHit(match)
+ {
+ if (!PrivateBrowsingUtils.isWindowPrivate(wnd))
Thomas Greiner 2015/11/02 17:29:23 I'm wondering whether `wnd` here could potentially
Wladimir Palant 2015/11/02 18:49:22 Ouch, I overlooked the "Chrome" part, and document
+ FilterStorage.increaseHitCount(match);
+ }
+
if (!match && Prefs.enabled)
{
let testWnd = wnd;
let testSitekey = sitekey;
let testSitekeyWnd = sitekeyWnd;
let parentWndLocation = cleanWindowLocation(testWnd);
while (true)
{
@@ -155,31 +162,31 @@ var Policy = exports.Policy =
let parentDocDomain = getHostname(parentWndLocation);
let typeMap = RegExpFilter.typeMap.DOCUMENT;
if (contentType == "ELEMHIDE")
typeMap = typeMap | RegExpFilter.typeMap.ELEMHIDE;
let whitelistMatch = defaultMatcher.matchesAny(testWndLocation, typeMap, parentDocDomain, false, sitekey);
if (whitelistMatch instanceof WhitelistFilter)
{
- FilterStorage.increaseHitCount(whitelistMatch, wnd);
+ addHit(whitelistMatch);
RequestNotifier.addNodeData(testWnd.document, topWnd,
(whitelistMatch.contentType & RegExpFilter.typeMap.DOCUMENT) ? "DOCUMENT" : "ELEMHIDE",
parentDocDomain, false, testWndLocation, whitelistMatch);
return true;
}
let genericType = (contentType == "ELEMHIDE" ? "GENERICHIDE" : "GENERICBLOCK");
let nogenericMatch = defaultMatcher.matchesAny(testWndLocation,
RegExpFilter.typeMap[genericType], parentDocDomain, false, testSitekey);
if (nogenericMatch instanceof WhitelistFilter)
{
nogeneric = true;
- FilterStorage.increaseHitCount(nogenericMatch, wnd);
+ addHit(nogenericMatch);
RequestNotifier.addNodeData(testWnd.document, topWnd, genericType,
parentDocDomain, false, testWndLocation,
nogenericMatch);
}
if (testWnd.parent == testWnd)
break;
@@ -203,17 +210,17 @@ var Policy = exports.Policy =
location = match.text.replace(/^.*?#/, '#');
if (!match.isActiveOnDomain(docDomain))
return true;
let exception = ElemHide.getException(match, docDomain);
if (exception)
{
- FilterStorage.increaseHitCount(exception, wnd);
+ addHit(exception);
RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false, location, exception);
return true;
}
if (nogeneric && match.isGeneric())
return true;
}
@@ -236,17 +243,17 @@ var Policy = exports.Policy =
node.addEventListener("mouseover", objectMouseEventHander, true);
node.addEventListener("mouseout", objectMouseEventHander, true);
}
}
// Store node data
RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, thirdParty, location, match);
if (match)
- FilterStorage.increaseHitCount(match, wnd);
+ addHit(match);
return !match || match instanceof WhitelistFilter;
},
/**
* Checks whether the location's scheme is blockable.
* @param location {nsIURI}
* @return {Boolean}
« no previous file with comments | « no previous file | lib/filterStorage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld