 Issue 29329246:
  Issue 3108 - Inject our about: module into all processes  (Closed)
    
  
    Issue 29329246:
  Issue 3108 - Inject our about: module into all processes  (Closed) 
  | Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | |
| 4 * | |
| 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 | |
| 7 * published by the Free Software Foundation. | |
| 8 * | |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 * GNU General Public License for more details. | |
| 13 * | |
| 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/>. | |
| 16 */ | |
| 17 | |
| 18 (function() | |
| 19 { | |
| 20 const Cc = Components.classes; | |
| 21 const Ci = Components.interfaces; | |
| 22 const Cr = Components.results; | |
| 23 const Cu = Components.utils; | |
| 24 | |
| 25 let {Loader, main, unload} = Cu.import("resource://gre/modules/commonjs/toolki t/loader.js", {}); | |
| 26 | |
| 27 let loader = null; | |
| 28 | |
| 29 let shutdownHandlers = []; | |
| 30 let onShutdown = | |
| 31 { | |
| 32 done: false, | |
| 33 add: function(handler) | |
| 34 { | |
| 35 if (shutdownHandlers.indexOf(handler) < 0) | |
| 36 shutdownHandlers.push(handler); | |
| 37 }, | |
| 38 remove: function(handler) | |
| 39 { | |
| 40 let index = shutdownHandlers.indexOf(handler); | |
| 41 if (index >= 0) | |
| 42 shutdownHandlers.splice(index, 1); | |
| 43 } | |
| 44 }; | |
| 45 | |
| 46 addMessageListener("AdblockPlus:Info", init); | |
| 47 addMessageListener("AdblockPlus:Shutdown", shutdown); | |
| 48 | |
| 49 function init(message) | |
| 50 { | |
| 51 removeMessageListener("AdblockPlus:Info", init); | |
| 52 | |
| 53 let info = message.data; | |
| 54 loader = Loader({ | |
| 55 paths: { | |
| 56 "": info.addonRoot + "lib/" | |
| 57 }, | |
| 58 globals: { | |
| 59 Components, Cc, Ci, Cu, Cr, atob, btoa, onShutdown, | |
| 
Wladimir Palant
2015/10/16 12:15:10
bootstrap.js from buildtools also exposes File and
 
Thomas Greiner
2015/10/16 15:40:25
I couldn't find a better one either. We could impl
 
Wladimir Palant
2015/10/16 17:52:03
The alternative is exposing this property as compo
 | |
| 60 addMessageListener, removeMessageListener, sendAsyncMessage, sendSyncMes sage | |
| 61 }, | |
| 62 modules: {"info": info}, | |
| 63 id: info.addonID | |
| 64 }); | |
| 65 onShutdown.add(() => unload(loader, "disable")) | |
| 66 | |
| 67 main(loader, "child/main"); | |
| 68 } | |
| 69 | |
| 70 function shutdown(message) | |
| 71 { | |
| 72 if (message.data == Components.stack.filename) | |
| 73 { | |
| 74 removeMessageListener("AdblockPlus:Shutdown", shutdown); | |
| 75 | |
| 76 onShutdown.done = true; | |
| 77 for (let i = shutdownHandlers.length - 1; i >= 0; i --) | |
| 78 { | |
| 79 try | |
| 80 { | |
| 81 shutdownHandlers[i](); | |
| 82 } | |
| 83 catch (e) | |
| 84 { | |
| 85 Cu.reportError(e); | |
| 86 } | |
| 87 } | |
| 88 shutdownHandlers = null; | |
| 89 } | |
| 90 } | |
| 91 })(); | |
| 92 | |
| OLD | NEW |