| Index: lib/main.js |
| =================================================================== |
| --- a/lib/main.js |
| +++ b/lib/main.js |
| @@ -17,25 +17,63 @@ |
| /** |
| * @fileOverview Starts up Adblock Plus |
| */ |
| Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
| Cu.import("resource://gre/modules/Services.jsm"); |
| +bootstrapChildProcesses(); |
| registerPublicAPI(); |
| require("filterListener"); |
| require("contentPolicy"); |
| require("synchronizer"); |
| require("notification"); |
| require("sync"); |
| require("messageResponder"); |
| require("ui"); |
| +function bootstrapChildProcesses() |
| +{ |
| + let info = require("info"); |
| + |
| + // Huge hack: we cannot opt out of individual compatibility shims (see |
| + // https://bugzilla.mozilla.org/show_bug.cgi?id=1167802). So the about |
| + // protocol shim will override our handler in the content process. Prevent |
| + // this by making sure it isn't messaged. |
| + try |
| + { |
| + let {AboutProtocolParent} = Cu.import("resource://gre/modules/RemoteAddonsParent.jsm", {}); |
| + if (AboutProtocolParent && typeof AboutProtocolParent.registerFactory == "function") |
| + { |
| + let origRegisterFactory = AboutProtocolParent.registerFactory; |
| + AboutProtocolParent.registerFactory = function(addon, ...args) |
| + { |
| + if (addon != info.addonID) |
| + origRegisterFactory.call(this, addon, ...args); |
| + } |
| + onShutdown.add(() => AboutProtocolParent.registerFactory = origRegisterFactory); |
| + } |
| + } |
| + catch(e) {} |
| + |
| + let processScript = info.addonRoot + "lib/child/bootstrap.js?" + Math.random(); |
| + let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"] |
| + .getService(Ci.nsIProcessScriptLoader) |
| + .QueryInterface(Ci.nsIMessageBroadcaster); |
| + messageManager.loadProcessScript(processScript, true); |
| + messageManager.broadcastAsyncMessage("AdblockPlus:Info", info); |
| + |
| + onShutdown.add(() => { |
| + messageManager.broadcastAsyncMessage("AdblockPlus:Shutdown", processScript); |
| + messageManager.removeDelayedProcessScript(processScript); |
| + }); |
| +} |
| + |
| function registerPublicAPI() |
| { |
| let {addonRoot} = require("info"); |
| let uri = Services.io.newURI(addonRoot + "lib/Public.jsm", null, null); |
| if (uri instanceof Ci.nsIMutable) |
| uri.mutable = false; |