| Left: | ||
| Right: |
| 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-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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 return; | 225 return; |
| 226 | 226 |
| 227 Promise.resolve(addSubscription && fetch("subscriptions.xml") | 227 Promise.resolve(addSubscription && fetch("subscriptions.xml") |
| 228 .then(function(response) | 228 .then(function(response) |
| 229 { | 229 { |
| 230 return response.text(); | 230 return response.text(); |
| 231 }) | 231 }) |
| 232 .then(function(text) | 232 .then(function(text) |
| 233 { | 233 { |
| 234 var doc = new DOMParser().parseFromString(text, "application/xml"); | 234 var doc = new DOMParser().parseFromString(text, "application/xml"); |
| 235 var node = Utils.chooseFilterSubscription(doc.getElementsByTagName("subscr iption")); | 235 var nodes = doc.getElementsByTagName("subscription"); |
|
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.
| |
| 236 var subscription = (node ? Subscription.fromURL(node.getAttribute("url")) : null); | 236 var node = Utils.chooseFilterSubscription(nodes); |
| 237 var subscription = node && Subscription.fromURL(node.getAttribute("url")); | |
| 238 | |
| 237 if (subscription) | 239 if (subscription) |
| 238 { | 240 { |
| 239 FilterStorage.addSubscription(subscription); | 241 FilterStorage.addSubscription(subscription); |
| 242 | |
| 240 subscription.disabled = false; | 243 subscription.disabled = false; |
| 241 subscription.title = node.getAttribute("title"); | 244 subscription.title = node.getAttribute("title"); |
| 242 subscription.homepage = node.getAttribute("homepage"); | 245 subscription.homepage = node.getAttribute("homepage"); |
| 243 if (subscription instanceof DownloadableSubscription && !subscription.la stDownload) | 246 |
| 247 if (subscription instanceof DownloadableSubscription && | |
| 248 !subscription.lastDownload) | |
| 244 Synchronizer.execute(subscription); | 249 Synchronizer.execute(subscription); |
| 245 } | 250 } |
| 246 }) | 251 }) |
| 247 ).then(function() | 252 ) |
|
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.
| |
| 253 .then(function() | |
| 248 { | 254 { |
| 249 if (!Prefs.suppress_first_run_page) | 255 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.
| |
| 250 ext.pages.open(ext.getURL("firstRun.html")); | 256 ext.pages.open(ext.getURL("firstRun.html")); |
| 251 }); | 257 }); |
| 252 } | 258 } |
| 253 | 259 |
| 254 Prefs.onChanged.addListener(function(name) | 260 Prefs.onChanged.addListener(function(name) |
| 255 { | 261 { |
| 256 if (name == "shouldShowBlockElementMenu") | 262 if (name == "shouldShowBlockElementMenu") |
| 257 refreshIconAndContextMenuForAllPages(); | 263 refreshIconAndContextMenuForAllPages(); |
| 258 }); | 264 }); |
| 259 | 265 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 { | 376 { |
| 371 sendResponse({status: "invalid", error: result.errors.join("\n")}); | 377 sendResponse({status: "invalid", error: result.errors.join("\n")}); |
| 372 break; | 378 break; |
| 373 } | 379 } |
| 374 | 380 |
| 375 for (var i = 0; i < result.filters.length; i++) | 381 for (var i = 0; i < result.filters.length; i++) |
| 376 FilterStorage.addFilter(result.filters[i]); | 382 FilterStorage.addFilter(result.filters[i]); |
| 377 | 383 |
| 378 sendResponse({status: "ok"}); | 384 sendResponse({status: "ok"}); |
| 379 break; | 385 break; |
| 380 case "add-subscription": | |
| 381 ext.showOptions(function(page) | |
| 382 { | |
| 383 page.sendMessage(msg); | |
| 384 }); | |
| 385 break; | |
| 386 case "add-sitekey": | 386 case "add-sitekey": |
| 387 processKey(msg.token, sender.page, sender.frame); | 387 processKey(msg.token, sender.page, sender.frame); |
| 388 break; | 388 break; |
| 389 case "report-html-page": | 389 case "report-html-page": |
| 390 htmlPages.set(sender.page, null); | 390 htmlPages.set(sender.page, null); |
| 391 refreshIconAndContextMenu(sender.page); | 391 refreshIconAndContextMenu(sender.page); |
| 392 break; | 392 break; |
| 393 case "compose-filters": | 393 case "compose-filters": |
| 394 sendResponse(composeFilters({ | 394 sendResponse(composeFilters({ |
| 395 tagName: msg.tagName, | 395 tagName: msg.tagName, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 419 } | 419 } |
| 420 }); | 420 }); |
| 421 | 421 |
| 422 // update icon when page changes location | 422 // update icon when page changes location |
| 423 ext.pages.onLoading.addListener(function(page) | 423 ext.pages.onLoading.addListener(function(page) |
| 424 { | 424 { |
| 425 page.sendMessage({type: "clickhide-deactivate"}); | 425 page.sendMessage({type: "clickhide-deactivate"}); |
| 426 refreshIconAndContextMenu(page); | 426 refreshIconAndContextMenu(page); |
| 427 showNextNotificationForUrl(page.url); | 427 showNextNotificationForUrl(page.url); |
| 428 }); | 428 }); |
| LEFT | RIGHT |