Index: lib/contentPolicy.js |
=================================================================== |
--- a/lib/contentPolicy.js |
+++ b/lib/contentPolicy.js |
@@ -368,31 +368,37 @@ let PolicyImplementation = |
registrar.registerFactory(this.classID, this.classDescription, this.contractID, this); |
let catMan = Utils.categoryManager; |
for each (let category in this.xpcom_categories) |
catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true); |
Services.obs.addObserver(this, "http-on-modify-request", true); |
Services.obs.addObserver(this, "content-document-global-created", true); |
+ Services.obs.addObserver(this, "xpcom-category-entry-removed", true); |
+ Services.obs.addObserver(this, "xpcom-category-cleared", true); |
onShutdown.add(function() |
{ |
+ // Our category observers should be removed before changing category |
+ // memberships, just in case. |
+ Services.obs.removeObserver(this, "http-on-modify-request"); |
+ Services.obs.removeObserver(this, "content-document-global-created"); |
+ Services.obs.removeObserver(this, "xpcom-category-entry-removed"); |
+ Services.obs.removeObserver(this, "xpcom-category-cleared"); |
+ |
for each (let category in this.xpcom_categories) |
catMan.deleteCategoryEntry(category, this.contractID, false); |
// This needs to run asynchronously, see bug 753687 |
Utils.runAsync(function() |
{ |
registrar.unregisterFactory(this.classID, this); |
}.bind(this)); |
- Services.obs.removeObserver(this, "http-on-modify-request"); |
- Services.obs.removeObserver(this, "content-document-global-created"); |
- |
this.previousRequest = null; |
}.bind(this)); |
}, |
// |
// nsISupports interface implementation |
// |
@@ -491,16 +497,35 @@ let PolicyImplementation = |
{ |
let wnd = Utils.getRequestWindow(subject); |
if (wnd && wnd.opener && wnd.location.href == "about:blank") |
this.observe(wnd, "content-document-global-created", null, subject.URI); |
} |
break; |
} |
+ case "xpcom-category-entry-removed": |
+ case "xpcom-category-cleared": |
+ { |
+ let category = data; |
+ if (this.xpcom_categories.indexOf(category) < 0) |
+ return; |
+ |
+ if (topic == "xpcom-category-entry-removed" && |
+ subject instanceof Ci.nsISupportsCString && |
+ subject.data != this.contractID) |
+ { |
+ return; |
+ } |
+ |
+ // Our category entry was removed, make sure to add it back |
+ let catMan = Utils.categoryManager; |
+ catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true); |
+ break; |
+ } |
} |
}, |
// |
// nsIChannelEventSink interface implementation |
// |
asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) |