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

Side by Side Diff: lib/subscriptionInit.js

Issue 29715577: Issue 6449 - Switch to Harmony modules (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created March 6, 2018, 10:20 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 subscriptionInit */ 18 /** @module subscriptionInit */
19 19
20 "use strict";
21
22 const {Subscription, DownloadableSubscription, 20 const {Subscription, DownloadableSubscription,
23 SpecialSubscription} = require("subscriptionClasses"); 21 SpecialSubscription} = require("subscriptionClasses");
24 const {FilterStorage} = require("filterStorage"); 22 const {FilterStorage} = require("filterStorage");
25 const {FilterNotifier} = require("filterNotifier"); 23 const {FilterNotifier} = require("filterNotifier");
26 const info = require("info"); 24 const info = require("info");
27 const {Prefs} = require("prefs"); 25 const {Prefs} = require("prefs");
28 const {Synchronizer} = require("synchronizer"); 26 const {Synchronizer} = require("synchronizer");
29 const {Utils} = require("utils"); 27 const {Utils} = require("utils");
30 const {initNotifications} = require("notificationHelper"); 28 const {initNotifications} = require("notificationHelper");
31 const {updatesVersion} = require("../adblockplusui/lib/prefs"); 29 const {updatesVersion} = require("../adblockplusui/lib/prefs");
32 30
33 let firstRun; 31 let firstRun;
34 let subscriptionsCallback = null; 32 let subscriptionsCallback = null;
35 33
36 /** 34 /**
37 * If there aren't any filters, the default subscriptions are added. 35 * If there aren't any filters, the default subscriptions are added.
38 * However, if patterns.ini already did exist and/or any preference 36 * However, if patterns.ini already did exist and/or any preference
39 * is set to a non-default value, this indicates that this isn't the 37 * is set to a non-default value, this indicates that this isn't the
40 * first run, but something went wrong. 38 * first run, but something went wrong.
41 * 39 *
42 * This function detects the first run, and makes sure that the user 40 * This function detects the first run, and makes sure that the user
43 * gets notified (on the first run page) if the data appears incomplete 41 * gets notified (on the first run page) if the data appears incomplete
44 * and therefore will be reinitialized. 42 * and therefore will be reinitialized.
45 */ 43 */
46 function detectFirstRun() 44 function detectFirstRun()
47 { 45 {
48 firstRun = FilterStorage.subscriptions.length == 0; 46 firstRun = FilterStorage.subscriptions.length == 0;
49 47
50 if (firstRun && (!FilterStorage.firstRun || Prefs.currentVersion)) 48 if (firstRun && (!FilterStorage.firstRun || Prefs.currentVersion))
51 exports.reinitialized = true; 49 reinitialized = true;
52 50
53 Prefs.currentVersion = info.addonVersion; 51 Prefs.currentVersion = info.addonVersion;
54 } 52 }
55 53
56 /** 54 /**
57 * Determines whether to add the default ad blocking subscription. 55 * Determines whether to add the default ad blocking subscription.
58 * Returns true, if there are no filter subscriptions besides those 56 * Returns true, if there are no filter subscriptions besides those
59 * other subscriptions added automatically, and no custom filters. 57 * other subscriptions added automatically, and no custom filters.
60 * 58 *
61 * On first run, this logic should always result in true since there 59 * On first run, this logic should always result in true since there
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 .then(getSubscriptions) 237 .then(getSubscriptions)
240 .then(finishInitialization); 238 .then(finishInitialization);
241 239
242 /** 240 /**
243 * Indicates whether the default filter subscriptions have been added 241 * Indicates whether the default filter subscriptions have been added
244 * again because there weren't any subscriptions even though this wasn't 242 * again because there weren't any subscriptions even though this wasn't
245 * the first run. 243 * the first run.
246 * 244 *
247 * @type {boolean} 245 * @type {boolean}
248 */ 246 */
249 exports.reinitialized = false; 247 export let reinitialized = false;
Manish Jethani 2018/03/06 10:29:06 webpack generates the correct binding for this so
250 248
251 /** 249 /**
252 * Sets a callback that is called with an array of subscriptions to be added 250 * Sets a callback that is called with an array of subscriptions to be added
253 * during initialization. The callback must return an array of subscriptions 251 * during initialization. The callback must return an array of subscriptions
254 * that will effectively be added. 252 * that will effectively be added.
255 * 253 *
256 * @param {function} callback 254 * @param {function} callback
257 */ 255 */
258 exports.setSubscriptionsCallback = callback => 256 export const setSubscriptionsCallback = callback =>
259 { 257 {
260 subscriptionsCallback = callback; 258 subscriptionsCallback = callback;
261 }; 259 };
OLDNEW
« lib/messaging.js ('K') | « lib/stats.js ('k') | lib/tldjs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld