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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 if (!listenerFilters) | 125 if (!listenerFilters) |
126 { | 126 { |
127 listenerFilters = Object.create(null); | 127 listenerFilters = Object.create(null); |
128 changeListeners.set(sender.page, listenerFilters); | 128 changeListeners.set(sender.page, listenerFilters); |
129 } | 129 } |
130 break; | 130 break; |
131 } | 131 } |
132 | 132 |
133 switch (message.type) | 133 switch (message.type) |
134 { | 134 { |
135 case "add-subscription": | |
136 ext.showOptions(function() | |
137 { | |
138 var subscription = Subscription.fromURL(message.url); | |
139 subscription.title = message.title; | |
140 onFilterChange("addSubscription", subscription); | |
141 }); | |
142 break; | |
143 case "app.get": | 135 case "app.get": |
144 if (message.what == "issues") | 136 if (message.what == "issues") |
145 { | 137 { |
146 var subscriptionInit; | 138 var subscriptionInit; |
147 try | 139 try |
148 { | 140 { |
149 subscriptionInit = require("subscriptionInit"); | 141 subscriptionInit = require("subscriptionInit"); |
150 } | 142 } |
151 catch (e) | 143 catch (e) |
152 { | 144 { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 | 284 |
293 if (!subscription) | 285 if (!subscription) |
294 FilterStorage.removeFilter(filter); | 286 FilterStorage.removeFilter(filter); |
295 else | 287 else |
296 FilterStorage.removeFilter(filter, subscription, message.index); | 288 FilterStorage.removeFilter(filter, subscription, message.index); |
297 break; | 289 break; |
298 case "prefs.get": | 290 case "prefs.get": |
299 callback(Prefs[message.key]); | 291 callback(Prefs[message.key]); |
300 break; | 292 break; |
301 case "subscriptions.add": | 293 case "subscriptions.add": |
302 if (message.url in FilterStorage.knownSubscriptions) | |
Sebastian Noack
2016/03/17 21:41:17
This check seems like a bug to me. If I understand
Thomas Greiner
2016/03/18 10:48:20
No, you're probably thinking about `Filter.knownFi
Sebastian Noack
2016/03/18 11:35:07
You're right. However, FilterStorage.addSubscripti
Thomas Greiner
2016/03/18 13:20:39
I see what you mean. Seems to be more of a design
| |
303 return; | |
304 | |
305 var subscription = Subscription.fromURL(message.url); | 294 var subscription = Subscription.fromURL(message.url); |
306 if (!subscription) | |
Sebastian Noack
2016/03/17 21:41:17
Subscription.fromURL() never returns null or simil
Thomas Greiner
2016/03/18 10:48:20
You're right, nice catch.
| |
307 return; | |
308 | |
309 subscription.disabled = false; | |
310 if ("title" in message) | 295 if ("title" in message) |
311 subscription.title = message.title; | 296 subscription.title = message.title; |
312 if ("homepage" in message) | 297 if ("homepage" in message) |
313 subscription.homepage = message.homepage; | 298 subscription.homepage = message.homepage; |
314 FilterStorage.addSubscription(subscription); | |
315 | 299 |
316 if (subscription instanceof DownloadableSubscription && !subscription.la stDownload) | 300 if (message.ask) |
Thomas Greiner
2016/03/18 10:48:20
Detail: Just a personal preference but what do you
Sebastian Noack
2016/03/18 11:35:07
Fine with me.
| |
317 Synchronizer.execute(subscription); | 301 { |
302 ext.showOptions(onFilterChange.bind(null, "addSubscription", subscript ion)); | |
Thomas Greiner
2016/03/18 10:48:20
Coding style: Mind the maximum line length.
Sebastian Noack
2016/03/18 11:35:07
Done.
| |
303 } | |
304 else | |
305 { | |
306 subscription.disabled = false; | |
307 FilterStorage.addSubscription(subscription); | |
308 | |
309 if (subscription instanceof DownloadableSubscription && !subscription. lastDownload) | |
310 Synchronizer.execute(subscription); | |
311 } | |
318 break; | 312 break; |
319 case "subscriptions.get": | 313 case "subscriptions.get": |
320 var subscriptions = FilterStorage.subscriptions.filter(function(s) | 314 var subscriptions = FilterStorage.subscriptions.filter(function(s) |
321 { | 315 { |
322 if (message.ignoreDisabled && s.disabled) | 316 if (message.ignoreDisabled && s.disabled) |
323 return false; | 317 return false; |
324 if (s instanceof DownloadableSubscription && message.downloadable) | 318 if (s instanceof DownloadableSubscription && message.downloadable) |
325 return true; | 319 return true; |
326 if (s instanceof SpecialSubscription && message.special) | 320 if (s instanceof SpecialSubscription && message.special) |
327 return true; | 321 return true; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 if (subscription instanceof DownloadableSubscription) | 366 if (subscription instanceof DownloadableSubscription) |
373 Synchronizer.execute(subscription, true); | 367 Synchronizer.execute(subscription, true); |
374 } | 368 } |
375 break; | 369 break; |
376 case "subscriptions.isDownloading": | 370 case "subscriptions.isDownloading": |
377 callback(Synchronizer.isExecuting(message.url)); | 371 callback(Synchronizer.isExecuting(message.url)); |
378 break; | 372 break; |
379 } | 373 } |
380 }); | 374 }); |
381 })(this); | 375 })(this); |
OLD | NEW |