| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 (function() | 18 (function() |
| 19 { | 19 { |
| 20 const Cc = Components.classes; | 20 const Cc = Components.classes; |
| 21 const Ci = Components.interfaces; | 21 const Ci = Components.interfaces; |
| 22 const Cr = Components.results; | 22 const Cr = Components.results; |
| 23 const Cu = Components.utils; | 23 const Cu = Components.utils; |
| 24 | 24 |
| 25 let {Loader, main, unload} = Cu.import("resource://gre/modules/commonjs/toolki
t/loader.js", {}); | 25 let {Loader, main, unload} = Cu.import("resource://gre/modules/commonjs/toolki
t/loader.js", {}); |
| 26 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); | 26 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
| 27 | 27 |
| 28 Cu.importGlobalProperties(["atob", "btoa", "File", "URL", "URLSearchParams", |
| 29 "TextDecoder", "TextEncoder"]); |
| 30 |
| 28 let shutdownHandlers = []; | 31 let shutdownHandlers = []; |
| 29 let onShutdown = | 32 let onShutdown = |
| 30 { | 33 { |
| 31 done: false, | 34 done: false, |
| 32 add: function(handler) | 35 add: function(handler) |
| 33 { | 36 { |
| 34 if (shutdownHandlers.indexOf(handler) < 0) | 37 if (shutdownHandlers.indexOf(handler) < 0) |
| 35 shutdownHandlers.push(handler); | 38 shutdownHandlers.push(handler); |
| 36 }, | 39 }, |
| 37 remove: function(handler) | 40 remove: function(handler) |
| 38 { | 41 { |
| 39 let index = shutdownHandlers.indexOf(handler); | 42 let index = shutdownHandlers.indexOf(handler); |
| 40 if (index >= 0) | 43 if (index >= 0) |
| 41 shutdownHandlers.splice(index, 1); | 44 shutdownHandlers.splice(index, 1); |
| 42 } | 45 } |
| 43 }; | 46 }; |
| 44 | 47 |
| 45 function init(info) | 48 function init() |
| 46 { | 49 { |
| 50 let url = new URL(Components.stack.filename); |
| 51 let params = new URLSearchParams(url.search.substr(1)); |
| 52 let info = JSON.parse(params.get("info")); |
| 53 |
| 47 let loader = Loader({ | 54 let loader = Loader({ |
| 48 paths: { | 55 paths: { |
| 49 "": info.addonRoot + "lib/" | 56 "": info.addonRoot + "lib/" |
| 50 }, | 57 }, |
| 51 globals: { | 58 globals: { |
| 52 Components, Cc, Ci, Cu, Cr, atob, btoa, onShutdown | 59 Components, Cc, Ci, Cu, Cr, atob, btoa, File, URL, URLSearchParams, |
| 60 TextDecoder, TextEncoder, onShutdown |
| 53 }, | 61 }, |
| 54 modules: {"info": info, "messageManager": this}, | 62 modules: {"info": info, "messageManager": this}, |
| 55 id: info.addonID | 63 id: info.addonID |
| 56 }); | 64 }); |
| 57 onShutdown.add(() => unload(loader, "disable")) | 65 onShutdown.add(() => unload(loader, "disable")) |
| 58 | 66 |
| 59 main(loader, "child/main"); | 67 main(loader, "child/main"); |
| 60 } | 68 } |
| 61 | 69 |
| 62 function shutdown(message) | 70 function shutdown(message) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 78 shutdownHandlers = null; | 86 shutdownHandlers = null; |
| 79 } | 87 } |
| 80 } | 88 } |
| 81 | 89 |
| 82 addMessageListener("AdblockPlus:Shutdown", shutdown); | 90 addMessageListener("AdblockPlus:Shutdown", shutdown); |
| 83 onShutdown.add(() => | 91 onShutdown.add(() => |
| 84 { | 92 { |
| 85 removeMessageListener("AdblockPlus:Shutdown", shutdown); | 93 removeMessageListener("AdblockPlus:Shutdown", shutdown); |
| 86 }); | 94 }); |
| 87 | 95 |
| 88 let param = Components.stack.filename.split("#", 2)[1]; | 96 init(); |
| 89 init(JSON.parse(decodeURIComponent(param))); | |
| 90 })(); | 97 })(); |
| LEFT | RIGHT |