even better, just skip completely nsIContentPolicy for FF35+

pull/2/head
gorhill 9 years ago
parent 51d18b4c47
commit ff36607354

@ -72,7 +72,7 @@ const contentObserver = {
contentBaseURI: 'chrome://' + hostName + '/content/js/', contentBaseURI: 'chrome://' + hostName + '/content/js/',
cpMessageName: hostName + ':shouldLoad', cpMessageName: hostName + ':shouldLoad',
uniqueSandboxId: 1, uniqueSandboxId: 1,
firefoxPost34: Services.vc.compare(Services.appinfo.platformVersion, '35.0') >= 0, firefoxPre35: Services.vc.compare(Services.appinfo.platformVersion, '35.0') < 0,
get componentRegistrar() { get componentRegistrar() {
return Components.manager.QueryInterface(Ci.nsIComponentRegistrar); return Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
@ -101,36 +101,40 @@ const contentObserver = {
register: function() { register: function() {
Services.obs.addObserver(this, 'document-element-inserted', true); Services.obs.addObserver(this, 'document-element-inserted', true);
this.componentRegistrar.registerFactory( if ( this.firefoxPre35 ) {
this.classID, this.componentRegistrar.registerFactory(
this.classDescription, this.classID,
this.contractID, this.classDescription,
this this.contractID,
); this
this.categoryManager.addCategoryEntry( );
'content-policy', this.categoryManager.addCategoryEntry(
this.contractID, 'content-policy',
this.contractID, this.contractID,
false, this.contractID,
true false,
); true
);
}
}, },
unregister: function() { unregister: function() {
Services.obs.removeObserver(this, 'document-element-inserted'); Services.obs.removeObserver(this, 'document-element-inserted');
this.componentRegistrar.unregisterFactory(this.classID, this); if ( this.firefoxPre35 ) {
this.categoryManager.deleteCategoryEntry( this.componentRegistrar.unregisterFactory(this.classID, this);
'content-policy', this.categoryManager.deleteCategoryEntry(
this.contractID, 'content-policy',
false this.contractID,
); false
);
}
}, },
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPolicy // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPolicy
// https://bugzil.la/612921 // https://bugzil.la/612921
shouldLoad: function(type, location, origin, context) { shouldLoad: function(type, location, origin, context) {
if ( this.firefoxPost34 || Services === undefined || !context ) { if ( Services === undefined || !context ) {
return this.ACCEPT; return this.ACCEPT;
} }

Loading…
Cancel
Save