Left: | ||
Right: |
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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 subscription.disabled = true; | 217 subscription.disabled = true; |
218 FilterStorage.addSubscription(subscription); | 218 FilterStorage.addSubscription(subscription); |
219 if (subscription instanceof DownloadableSubscription && !subscription.last Download) | 219 if (subscription instanceof DownloadableSubscription && !subscription.last Download) |
220 Synchronizer.execute(subscription); | 220 Synchronizer.execute(subscription); |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 if (!addSubscription && !addAcceptable) | 224 if (!addSubscription && !addAcceptable) |
225 return; | 225 return; |
226 | 226 |
227 function notifyUser() | 227 Promise.resolve(addSubscription && fetch("subscriptions.xml") |
228 { | 228 .then(function(response) |
229 if (!Prefs.suppress_first_run_page) | |
230 ext.pages.open(ext.getURL("firstRun.html")); | |
231 } | |
232 | |
233 if (addSubscription) | |
234 { | |
235 // Load subscriptions data | |
236 var request = new XMLHttpRequest(); | |
237 request.open("GET", "subscriptions.xml"); | |
238 request.addEventListener("load", function() | |
239 { | 229 { |
240 var node = Utils.chooseFilterSubscription(request.responseXML.getElementsB yTagName("subscription")); | 230 return response.text(); |
231 }) | |
232 .then(function(text) | |
233 { | |
234 var doc = new DOMParser().parseFromString(text, "application/xml"); | |
235 var node = Utils.chooseFilterSubscription(doc.getElementsByTagName("subscr iption")); | |
kzar
2016/01/17 17:14:06
Nit: While changing mind fixing some of these long
Sebastian Noack
2016/01/19 14:58:10
Done.
| |
241 var subscription = (node ? Subscription.fromURL(node.getAttribute("url")) : null); | 236 var subscription = (node ? Subscription.fromURL(node.getAttribute("url")) : null); |
242 if (subscription) | 237 if (subscription) |
243 { | 238 { |
244 FilterStorage.addSubscription(subscription); | 239 FilterStorage.addSubscription(subscription); |
245 subscription.disabled = false; | 240 subscription.disabled = false; |
246 subscription.title = node.getAttribute("title"); | 241 subscription.title = node.getAttribute("title"); |
247 subscription.homepage = node.getAttribute("homepage"); | 242 subscription.homepage = node.getAttribute("homepage"); |
248 if (subscription instanceof DownloadableSubscription && !subscription.la stDownload) | 243 if (subscription instanceof DownloadableSubscription && !subscription.la stDownload) |
249 Synchronizer.execute(subscription); | 244 Synchronizer.execute(subscription); |
250 | |
251 notifyUser(); | |
252 } | 245 } |
253 }, false); | 246 }) |
254 request.send(null); | 247 ).then(function() |
kzar
2016/01/17 17:14:06
Nit: The indentation of this `.then(...` call seem
Sebastian Noack
2016/01/19 14:58:10
Intending the code above like that:
Promise.res
kzar
2016/01/19 15:39:19
What about doing this here? That way they'd all be
Sebastian Noack
2016/01/19 16:13:25
Note sure if I like it any better, but done.
| |
255 } | 248 { |
256 else | 249 if (!Prefs.suppress_first_run_page) |
kzar
2016/01/17 17:14:06
I think previously we always called `notifyUser()`
Sebastian Noack
2016/01/19 14:58:10
That's not correct. Promise.resolve(addSubscriptio
kzar
2016/01/19 15:39:19
Ah, I see.
| |
257 notifyUser(); | 250 ext.pages.open(ext.getURL("firstRun.html")); |
251 }); | |
258 } | 252 } |
259 | 253 |
260 Prefs.onChanged.addListener(function(name) | 254 Prefs.onChanged.addListener(function(name) |
261 { | 255 { |
262 if (name == "shouldShowBlockElementMenu") | 256 if (name == "shouldShowBlockElementMenu") |
263 refreshIconAndContextMenuForAllPages(); | 257 refreshIconAndContextMenuForAllPages(); |
264 }); | 258 }); |
265 | 259 |
266 // This is a hack to speedup loading of the options page on Safari. | 260 // This is a hack to speedup loading of the options page on Safari. |
267 // Once we replaced the background page proxy with message passing | 261 // Once we replaced the background page proxy with message passing |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 } | 419 } |
426 }); | 420 }); |
427 | 421 |
428 // update icon when page changes location | 422 // update icon when page changes location |
429 ext.pages.onLoading.addListener(function(page) | 423 ext.pages.onLoading.addListener(function(page) |
430 { | 424 { |
431 page.sendMessage({type: "clickhide-deactivate"}); | 425 page.sendMessage({type: "clickhide-deactivate"}); |
432 refreshIconAndContextMenu(page); | 426 refreshIconAndContextMenu(page); |
433 showNextNotificationForUrl(page.url); | 427 showNextNotificationForUrl(page.url); |
434 }); | 428 }); |
OLD | NEW |