OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 11 matching lines...) Expand all Loading... |
22 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | 22 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
23 Cu.import("resource://gre/modules/Services.jsm"); | 23 Cu.import("resource://gre/modules/Services.jsm"); |
24 | 24 |
25 let {TimeLine} = require("timeline"); | 25 let {TimeLine} = require("timeline"); |
26 let {FilterStorage} = require("filterStorage"); | 26 let {FilterStorage} = require("filterStorage"); |
27 let {FilterNotifier} = require("filterNotifier"); | 27 let {FilterNotifier} = require("filterNotifier"); |
28 let {ElemHide} = require("elemHide"); | 28 let {ElemHide} = require("elemHide"); |
29 let {defaultMatcher} = require("matcher"); | 29 let {defaultMatcher} = require("matcher"); |
30 let {ActiveFilter, RegExpFilter, ElemHideBase} = require("filterClasses"); | 30 let {ActiveFilter, RegExpFilter, ElemHideBase} = require("filterClasses"); |
31 let {Prefs} = require("prefs"); | 31 let {Prefs} = require("prefs"); |
| 32 let {FilterHits} = require("filterHits"); |
32 | 33 |
33 /** | 34 /** |
34 * Value of the FilterListener.batchMode property. | 35 * Value of the FilterListener.batchMode property. |
35 * @type Boolean | 36 * @type Boolean |
36 */ | 37 */ |
37 let batchMode = false; | 38 let batchMode = false; |
38 | 39 |
39 /** | 40 /** |
40 * Increases on filter changes, filters will be saved if it exceeds 1. | 41 * Increases on filter changes, filters will be saved if it exceeds 1. |
41 * @type Integer | 42 * @type Integer |
(...skipping 26 matching lines...) Expand all Loading... |
68 * subsequent calls. If the parameter is 0 it forces saving filters if any | 69 * subsequent calls. If the parameter is 0 it forces saving filters if any |
69 * changes were recorded after the previous save. | 70 * changes were recorded after the previous save. |
70 */ | 71 */ |
71 setDirty: function(/**Integer*/ factor) | 72 setDirty: function(/**Integer*/ factor) |
72 { | 73 { |
73 if (factor == 0 && isDirty > 0) | 74 if (factor == 0 && isDirty > 0) |
74 isDirty = 1; | 75 isDirty = 1; |
75 else | 76 else |
76 isDirty += factor; | 77 isDirty += factor; |
77 if (isDirty >= 1) | 78 if (isDirty >= 1) |
| 79 { |
78 FilterStorage.saveToDisk(); | 80 FilterStorage.saveToDisk(); |
| 81 if (Prefs.sendstats) |
| 82 FilterHits.saveFilterHitsToDisk(); |
| 83 } |
79 } | 84 } |
80 }; | 85 }; |
81 | 86 |
82 /** | 87 /** |
83 * Observer listening to history purge actions. | 88 * Observer listening to history purge actions. |
84 * @class | 89 * @class |
85 */ | 90 */ |
86 let HistoryPurgeObserver = | 91 let HistoryPurgeObserver = |
87 { | 92 { |
88 observe: function(subject, topic, data) | 93 observe: function(subject, topic, data) |
89 { | 94 { |
90 if (topic == "browser:purge-session-history" && Prefs.clearStatsOnHistoryPur
ge) | 95 if (topic == "browser:purge-session-history" && Prefs.clearStatsOnHistoryPur
ge) |
91 { | 96 { |
92 FilterStorage.resetHitCounts(); | 97 FilterStorage.resetHitCounts(); |
| 98 FilterHits.resetFilterHits(); |
93 FilterListener.setDirty(0); // Force saving to disk | 99 FilterListener.setDirty(0); // Force saving to disk |
94 | 100 |
95 Prefs.recentReports = []; | 101 Prefs.recentReports = []; |
96 } | 102 } |
97 }, | 103 }, |
98 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse
rver]) | 104 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse
rver]) |
99 }; | 105 }; |
100 | 106 |
101 /** | 107 /** |
102 * Initializes filter listener on startup, registers the necessary hooks. | 108 * Initializes filter listener on startup, registers the necessary hooks. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 defaultMatcher.clear(); | 274 defaultMatcher.clear(); |
269 ElemHide.clear(); | 275 ElemHide.clear(); |
270 for (let subscription of FilterStorage.subscriptions) | 276 for (let subscription of FilterStorage.subscriptions) |
271 if (!subscription.disabled) | 277 if (!subscription.disabled) |
272 subscription.filters.forEach(addFilter); | 278 subscription.filters.forEach(addFilter); |
273 flushElemHide(); | 279 flushElemHide(); |
274 } | 280 } |
275 else if (action == "save") | 281 else if (action == "save") |
276 isDirty = 0; | 282 isDirty = 0; |
277 } | 283 } |
OLD | NEW |