| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 * @type {string} | 109 * @type {string} |
| 110 */ | 110 */ |
| 111 defaults.notificationurl = "https://notification.adblockplus.org/notification.js
on"; | 111 defaults.notificationurl = "https://notification.adblockplus.org/notification.js
on"; |
| 112 /** | 112 /** |
| 113 * The total number of requests blocked by the extension. | 113 * The total number of requests blocked by the extension. |
| 114 * | 114 * |
| 115 * @type {number} | 115 * @type {number} |
| 116 */ | 116 */ |
| 117 defaults.blocked_total = 0; | 117 defaults.blocked_total = 0; |
| 118 /** | 118 /** |
| 119 * Whether to show a badge in the toolbar icon indicating the number of blocked
ads. | 119 * Whether to show a badge in the toolbar icon indicating the number |
| 120 * of blocked ads. |
| 120 * | 121 * |
| 121 * @type {boolean} | 122 * @type {boolean} |
| 122 */ | 123 */ |
| 123 defaults.show_statsinicon = true; | 124 defaults.show_statsinicon = true; |
| 124 /** | 125 /** |
| 125 * Whether to show the number of blocked ads in the popup. | 126 * Whether to show the number of blocked ads in the popup. |
| 126 * | 127 * |
| 127 * @type {boolean} | 128 * @type {boolean} |
| 128 */ | 129 */ |
| 129 defaults.show_statsinpopup = true; | 130 defaults.show_statsinpopup = true; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 }, | 254 }, |
| 254 enumerable: true | 255 enumerable: true |
| 255 }); | 256 }); |
| 256 } | 257 } |
| 257 | 258 |
| 258 function init() | 259 function init() |
| 259 { | 260 { |
| 260 let prefs = Object.keys(defaults); | 261 let prefs = Object.keys(defaults); |
| 261 prefs.forEach(addPreference); | 262 prefs.forEach(addPreference); |
| 262 | 263 |
| 263 let localLoaded = new Promise(resolve => { | 264 let localLoaded = new Promise(resolve => |
| 265 { |
| 264 ext.storage.get(prefs.map(prefToKey), items => | 266 ext.storage.get(prefs.map(prefToKey), items => |
| 265 { | 267 { |
| 266 for (let key in items) | 268 for (let key in items) |
| 267 overrides[keyToPref(key)] = items[key]; | 269 overrides[keyToPref(key)] = items[key]; |
| 268 | 270 |
| 269 resolve(); | 271 resolve(); |
| 270 }); | 272 }); |
| 271 }); | 273 }); |
| 272 | 274 |
| 273 let managedLoaded = new Promise(resolve => { | 275 let managedLoaded = new Promise(resolve => |
| 276 { |
| 274 if (require("info").platform == "chromium" && "managed" in chrome.storage) | 277 if (require("info").platform == "chromium" && "managed" in chrome.storage) |
| 275 { | 278 { |
| 276 chrome.storage.managed.get(null, items => | 279 chrome.storage.managed.get(null, items => |
| 277 { | 280 { |
| 278 // Opera doesn't support chrome.storage.managed, but instead simply | 281 // Opera doesn't support chrome.storage.managed, but instead simply |
| 279 // removing the API, Opera sets chrome.runtime.lastError when using it. | 282 // removing the API, Opera sets chrome.runtime.lastError when using it. |
| 280 // So we have to retrieve that error, to prevent it from showing up | 283 // So we have to retrieve that error, to prevent it from showing up |
| 281 // in the console. | 284 // in the console. |
| 282 chrome.runtime.lastError; | 285 chrome.runtime.lastError; |
| 283 | 286 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 311 eventEmitter.emit(pref); | 314 eventEmitter.emit(pref); |
| 312 } | 315 } |
| 313 } | 316 } |
| 314 }); | 317 }); |
| 315 } | 318 } |
| 316 | 319 |
| 317 Prefs.untilLoaded = Promise.all([localLoaded, managedLoaded]).then(onLoaded); | 320 Prefs.untilLoaded = Promise.all([localLoaded, managedLoaded]).then(onLoaded); |
| 318 } | 321 } |
| 319 | 322 |
| 320 init(); | 323 init(); |
| OLD | NEW |