From 38582edd26dc49f2dde6a89aaf2e0a655b231207 Mon Sep 17 00:00:00 2001 From: Mike Conley Date: Wed, 26 Nov 2014 10:48:26 -0500 Subject: [PATCH] Bug 1102410 - Make AboutProtocolChild use a unique classID each time it registers a new nsIAboutModule. r=billm. --HG-- extra : rebase_source : eb937c4c8996441eb92b41e2620820f99937ed90 --- .../addoncompat/RemoteAddonsChild.jsm | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/toolkit/components/addoncompat/RemoteAddonsChild.jsm b/toolkit/components/addoncompat/RemoteAddonsChild.jsm index f7655b9f392..e38d7555629 100644 --- a/toolkit/components/addoncompat/RemoteAddonsChild.jsm +++ b/toolkit/components/addoncompat/RemoteAddonsChild.jsm @@ -310,10 +310,12 @@ AboutProtocolInstance.prototype = { let AboutProtocolChild = { _classDescription: "Addon shim about: protocol handler", - _classID: Components.ID("8d56a310-0c80-11e4-9191-0800200c9a66"), init: function() { - this._instances = {}; + // Maps contractIDs to instances + this._instances = new Map(); + // Maps contractIDs to classIDs + this._classIDs = new Map(); NotificationTracker.watch("about-protocol", this); }, @@ -322,11 +324,19 @@ let AboutProtocolChild = { let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); if (register) { let instance = new AboutProtocolInstance(contractID); - this._instances[contractID] = instance; - registrar.registerFactory(this._classID, this._classDescription, contractID, instance); + let classID = Cc["@mozilla.org/uuid-generator;1"] + .getService(Ci.nsIUUIDGenerator) + .generateUUID(); + + this._instances.set(contractID, instance); + this._classIDs.set(contractID, classID); + registrar.registerFactory(classID, this._classDescription, contractID, instance); } else { - registrar.unregisterFactory(this._classID, this._instances[contractID]); - delete this._instances[contractID]; + let instance = this._instances.get(contractID); + let classID = this._classIDs.get(contractID); + registrar.unregisterFactory(classID, instance); + this._instances.delete(contractID); + this._classIDs.delete(contractID); } }, };