| Index: lib/filterStorage.js |
| =================================================================== |
| --- a/lib/filterStorage.js |
| +++ b/lib/filterStorage.js |
| @@ -308,21 +308,26 @@ let FilterStorage = exports.FilterStorag |
| subscription.filters.splice(oldPosition, 1); |
| subscription.filters.splice(newPosition, 0, filter); |
| FilterNotifier.triggerListeners("filter.moved", filter, subscription, oldPosition, newPosition); |
| }, |
| /** |
| * Increases the hit count for a filter by one |
| * @param {Filter} filter |
| + * @param {Window} window Window that the match originated in (required |
| + * to recognize private browsing mode) |
| */ |
| - increaseHitCount: function(filter) |
| + increaseHitCount: function(filter, wnd) |
| { |
| - if (!Prefs.savestats || PrivateBrowsing.enabled || !(filter instanceof ActiveFilter)) |
| + if (!Prefs.savestats || PrivateBrowsing.enabledForWindow(wnd) || |
| + PrivateBrowsing.enabled || !(filter instanceof ActiveFilter)) |
| + { |
| return; |
| + } |
| filter.hitCount++; |
| filter.lastHit = Date.now(); |
| }, |
| /** |
| * Resets hit count for some filters |
| * @param {Array of Filter} filters filters to be reset, if null all filters will be reset |
| @@ -707,21 +712,41 @@ function removeSubscriptionFilters(subsc |
| /** |
| * Observer listening to private browsing mode changes. |
| * @class |
| */ |
| let PrivateBrowsing = exports.PrivateBrowsing = |
| { |
| /** |
| - * Will be set to true when the private browsing mode is switched on. |
| + * Will be set to true when the private browsing mode is switched on globally. |
| * @type Boolean |
| */ |
| enabled: false, |
| + /** |
| + * Checks whether private browsing is enabled for a particular window. |
| + */ |
| + enabledForWindow: function(/**Window*/ wnd) /**Boolean*/ |
| + { |
| + try |
| + { |
| + return wnd.QueryInterface(Ci.nsIInterfaceRequestor) |
| + .getInterface(Ci.nsILoadContext) |
| + .usePrivateBrowsing; |
| + } |
| + catch (e) |
| + { |
| + // Gecko 19 and below will throw NS_NOINTERFACE, this is expected |
| + if (e.result != Cr.NS_NOINTERFACE) |
| + Cu.reportError(e); |
| + return false; |
| + } |
| + }, |
| + |
| init: function() |
| { |
| if ("@mozilla.org/privatebrowsing;1" in Cc) |
| { |
| try |
| { |
| this.enabled = Cc["@mozilla.org/privatebrowsing;1"].getService(Ci.nsIPrivateBrowsingService).privateBrowsingEnabled; |
| Services.obs.addObserver(this, "private-browsing", true); |