| LEFT | RIGHT |
| 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 SpecialSubscription} = | 24 SpecialSubscription} = |
| 25 require("../adblockpluscore/lib/subscriptionClasses"); | 25 require("../adblockpluscore/lib/subscriptionClasses"); |
| 26 const {FilterStorage} = require("../adblockpluscore/lib/filterStorage"); | 26 const {FilterStorage} = require("../adblockpluscore/lib/filterStorage"); |
| 27 const {FilterNotifier} = require("../adblockpluscore/lib/filterNotifier"); | 27 const {FilterNotifier} = require("../adblockpluscore/lib/filterNotifier"); |
| 28 const info = require("../buildtools/info"); | 28 const info = require("../buildtools/info"); |
| 29 const {Prefs} = require("./prefs"); | 29 const {Prefs} = require("./prefs"); |
| 30 const {Synchronizer} = require("../adblockpluscore/lib/synchronizer"); | 30 const {Synchronizer} = require("../adblockpluscore/lib/synchronizer"); |
| 31 const {Utils} = require("./utils"); | 31 const {Utils} = require("./utils"); |
| 32 const {initNotifications} = require("./notificationHelper"); | 32 const {initNotifications} = require("./notificationHelper"); |
| 33 const {updatesVersion} = require("../adblockplusui/lib/prefs"); | 33 const {updatesVersion} = require("../adblockplusui/lib/prefs"); |
| 34 const {setUninstallURL} = require("./uninstall"); | |
| 35 | 34 |
| 36 let firstRun; | 35 let firstRun; |
| 37 let subscriptionsCallback = null; | 36 let subscriptionsCallback = null; |
| 38 let reinitialized = false; | 37 let reinitialized = false; |
| 39 let dataCorrupted = false; | 38 let dataCorrupted = false; |
| 40 | 39 |
| 41 /** | 40 /** |
| 42 * If there aren't any filters, the default subscriptions are added. | 41 * If there aren't any filters, the default subscriptions are added. |
| 43 * However, if patterns.ini already did exist and/or any preference | 42 * However, if patterns.ini already did exist and/or any preference |
| 44 * is set to a non-default value, this indicates that this isn't the | 43 * is set to a non-default value, this indicates that this isn't the |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 updatesVersion > Prefs.last_updates_page_displayed) | 248 updatesVersion > Prefs.last_updates_page_displayed) |
| 250 { | 249 { |
| 251 return Prefs.set("last_updates_page_displayed", updatesVersion).catch(() => | 250 return Prefs.set("last_updates_page_displayed", updatesVersion).catch(() => |
| 252 { | 251 { |
| 253 dataCorrupted = true; | 252 dataCorrupted = true; |
| 254 }).then(() => | 253 }).then(() => |
| 255 { | 254 { |
| 256 if (!Prefs.suppress_first_run_page) | 255 if (!Prefs.suppress_first_run_page) |
| 257 { | 256 { |
| 258 // Always show the first run page if a data corruption was detected | 257 // Always show the first run page if a data corruption was detected |
| 259 // (either though failure of reading from or writing to storage.local). | 258 // (either through failure of reading from or writing to storage.local). |
| 260 // The first run page notifies the user about the data corruption. | 259 // The first run page notifies the user about the data corruption. |
| 261 let url; | 260 let url; |
| 262 if (firstRun || dataCorrupted) | 261 if (firstRun || dataCorrupted) |
| 263 url = "firstRun.html"; | 262 url = "firstRun.html"; |
| 264 else | 263 else |
| 265 url = "updates.html"; | 264 url = "updates.html"; |
| 266 browser.tabs.create({url}); | 265 browser.tabs.create({url}); |
| 267 } | 266 } |
| 268 }); | 267 }); |
| 269 } | 268 } |
| 270 } | 269 } |
| 271 | 270 |
| 272 Promise.all([ | 271 Promise.all([ |
| 273 FilterNotifier.once("load"), | 272 FilterNotifier.once("load"), |
| 274 Prefs.untilLoaded.catch(() => { dataCorrupted = true; }) | 273 Prefs.untilLoaded.catch(() => { dataCorrupted = true; }) |
| 275 ]).then(detectFirstRun) | 274 ]).then(detectFirstRun) |
| 276 .then(getSubscriptions) | 275 .then(getSubscriptions) |
| 277 .then(addSubscriptionsAndNotifyUser) | 276 .then(addSubscriptionsAndNotifyUser) |
| 278 .then(setUninstallURL) | 277 // We have to require the "uninstall" module on demand, |
| 278 // as the "uninstall" module in turn requires this module. |
| 279 .then(() => { require("./uninstall").setUninstallURL(); }) |
| 279 .then(initNotifications); | 280 .then(initNotifications); |
| 280 | 281 |
| 281 /** | 282 /** |
| 282 * Gets a value indicating whether the default filter subscriptions have been | 283 * Gets a value indicating whether the default filter subscriptions have been |
| 283 * added again because there weren't any subscriptions even though this wasn't | 284 * added again because there weren't any subscriptions even though this wasn't |
| 284 * the first run. | 285 * the first run. |
| 285 * | 286 * |
| 286 * @return {boolean} | 287 * @return {boolean} |
| 287 */ | 288 */ |
| 288 exports.isReinitialized = () => reinitialized; | 289 exports.isReinitialized = () => reinitialized; |
| 289 | 290 |
| 290 /** | 291 /** |
| 291 * Gets a value indicating whether a data corruption was detected. | 292 * Gets a value indicating whether a data corruption was detected. |
| 292 * | 293 * |
| 293 * @return {boolean} | 294 * @return {boolean} |
| 294 */ | 295 */ |
| 295 exports.isDataCorrupted = () => dataCorrupted; | 296 exports.isDataCorrupted = () => dataCorrupted; |
| 296 | 297 |
| 297 /** | 298 /** |
| 298 * Sets a callback that is called with an array of subscriptions to be added | 299 * Sets a callback that is called with an array of subscriptions to be added |
| 299 * during initialization. The callback must return an array of subscriptions | 300 * during initialization. The callback must return an array of subscriptions |
| 300 * that will effectively be added. | 301 * that will effectively be added. |
| 301 * | 302 * |
| 302 * @param {function} callback | 303 * @param {function} callback |
| 303 */ | 304 */ |
| 304 exports.setSubscriptionsCallback = callback => | 305 exports.setSubscriptionsCallback = callback => |
| 305 { | 306 { |
| 306 subscriptionsCallback = callback; | 307 subscriptionsCallback = callback; |
| 307 }; | 308 }; |
| LEFT | RIGHT |