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

Side by Side Diff: lib/prefs.js

Issue 29713631: Issue 5760 - Use relative require paths (Closed)
Patch Set: Created March 3, 2018, 4:09 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 { 333 {
334 for (let key in items) 334 for (let key in items)
335 overrides[keyToPref(key)] = items[key]; 335 overrides[keyToPref(key)] = items[key];
336 336
337 resolve(); 337 resolve();
338 }); 338 });
339 }); 339 });
340 340
341 let managedLoaded = new Promise(resolve => 341 let managedLoaded = new Promise(resolve =>
342 { 342 {
343 if (require("info").platform == "chromium" && "managed" in browser.storage) 343 if (require("../buildtools/info").platform == "chromium" &&
344 "managed" in browser.storage)
kzar 2018/03/19 21:50:08 Please fix the whitespace here, `"managed"` should
Jon Sonesen 2018/03/20 23:25:18 Acknowledged. Since rebase this require is not nee
344 { 345 {
345 browser.storage.managed.get(null, items => 346 browser.storage.managed.get(null, items =>
346 { 347 {
347 // Opera doesn't support browser.storage.managed, but instead simply 348 // Opera doesn't support browser.storage.managed, but instead simply
348 // removing the API, Opera sets browser.runtime.lastError when using it. 349 // removing the API, Opera sets browser.runtime.lastError when using it.
349 // So we have to retrieve that error, to prevent it from showing up 350 // So we have to retrieve that error, to prevent it from showing up
350 // in the console. 351 // in the console.
351 browser.runtime.lastError; 352 browser.runtime.lastError;
352 353
353 for (let key in items) 354 for (let key in items)
(...skipping 26 matching lines...) Expand all
380 eventEmitter.emit(pref); 381 eventEmitter.emit(pref);
381 } 382 }
382 } 383 }
383 }); 384 });
384 } 385 }
385 386
386 Prefs.untilLoaded = Promise.all([localLoaded, managedLoaded]).then(onLoaded); 387 Prefs.untilLoaded = Promise.all([localLoaded, managedLoaded]).then(onLoaded);
387 } 388 }
388 389
389 init(); 390 init();
OLDNEW

Powered by Google App Engine
This is Rietveld