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-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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 type: messageTypes[type], | 74 type: messageTypes[type], |
75 action: action, | 75 action: action, |
76 args: args | 76 args: args |
77 }); | 77 }); |
78 } | 78 } |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 function onFilterChange(action) | 82 function onFilterChange(action) |
83 { | 83 { |
| 84 var type; |
84 if (action == "load") | 85 if (action == "load") |
85 action = "filter.loaded"; | 86 { |
86 | 87 type = "filter"; |
87 var parts = action.split(".", 2); | 88 action = "loaded"; |
88 var type; | |
89 if (parts.length == 1) | |
90 { | |
91 type = "app"; | |
92 action = parts[0]; | |
93 } | 89 } |
94 else | 90 else |
95 { | 91 { |
| 92 var parts = action.split("."); |
96 type = parts[0]; | 93 type = parts[0]; |
97 action = parts[1]; | 94 action = parts[1]; |
98 } | 95 } |
99 | 96 |
100 if (!messageTypes.hasOwnProperty(type)) | 97 if (!(type in messageTypes)) |
101 return; | 98 return; |
102 | 99 |
103 var args = Array.prototype.slice.call(arguments, 1).map(function(arg) | 100 var args = []; |
104 { | 101 for (var i = 1; i < arguments.length; i++) |
| 102 { |
| 103 var arg = arguments[i]; |
105 if (arg instanceof Subscription) | 104 if (arg instanceof Subscription) |
106 return convertSubscription(arg); | 105 args.push(convertSubscription(arg)); |
107 else if (arg instanceof Filter) | 106 else if (arg instanceof Filter) |
108 return convertFilter(arg); | 107 args.push(convertFilter(arg)); |
109 else | 108 else |
110 return arg; | 109 args.push(arg); |
111 }); | 110 } |
| 111 |
112 sendMessage(type, action, args); | 112 sendMessage(type, action, args); |
113 } | 113 } |
114 | 114 |
115 function getListenerFilters(page) | 115 function getListenerFilters(page) |
116 { | 116 { |
117 var listenerFilters = changeListeners.get(page); | 117 var listenerFilters = changeListeners.get(page); |
118 if (!listenerFilters) | 118 if (!listenerFilters) |
119 { | 119 { |
120 listenerFilters = Object.create(null); | 120 listenerFilters = Object.create(null); |
121 changeListeners.set(page, listenerFilters); | 121 changeListeners.set(page, listenerFilters); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 var subscription = Subscription.fromURL(message.url); | 331 var subscription = Subscription.fromURL(message.url); |
332 if ("title" in message) | 332 if ("title" in message) |
333 subscription.title = message.title; | 333 subscription.title = message.title; |
334 if ("homepage" in message) | 334 if ("homepage" in message) |
335 subscription.homepage = message.homepage; | 335 subscription.homepage = message.homepage; |
336 | 336 |
337 if (message.confirm) | 337 if (message.confirm) |
338 { | 338 { |
339 ext.showOptions(function() | 339 ext.showOptions(function() |
340 { | 340 { |
341 onFilterChange("addSubscription", subscription); | 341 sendMessage("app", "addSubscription", [convertSubscription(subscript
ion)]); |
342 }); | 342 }); |
343 } | 343 } |
344 else | 344 else |
345 { | 345 { |
346 subscription.disabled = false; | 346 subscription.disabled = false; |
347 FilterStorage.addSubscription(subscription); | 347 FilterStorage.addSubscription(subscription); |
348 | 348 |
349 if (subscription instanceof DownloadableSubscription && !subscription.
lastDownload) | 349 if (subscription instanceof DownloadableSubscription && !subscription.
lastDownload) |
350 Synchronizer.execute(subscription); | 350 Synchronizer.execute(subscription); |
351 } | 351 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 if (subscription instanceof DownloadableSubscription) | 410 if (subscription instanceof DownloadableSubscription) |
411 Synchronizer.execute(subscription, true); | 411 Synchronizer.execute(subscription, true); |
412 } | 412 } |
413 break; | 413 break; |
414 case "subscriptions.isDownloading": | 414 case "subscriptions.isDownloading": |
415 callback(Synchronizer.isExecuting(message.url)); | 415 callback(Synchronizer.isExecuting(message.url)); |
416 break; | 416 break; |
417 } | 417 } |
418 }); | 418 }); |
419 })(this); | 419 })(this); |
LEFT | RIGHT |