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

Unified Diff: lib/contentPolicy.js

Issue 29329565: Issue 3208 - Initialize types map in PolicyImplementation, not Policy (Closed)
Patch Set: Created Oct. 30, 2015, 10:52 p.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
@@ -76,22 +76,16 @@ var Policy = exports.Policy =
*/
whitelistSchemes: new Set(),
/**
* Called on module startup, initializes various exported properties.
*/
init: function()
{
- // Populate types map
- let iface = Ci.nsIContentPolicy;
- for (let name in iface)
- if (name.indexOf("TYPE_") == 0 && name != "TYPE_DATAREQUEST")
- types.set(iface[name], name.substr(5));
-
// whitelisted URL schemes
for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" "))
this.whitelistSchemes.add(scheme);
// Generate class identifier used to collapse node and register corresponding
// stylesheet.
let offset = "a".charCodeAt(0);
for (let i = 0; i < 20; i++)
@@ -341,16 +335,22 @@ var PolicyImplementation =
contractID: "@adblockplus.org/abp/policy;1",
xpcom_categories: ["content-policy", "net-channel-event-sinks"],
/**
* Registers the content policy on startup.
*/
init: function()
{
+ // Populate types map
+ let iface = Ci.nsIContentPolicy;
+ for (let name in iface)
+ if (name.indexOf("TYPE_") == 0 && name != "TYPE_DATAREQUEST")
+ types.set(iface[name], name.substr(5));
+
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(this.classID, this.classDescription, this.contractID, this);
let catMan = Utils.categoryManager;
for (let category of this.xpcom_categories)
catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true);
Services.obs.addObserver(this, "content-document-global-created", true);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld