| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 request.send(); | 87 request.send(); |
| 88 return request.responseText; | 88 return request.responseText; |
| 89 }, | 89 }, |
| 90 isSubscriptionListed: function(url) | 90 isSubscriptionListed: function(url) |
| 91 { | 91 { |
| 92 return url in FilterStorage.knownSubscriptions; | 92 return url in FilterStorage.knownSubscriptions; |
| 93 }, | 93 }, |
| 94 addSubscription: function(url, title) | 94 addSubscription: function(url, title) |
| 95 { | 95 { |
| 96 let subscription = Subscription.fromURL(url); | 96 let subscription = Subscription.fromURL(url); |
| 97 subscription.title = title; | 97 if (title) |
| 98 subscription.title = title; |
| 98 FilterStorage.addSubscription(subscription); | 99 FilterStorage.addSubscription(subscription); |
| 99 if (!subscription.lastDownload) | 100 if (!subscription.lastDownload) |
| 100 { | 101 { |
| 101 Synchronizer.execute(subscription); | 102 Synchronizer.execute(subscription); |
| 102 } | 103 } |
| 103 }, | 104 }, |
| 104 removeSubscription: function(url) | 105 removeSubscription: function(url) |
| 105 { | 106 { |
| 106 FilterStorage.removeSubscription( | 107 FilterStorage.removeSubscription( |
| 107 FilterStorage.knownSubscriptions[url]); | 108 FilterStorage.knownSubscriptions[url]); |
| 108 }, | 109 }, |
| 110 getActiveSubscriptions: function() |
| 111 { |
| 112 let subscriptions = []; |
| 113 for (let i = 0; i < FilterStorage.subscriptions.length; i++) |
| 114 { |
| 115 let subscription = FilterStorage.subscriptions[i]; |
| 116 subscriptions.push({"title": subscription.title, "url": subscription.url})
; |
| 117 } |
| 118 return subscriptions; |
| 119 }, |
| 109 isLocal: function(url) | 120 isLocal: function(url) |
| 110 { | 121 { |
| 111 let uriObject = Services.io.newURI(url, null, null); | 122 let uriObject = Services.io.newURI(url, null, null); |
| 112 return !uriObject.schemeIs("http") && !uriObject.schemeIs("https"); | 123 return !uriObject.schemeIs("http") && !uriObject.schemeIs("https"); |
| 113 }, | 124 }, |
| 114 isPageWhitelisted: function(url) | 125 isPageWhitelisted: function(url) |
| 115 { | 126 { |
| 116 return AdblockPlusApi.isLocal(url) || !!getWhitelistingFilter(url); | 127 return AdblockPlusApi.isLocal(url) || !!getWhitelistingFilter(url); |
| 117 }, | 128 }, |
| 118 whitelistSite: function(url, whitelisted) | 129 whitelistSite: function(url, whitelisted) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 return {"success": true, "value": this.acceptableAdsEnabled}; | 173 return {"success": true, "value": this.acceptableAdsEnabled}; |
| 163 case "setAcceptableAdsEnabled": | 174 case "setAcceptableAdsEnabled": |
| 164 if ("enable" in data) | 175 if ("enable" in data) |
| 165 { | 176 { |
| 166 this.acceptableAdsEnabled = !!data["enable"]; | 177 this.acceptableAdsEnabled = !!data["enable"]; |
| 167 return {"success": true}; | 178 return {"success": true}; |
| 168 } | 179 } |
| 169 break; | 180 break; |
| 170 case "getSubscriptionsXml": | 181 case "getSubscriptionsXml": |
| 171 return {"success": true, "value": this.subscriptionsXml}; | 182 return {"success": true, "value": this.subscriptionsXml}; |
| 183 case "getActiveSubscriptions": |
| 184 return {"success": true, "value": this.getActiveSubscriptions()}; |
| 172 case "isSubscriptionListed": | 185 case "isSubscriptionListed": |
| 173 if ("url" in data) | 186 if ("url" in data) |
| 174 { | 187 { |
| 175 return {"success": true, | 188 return {"success": true, |
| 176 "value": this.isSubscriptionListed(data["url"])}; | 189 "value": this.isSubscriptionListed(data["url"])}; |
| 177 } | 190 } |
| 178 break; | 191 break; |
| 179 case "addSubscription": | 192 case "addSubscription": |
| 180 if ("url" in data && "title" in data) | 193 if ("url" in data) |
| 181 { | 194 { |
| 182 this.addSubscription(data["url"], data["title"]); | 195 this.addSubscription(data["url"], data["title"]); |
| 183 return {"success": true}; | 196 return {"success": true}; |
| 184 } | 197 } |
| 185 break; | 198 break; |
| 186 case "removeSubscription": | 199 case "removeSubscription": |
| 187 if ("url" in data) | 200 if ("url" in data) |
| 188 { | 201 { |
| 189 this.removeSubscription(data["url"]); | 202 this.removeSubscription(data["url"]); |
| 190 return {"success": true}; | 203 return {"success": true}; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 205 { | 218 { |
| 206 this.whitelistSite(data["url"], data["whitelisted"]); | 219 this.whitelistSite(data["url"], data["whitelisted"]); |
| 207 return {"success": true}; | 220 return {"success": true}; |
| 208 } | 221 } |
| 209 break; | 222 break; |
| 210 } | 223 } |
| 211 return {"success": false, "error": "malformed request"}; | 224 return {"success": false, "error": "malformed request"}; |
| 212 }).bind(this), "AdblockPlus:Api"); | 225 }).bind(this), "AdblockPlus:Api"); |
| 213 } | 226 } |
| 214 }; | 227 }; |
| OLD | NEW |