Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/contentPolicy.js

Issue 9355011: Make sure ABP category cannot be removed (work-around for AVG toolbar issue) (Closed)
Patch Set: Created Feb. 8, 2013, 7:46 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld