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 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 subscriptions = subscriptionsCallback(subscriptions); | 231 subscriptions = subscriptionsCallback(subscriptions); |
232 | 232 |
233 for (let subscription of subscriptions) | 233 for (let subscription of subscriptions) |
234 { | 234 { |
235 FilterStorage.addSubscription(subscription); | 235 FilterStorage.addSubscription(subscription); |
236 if (subscription instanceof DownloadableSubscription && | 236 if (subscription instanceof DownloadableSubscription && |
237 !subscription.lastDownload) | 237 !subscription.lastDownload) |
238 Synchronizer.execute(subscription); | 238 Synchronizer.execute(subscription); |
239 } | 239 } |
240 | 240 |
241 if (!Prefs.suppress_first_run_page) | 241 if (firstRun || info.platform == "chromium" && |
| 242 updatesVersion > Prefs.last_updates_page_displayed) |
242 { | 243 { |
243 let page = null; | 244 Prefs.set("last_updates_page_displayed", updatesVersion).catch(() => |
244 if (firstRun) | |
245 { | 245 { |
246 page = "firstRun.html"; | 246 exports.dataCorrupted = true; |
247 } | 247 }).then(() => |
248 // For now we're limiting the updates page to users of | |
249 // Chromium-based browsers to gage its impact | |
250 else if (info.platform == "chromium" && | |
251 updatesVersion > Prefs.last_updates_page_displayed) | |
252 { | 248 { |
253 page = "updates.html"; | 249 if (!Prefs.suppress_first_run_page) |
254 } | 250 { |
255 | 251 let url; |
256 if (page) | 252 if (firstRun || exports.dataCorrupted) |
257 { | 253 url = "firstRun.html"; |
258 browser.tabs.create({url: browser.extension.getURL(page)}); | 254 else |
259 | 255 url = "updates.html"; |
260 // For new users and users that have already seen this updates page we | 256 browser.tabs.create({url}); |
261 // want to avoid showing it again for subsequent updates. | 257 } |
262 Prefs.last_updates_page_displayed = updatesVersion; | 258 }); |
263 } | |
264 } | 259 } |
265 | 260 |
266 initNotifications(); | 261 initNotifications(); |
267 } | 262 } |
268 | 263 |
269 Promise.all([FilterNotifier.once("load"), | 264 Promise.all([ |
270 Prefs.untilLoaded]).then(detectFirstRun) | 265 FilterNotifier.once("load"), |
271 .then(getSubscriptions) | 266 Prefs.untilLoaded.catch(() => { exports.dataCorrupted = true; }) |
272 .then(finishInitialization); | 267 ]).then(detectFirstRun) |
| 268 .then(getSubscriptions) |
| 269 .then(finishInitialization); |
273 | 270 |
274 /** | 271 /** |
275 * Indicates whether the default filter subscriptions have been added | 272 * Indicates whether the default filter subscriptions have been added |
276 * again because there weren't any subscriptions even though this wasn't | 273 * again because there weren't any subscriptions even though this wasn't |
277 * the first run. | 274 * the first run. |
278 * | 275 * |
279 * @type {boolean} | 276 * @type {boolean} |
280 */ | 277 */ |
281 exports.reinitialized = false; | 278 exports.reinitialized = false; |
282 | 279 |
283 /** | 280 /** |
| 281 * Indicates whether a data corruption was detcted. |
| 282 * |
| 283 * @type {boolean} |
| 284 */ |
| 285 exports.dataCorrupted = false; |
| 286 |
| 287 /** |
284 * Sets a callback that is called with an array of subscriptions to be added | 288 * Sets a callback that is called with an array of subscriptions to be added |
285 * during initialization. The callback must return an array of subscriptions | 289 * during initialization. The callback must return an array of subscriptions |
286 * that will effectively be added. | 290 * that will effectively be added. |
287 * | 291 * |
288 * @param {function} callback | 292 * @param {function} callback |
289 */ | 293 */ |
290 exports.setSubscriptionsCallback = callback => | 294 exports.setSubscriptionsCallback = callback => |
291 { | 295 { |
292 subscriptionsCallback = callback; | 296 subscriptionsCallback = callback; |
293 }; | 297 }; |
OLD | NEW |