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