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.isContentWindowPrivate(wnd)) |
+ 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} |