| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the Adblock Plus, | 2 * This file is part of the Adblock Plus, |
| 3 * Copyright (C) 2006-2012 Eyeo GmbH | 3 * Copyright (C) 2006-2012 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 return; | 306 return; |
| 307 | 307 |
| 308 subscription.filters.splice(oldPosition, 1); | 308 subscription.filters.splice(oldPosition, 1); |
| 309 subscription.filters.splice(newPosition, 0, filter); | 309 subscription.filters.splice(newPosition, 0, filter); |
| 310 FilterNotifier.triggerListeners("filter.moved", filter, subscription, oldPos
ition, newPosition); | 310 FilterNotifier.triggerListeners("filter.moved", filter, subscription, oldPos
ition, newPosition); |
| 311 }, | 311 }, |
| 312 | 312 |
| 313 /** | 313 /** |
| 314 * Increases the hit count for a filter by one | 314 * Increases the hit count for a filter by one |
| 315 * @param {Filter} filter | 315 * @param {Filter} filter |
| 316 * @param {Window} window Window that the match originated in (required |
| 317 * to recognize private browsing mode) |
| 316 */ | 318 */ |
| 317 increaseHitCount: function(filter) | 319 increaseHitCount: function(filter, wnd) |
| 318 { | 320 { |
| 319 if (!Prefs.savestats || PrivateBrowsing.enabled || !(filter instanceof Activ
eFilter)) | 321 if (!Prefs.savestats || PrivateBrowsing.enabledForWindow(wnd) || |
| 322 PrivateBrowsing.enabled || !(filter instanceof ActiveFilter)) |
| 323 { |
| 320 return; | 324 return; |
| 325 } |
| 321 | 326 |
| 322 filter.hitCount++; | 327 filter.hitCount++; |
| 323 filter.lastHit = Date.now(); | 328 filter.lastHit = Date.now(); |
| 324 }, | 329 }, |
| 325 | 330 |
| 326 /** | 331 /** |
| 327 * Resets hit count for some filters | 332 * Resets hit count for some filters |
| 328 * @param {Array of Filter} filters filters to be reset, if null all filters
will be reset | 333 * @param {Array of Filter} filters filters to be reset, if null all filters
will be reset |
| 329 */ | 334 */ |
| 330 resetHitCounts: function(filters) | 335 resetHitCounts: function(filters) |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 } | 710 } |
| 706 } | 711 } |
| 707 | 712 |
| 708 /** | 713 /** |
| 709 * Observer listening to private browsing mode changes. | 714 * Observer listening to private browsing mode changes. |
| 710 * @class | 715 * @class |
| 711 */ | 716 */ |
| 712 let PrivateBrowsing = exports.PrivateBrowsing = | 717 let PrivateBrowsing = exports.PrivateBrowsing = |
| 713 { | 718 { |
| 714 /** | 719 /** |
| 715 * Will be set to true when the private browsing mode is switched on. | 720 * Will be set to true when the private browsing mode is switched on globally. |
| 716 * @type Boolean | 721 * @type Boolean |
| 717 */ | 722 */ |
| 718 enabled: false, | 723 enabled: false, |
| 719 | 724 |
| 725 /** |
| 726 * Checks whether private browsing is enabled for a particular window. |
| 727 */ |
| 728 enabledForWindow: function(/**Window*/ wnd) /**Boolean*/ |
| 729 { |
| 730 try |
| 731 { |
| 732 return wnd.QueryInterface(Ci.nsIInterfaceRequestor) |
| 733 .getInterface(Ci.nsILoadContext) |
| 734 .usePrivateBrowsing; |
| 735 } |
| 736 catch (e) |
| 737 { |
| 738 // Gecko 19 and below will throw NS_NOINTERFACE, this is expected |
| 739 if (e.result != Cr.NS_NOINTERFACE) |
| 740 Cu.reportError(e); |
| 741 return false; |
| 742 } |
| 743 }, |
| 744 |
| 720 init: function() | 745 init: function() |
| 721 { | 746 { |
| 722 if ("@mozilla.org/privatebrowsing;1" in Cc) | 747 if ("@mozilla.org/privatebrowsing;1" in Cc) |
| 723 { | 748 { |
| 724 try | 749 try |
| 725 { | 750 { |
| 726 this.enabled = Cc["@mozilla.org/privatebrowsing;1"].getService(Ci.nsIPri
vateBrowsingService).privateBrowsingEnabled; | 751 this.enabled = Cc["@mozilla.org/privatebrowsing;1"].getService(Ci.nsIPri
vateBrowsingService).privateBrowsingEnabled; |
| 727 Services.obs.addObserver(this, "private-browsing", true); | 752 Services.obs.addObserver(this, "private-browsing", true); |
| 728 onShutdown.add(function() | 753 onShutdown.add(function() |
| 729 { | 754 { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 else if (this.wantObj === false && val) | 872 else if (this.wantObj === false && val) |
| 848 this.curObj.push(val.replace(/\\\[/g, "[")); | 873 this.curObj.push(val.replace(/\\\[/g, "[")); |
| 849 } | 874 } |
| 850 finally | 875 finally |
| 851 { | 876 { |
| 852 Filter.knownFilters = origKnownFilters; | 877 Filter.knownFilters = origKnownFilters; |
| 853 Subscription.knownSubscriptions = origKnownSubscriptions; | 878 Subscription.knownSubscriptions = origKnownSubscriptions; |
| 854 } | 879 } |
| 855 } | 880 } |
| 856 }; | 881 }; |
| OLD | NEW |