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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 listenerFilters.app = message.filter; | 177 listenerFilters.app = message.filter; |
178 else | 178 else |
179 delete listenerFilters.app; | 179 delete listenerFilters.app; |
180 break; | 180 break; |
181 case "app.open": | 181 case "app.open": |
182 if (message.what == "options") | 182 if (message.what == "options") |
183 ext.showOptions(); | 183 ext.showOptions(); |
184 break; | 184 break; |
185 case "filters.add": | 185 case "filters.add": |
186 var result = require("filterValidation").parseFilter(message.text); | 186 var result = require("filterValidation").parseFilter(message.text); |
| 187 var errors = []; |
187 if (result.error) | 188 if (result.error) |
188 sendMessage("app", "error", [result.error.toString()], sender.page); | 189 errors.push(result.error.toString()); |
189 else if (result.filter) | 190 else if (result.filter) |
190 FilterStorage.addFilter(result.filter); | 191 FilterStorage.addFilter(result.filter); |
| 192 callback(errors); |
191 break; | 193 break; |
192 case "filters.blocked": | 194 case "filters.blocked": |
193 var filter = defaultMatcher.matchesAny(message.url, message.requestType, | 195 var filter = defaultMatcher.matchesAny(message.url, message.requestType, |
194 message.docDomain, message.thirdParty); | 196 message.docDomain, message.thirdParty); |
195 callback(filter instanceof BlockingFilter); | 197 callback(filter instanceof BlockingFilter); |
196 break; | 198 break; |
197 case "filters.get": | 199 case "filters.get": |
198 if (message.what == "cssproperties") | 200 if (message.what == "cssproperties") |
199 { | 201 { |
200 var filters = []; | 202 var filters = []; |
(...skipping 29 matching lines...) Expand all Loading... |
230 case "filters.importRaw": | 232 case "filters.importRaw": |
231 var result = require("filterValidation").parseFilters(message.text); | 233 var result = require("filterValidation").parseFilters(message.text); |
232 var errors = []; | 234 var errors = []; |
233 for (var i = 0; i < result.errors.length; i++) | 235 for (var i = 0; i < result.errors.length; i++) |
234 { | 236 { |
235 var error = result.errors[i]; | 237 var error = result.errors[i]; |
236 if (error.type != "unexpected-filter-list-header") | 238 if (error.type != "unexpected-filter-list-header") |
237 errors.push(error.toString()); | 239 errors.push(error.toString()); |
238 } | 240 } |
239 | 241 |
| 242 callback(errors); |
240 if (errors.length > 0) | 243 if (errors.length > 0) |
241 { | |
242 sendMessage("app", "error", errors, sender.page); | |
243 return; | 244 return; |
244 } | |
245 | 245 |
246 var seenFilter = Object.create(null); | 246 var seenFilter = Object.create(null); |
247 for (var i = 0; i < result.filters.length; i++) | 247 for (var i = 0; i < result.filters.length; i++) |
248 { | 248 { |
249 var filter = result.filters[i]; | 249 var filter = result.filters[i]; |
250 FilterStorage.addFilter(filter); | 250 FilterStorage.addFilter(filter); |
251 seenFilter[filter.text] = null; | 251 seenFilter[filter.text] = null; |
252 } | 252 } |
253 | 253 |
254 for (var i = 0; i < FilterStorage.subscriptions.length; i++) | 254 for (var i = 0; i < FilterStorage.subscriptions.length; i++) |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 if (subscription instanceof DownloadableSubscription) | 362 if (subscription instanceof DownloadableSubscription) |
363 Synchronizer.execute(subscription, true); | 363 Synchronizer.execute(subscription, true); |
364 } | 364 } |
365 break; | 365 break; |
366 case "subscriptions.isDownloading": | 366 case "subscriptions.isDownloading": |
367 callback(Synchronizer.isExecuting(message.url)); | 367 callback(Synchronizer.isExecuting(message.url)); |
368 break; | 368 break; |
369 } | 369 } |
370 }); | 370 }); |
371 })(this); | 371 })(this); |
OLD | NEW |