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

Unified Diff: lib/filterStorage.js

Issue 9043026: Adapted private browsing handling to per-window private browsing in Firefox 20 (Closed)
Patch Set: Created Dec. 18, 2012, 2:57 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 | « lib/contentPolicy.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,39 @@ 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 NO_INTERFACE, this is expected
Thomas Greiner 2012/12/19 14:21:39 in that case we can check if we actually got a NO_
+ 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);
« no previous file with comments | « lib/contentPolicy.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld