| 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 22 matching lines...) Expand all Loading... |
| 33 var BlockingFilter = filterClasses.BlockingFilter; | 33 var BlockingFilter = filterClasses.BlockingFilter; |
| 34 var RegExpFilter = filterClasses.RegExpFilter; | 34 var RegExpFilter = filterClasses.RegExpFilter; |
| 35 var Synchronizer = require("synchronizer").Synchronizer; | 35 var Synchronizer = require("synchronizer").Synchronizer; |
| 36 | 36 |
| 37 var info = require("info"); | 37 var info = require("info"); |
| 38 var subscriptionClasses = require("subscriptionClasses"); | 38 var subscriptionClasses = require("subscriptionClasses"); |
| 39 var Subscription = subscriptionClasses.Subscription; | 39 var Subscription = subscriptionClasses.Subscription; |
| 40 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; | 40 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; |
| 41 var SpecialSubscription = subscriptionClasses.SpecialSubscription; | 41 var SpecialSubscription = subscriptionClasses.SpecialSubscription; |
| 42 | 42 |
| 43 // Some modules doesn't exist on Firefox. Moreover, |
| 44 // require() throws an exception on Firefox in that case. |
| 45 // However, try/catch causes the whole function to to be |
| 46 // deoptimized on V8. So we wrap it into another function. |
| 47 function tryRequire(module) |
| 48 { |
| 49 try |
| 50 { |
| 51 return require(module); |
| 52 } |
| 53 catch (e) |
| 54 { |
| 55 return null; |
| 56 } |
| 57 } |
| 58 |
| 43 function convertObject(keys, obj) | 59 function convertObject(keys, obj) |
| 44 { | 60 { |
| 45 var result = {}; | 61 var result = {}; |
| 46 for (var i = 0; i < keys.length; i++) | 62 for (var i = 0; i < keys.length; i++) |
| 47 result[keys[i]] = obj[keys[i]]; | 63 result[keys[i]] = obj[keys[i]]; |
| 48 return result; | 64 return result; |
| 49 } | 65 } |
| 50 | 66 |
| 51 var convertSubscription = convertObject.bind(null, ["disabled", | 67 var convertSubscription = convertObject.bind(null, ["disabled", |
| 52 "downloadStatus", "homepage", "lastDownload", "title", "url"]); | 68 "downloadStatus", "homepage", "lastDownload", "title", "url"]); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 return listenerFilters; | 147 return listenerFilters; |
| 132 } | 148 } |
| 133 | 149 |
| 134 global.ext.onMessage.addListener(function(message, sender, callback) | 150 global.ext.onMessage.addListener(function(message, sender, callback) |
| 135 { | 151 { |
| 136 switch (message.type) | 152 switch (message.type) |
| 137 { | 153 { |
| 138 case "app.get": | 154 case "app.get": |
| 139 if (message.what == "issues") | 155 if (message.what == "issues") |
| 140 { | 156 { |
| 141 var subscriptionInit; | 157 var subscriptionInit = tryRequire("subscriptionInit"); |
| 142 try | |
| 143 { | |
| 144 subscriptionInit = require("subscriptionInit"); | |
| 145 } | |
| 146 catch (e) | |
| 147 { | |
| 148 // Expected exception, this module doesn't exist on Firefox | |
| 149 } | |
| 150 | |
| 151 callback({ | 158 callback({ |
| 152 filterlistsReinitialized: subscriptionInit ? subscriptionInit.reinit
ialized : false, | 159 filterlistsReinitialized: subscriptionInit ? subscriptionInit.reinit
ialized : false, |
| 153 legacySafariVersion: (info.platform == "safari" && ( | 160 legacySafariVersion: (info.platform == "safari" && ( |
| 154 Services.vc.compare(info.platformVersion, "6.0") < 0 || // bef
oreload breaks websites in Safari 5 | 161 Services.vc.compare(info.platformVersion, "6.0") < 0 || // bef
oreload breaks websites in Safari 5 |
| 155 Services.vc.compare(info.platformVersion, "6.1") == 0 || // ext
ensions are broken in 6.1 and 7.0 | 162 Services.vc.compare(info.platformVersion, "6.1") == 0 || // ext
ensions are broken in 6.1 and 7.0 |
| 156 Services.vc.compare(info.platformVersion, "7.0") == 0)) | 163 Services.vc.compare(info.platformVersion, "7.0") == 0)) |
| 157 }); | 164 }); |
| 158 } | 165 } |
| 159 else if (message.what == "doclink") | 166 else if (message.what == "doclink") |
| 160 callback(Utils.getDocLink(message.link)); | 167 callback(Utils.getDocLink(message.link)); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 if (subscription instanceof DownloadableSubscription) | 399 if (subscription instanceof DownloadableSubscription) |
| 393 Synchronizer.execute(subscription, true); | 400 Synchronizer.execute(subscription, true); |
| 394 } | 401 } |
| 395 break; | 402 break; |
| 396 case "subscriptions.isDownloading": | 403 case "subscriptions.isDownloading": |
| 397 callback(Synchronizer.isExecuting(message.url)); | 404 callback(Synchronizer.isExecuting(message.url)); |
| 398 break; | 405 break; |
| 399 } | 406 } |
| 400 }); | 407 }); |
| 401 })(this); | 408 })(this); |
| OLD | NEW |