| 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-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 12 matching lines...) Expand all Loading... |
| 23 var Prefs = require("prefs").Prefs; | 23 var Prefs = require("prefs").Prefs; |
| 24 var Utils = require("utils").Utils; | 24 var Utils = require("utils").Utils; |
| 25 var FilterStorage = require("filterStorage").FilterStorage; | 25 var FilterStorage = require("filterStorage").FilterStorage; |
| 26 var FilterNotifier = require("filterNotifier").FilterNotifier; | 26 var FilterNotifier = require("filterNotifier").FilterNotifier; |
| 27 var defaultMatcher = require("matcher").defaultMatcher; | 27 var defaultMatcher = require("matcher").defaultMatcher; |
| 28 | 28 |
| 29 var filterClasses = require("filterClasses"); | 29 var filterClasses = require("filterClasses"); |
| 30 var Filter = filterClasses.Filter; | 30 var Filter = filterClasses.Filter; |
| 31 var BlockingFilter = filterClasses.BlockingFilter; | 31 var BlockingFilter = filterClasses.BlockingFilter; |
| 32 var Synchronizer = require("synchronizer").Synchronizer; | 32 var Synchronizer = require("synchronizer").Synchronizer; |
| 33 var filterValidation = require("filterValidation"); | |
| 34 | 33 |
| 35 var subscriptionClasses = require("subscriptionClasses"); | 34 var subscriptionClasses = require("subscriptionClasses"); |
| 36 var Subscription = subscriptionClasses.Subscription; | 35 var Subscription = subscriptionClasses.Subscription; |
| 37 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; | 36 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; |
| 38 var SpecialSubscription = subscriptionClasses.SpecialSubscription; | 37 var SpecialSubscription = subscriptionClasses.SpecialSubscription; |
| 39 | 38 |
| 40 function convertObject(keys, obj) | 39 function convertObject(keys, obj) |
| 41 { | 40 { |
| 42 var result = {}; | 41 var result = {}; |
| 43 for (var i = 0; i < keys.length; i++) | 42 for (var i = 0; i < keys.length; i++) |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 listenerFilters.app = message.filter; | 175 listenerFilters.app = message.filter; |
| 177 else | 176 else |
| 178 delete listenerFilters.app; | 177 delete listenerFilters.app; |
| 179 break; | 178 break; |
| 180 case "app.open": | 179 case "app.open": |
| 181 if (message.what == "options") | 180 if (message.what == "options") |
| 182 ext.showOptions(); | 181 ext.showOptions(); |
| 183 break; | 182 break; |
| 184 case "filters.add": | 183 case "filters.add": |
| 185 var filter = Filter.fromText(message.text); | 184 var filter = Filter.fromText(message.text); |
| 186 var result = filterValidation.parseFilter(message.text); | 185 var result = require("filterValidation").parseFilter(message.text); |
| 187 if (result.error) | 186 if (result.error) |
| 188 sendMessage("app", "error", [result.error.toString()], sender.page); | 187 sendMessage("app", "error", [result.error.toString()], sender.page); |
| 189 else if (result.filter) | 188 else if (result.filter) |
| 190 FilterStorage.addFilter(result.filter); | 189 FilterStorage.addFilter(result.filter); |
| 191 break; | 190 break; |
| 192 case "filters.blocked": | 191 case "filters.blocked": |
| 193 var filter = defaultMatcher.matchesAny(message.url, message.requestType, | 192 var filter = defaultMatcher.matchesAny(message.url, message.requestType, |
| 194 message.docDomain, message.thirdParty); | 193 message.docDomain, message.thirdParty); |
| 195 callback(filter instanceof BlockingFilter); | 194 callback(filter instanceof BlockingFilter); |
| 196 break; | 195 break; |
| 197 case "filters.get": | 196 case "filters.get": |
| 198 var subscription = Subscription.fromURL(message.subscriptionUrl); | 197 var subscription = Subscription.fromURL(message.subscriptionUrl); |
| 199 if (!subscription) | 198 if (!subscription) |
| 200 { | 199 { |
| 201 callback([]); | 200 callback([]); |
| 202 break; | 201 break; |
| 203 } | 202 } |
| 204 | 203 |
| 205 callback(subscription.filters.map(convertFilter)); | 204 callback(subscription.filters.map(convertFilter)); |
| 206 break; | 205 break; |
| 207 case "filters.importRaw": | 206 case "filters.importRaw": |
| 208 var result = filterValidation.parseFilters(message.text); | 207 var result = require("filterValidation").parseFilters(message.text); |
| 209 var errors = []; | 208 var errors = []; |
| 210 for (var i = 0; i < result.errors.length; i++) | 209 for (var i = 0; i < result.errors.length; i++) |
| 211 { | 210 { |
| 212 var error = result.errors[i]; | 211 var error = result.errors[i]; |
| 213 if (error.type != "unexpected-filter-list-header") | 212 if (error.type != "unexpected-filter-list-header") |
| 214 errors.push(error.toString()); | 213 errors.push(error.toString()); |
| 215 } | 214 } |
| 216 | 215 |
| 217 if (errors.length > 0) | 216 if (errors.length > 0) |
| 218 { | 217 { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 subscription.title = message.title; | 316 subscription.title = message.title; |
| 318 subscription.homepage = message.homepage; | 317 subscription.homepage = message.homepage; |
| 319 FilterStorage.addSubscription(subscription); | 318 FilterStorage.addSubscription(subscription); |
| 320 if (!subscription.lastDownload) | 319 if (!subscription.lastDownload) |
| 321 Synchronizer.execute(subscription); | 320 Synchronizer.execute(subscription); |
| 322 } | 321 } |
| 323 break; | 322 break; |
| 324 } | 323 } |
| 325 }); | 324 }); |
| 326 })(this); | 325 })(this); |
| OLD | NEW |