| 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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 /** @module prefs */ | 18 /** @module prefs */ |
| 19 | 19 |
| 20 "use strict"; | 20 "use strict"; |
| 21 | 21 |
| 22 const {EventEmitter} = require("events"); | 22 const {EventEmitter} = require("../adblockpluscore/lib/events"); |
| 23 | 23 |
| 24 const keyPrefix = "pref:"; | 24 const keyPrefix = "pref:"; |
| 25 | 25 |
| 26 let eventEmitter = new EventEmitter(); | 26 let eventEmitter = new EventEmitter(); |
| 27 let overrides = Object.create(null); | 27 let overrides = Object.create(null); |
| 28 | 28 |
| 29 /** @lends module:prefs.Prefs */ | 29 /** @lends module:prefs.Prefs */ |
| 30 let defaults = Object.create(null); | 30 let defaults = Object.create(null); |
| 31 | 31 |
| 32 /** | 32 /** |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 { | 258 { |
| 259 return keyPrefix + pref; | 259 return keyPrefix + pref; |
| 260 } | 260 } |
| 261 | 261 |
| 262 function savePref(pref) | 262 function savePref(pref) |
| 263 { | 263 { |
| 264 ext.storage.set(prefToKey(pref), overrides[pref]); | 264 ext.storage.set(prefToKey(pref), overrides[pref]); |
| 265 } | 265 } |
| 266 | 266 |
| 267 let customSave = new Map(); | 267 let customSave = new Map(); |
| 268 if (require("info").platform == "gecko") | 268 if (require("../buildtools/info").platform == "gecko") |
| 269 { | 269 { |
| 270 // Saving one storage value causes all others to be saved as well on Gecko. | 270 // Saving one storage value causes all others to be saved as well on Gecko. |
| 271 // Make sure that updating ad counter doesn't cause the filters data to be | 271 // Make sure that updating ad counter doesn't cause the filters data to be |
| 272 // saved frequently as a side-effect. | 272 // saved frequently as a side-effect. |
| 273 const MIN_UPDATE_INTERVAL = 60 * 1000; | 273 const MIN_UPDATE_INTERVAL = 60 * 1000; |
| 274 let lastUpdate = -MIN_UPDATE_INTERVAL; | 274 let lastUpdate = -MIN_UPDATE_INTERVAL; |
| 275 let updateScheduled = false; | 275 let updateScheduled = false; |
| 276 customSave.set("blocked_total", pref => | 276 customSave.set("blocked_total", pref => |
| 277 { | 277 { |
| 278 if (updateScheduled) | 278 if (updateScheduled) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 eventEmitter.emit(pref); | 380 eventEmitter.emit(pref); |
| 381 } | 381 } |
| 382 } | 382 } |
| 383 }); | 383 }); |
| 384 } | 384 } |
| 385 | 385 |
| 386 Prefs.untilLoaded = Promise.all([localLoaded, managedLoaded]).then(onLoaded); | 386 Prefs.untilLoaded = Promise.all([localLoaded, managedLoaded]).then(onLoaded); |
| 387 } | 387 } |
| 388 | 388 |
| 389 init(); | 389 init(); |
| OLD | NEW |