| 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 function convertObject(keys, obj) | 41 function convertObject(keys, obj) |
| 42 { | 42 { |
| 43 var result = {}; | 43 var result = {}; |
| 44 for (var i = 0; i < keys.length; i++) | 44 for (var i = 0; i < keys.length; i++) |
| 45 result[keys[i]] = obj[keys[i]]; | 45 result[keys[i]] = obj[keys[i]]; |
| 46 return result; | 46 return result; |
| 47 } | 47 } |
| 48 | 48 |
| 49 var convertSubscription = convertObject.bind(null, ["disabled", | 49 var convertSubscription = convertObject.bind(null, ["disabled", |
| 50 "downloadStatus", "homepage", "lastSuccess", "title", "url"]); | 50 "downloadStatus", "homepage", "lastDownload", "title", "url"]); |
| 51 var convertFilter = convertObject.bind(null, ["text"]); | 51 var convertFilter = convertObject.bind(null, ["text"]); |
| 52 | 52 |
| 53 var changeListeners = null; | 53 var changeListeners = null; |
| 54 var messageTypes = { | 54 var messageTypes = { |
| 55 "app": "app.listen", | 55 "app": "app.listen", |
| 56 "filter": "filters.listen", | 56 "filter": "filters.listen", |
| 57 "subscription": "subscriptions.listen" | 57 "subscription": "subscriptions.listen" |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 function sendMessage(type, action, args, page) | 60 function sendMessage(type, action, args, page) |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 else | 326 else |
| 327 delete listenerFilters.subscription; | 327 delete listenerFilters.subscription; |
| 328 break; | 328 break; |
| 329 case "subscriptions.remove": | 329 case "subscriptions.remove": |
| 330 var subscription = Subscription.fromURL(message.url); | 330 var subscription = Subscription.fromURL(message.url); |
| 331 if (subscription.url in FilterStorage.knownSubscriptions) | 331 if (subscription.url in FilterStorage.knownSubscriptions) |
| 332 FilterStorage.removeSubscription(subscription); | 332 FilterStorage.removeSubscription(subscription); |
| 333 break; | 333 break; |
| 334 case "subscriptions.toggle": | 334 case "subscriptions.toggle": |
| 335 var subscription = Subscription.fromURL(message.url); | 335 var subscription = Subscription.fromURL(message.url); |
| 336 if (subscription.url in FilterStorage.knownSubscriptions && !subscriptio
n.disabled) | 336 if (subscription.url in FilterStorage.knownSubscriptions) |
| 337 FilterStorage.removeSubscription(subscription); | 337 { |
| 338 if (subscription.disabled || message.keepInstalled) |
| 339 { |
| 340 subscription.disabled = !subscription.disabled; |
| 341 FilterNotifier.triggerListeners("subscription.disabled", |
| 342 subscription); |
| 343 } |
| 344 else |
| 345 FilterStorage.removeSubscription(subscription); |
| 346 } |
| 338 else | 347 else |
| 339 { | 348 { |
| 340 subscription.disabled = false; | 349 subscription.disabled = false; |
| 341 subscription.title = message.title; | 350 subscription.title = message.title; |
| 342 subscription.homepage = message.homepage; | 351 subscription.homepage = message.homepage; |
| 343 FilterStorage.addSubscription(subscription); | 352 FilterStorage.addSubscription(subscription); |
| 344 if (!subscription.lastDownload) | 353 if (!subscription.lastDownload) |
| 345 Synchronizer.execute(subscription); | 354 Synchronizer.execute(subscription); |
| 346 } | 355 } |
| 347 break; | 356 break; |
| 357 case "subscriptions.update": |
| 358 var subscriptions = message.url ? [Subscription.fromURL(message.url)] : |
| 359 FilterStorage.subscriptions; |
| 360 for (var i = 0; i < subscriptions.length; i++) |
| 361 { |
| 362 var subscription = subscriptions[i]; |
| 363 if (subscription instanceof DownloadableSubscription) |
| 364 Synchronizer.execute(subscription, true); |
| 365 } |
| 366 break; |
| 348 } | 367 } |
| 349 }); | 368 }); |
| 350 })(this); | 369 })(this); |
| OLD | NEW |