Browse Source

Code styling

pull/2/head
Deathamns 10 years ago
committed by gorhill
parent
commit
40b191e9f4
  1. 23
      platform/firefox/frameModule.js

23
platform/firefox/frameModule.js

@ -54,20 +54,24 @@ const contentPolicy = {
contractID: '@' + appName + '/content-policy;1', contractID: '@' + appName + '/content-policy;1',
ACCEPT: Ci.nsIContentPolicy.ACCEPT, ACCEPT: Ci.nsIContentPolicy.ACCEPT,
messageName: appName + ':shouldLoad', messageName: appName + ':shouldLoad',
get componentRegistrar() { get componentRegistrar() {
return Components.manager.QueryInterface(Ci.nsIComponentRegistrar); return Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
}, },
get categoryManager() { get categoryManager() {
return Components.classes['@mozilla.org/categorymanager;1'] return Components.classes['@mozilla.org/categorymanager;1']
.getService(Ci.nsICategoryManager); .getService(Ci.nsICategoryManager);
}, },
QueryInterface: XPCOMUtils.generateQI([ QueryInterface: XPCOMUtils.generateQI([
Ci.nsIFactory, Ci.nsIFactory,
Ci.nsIContentPolicy, Ci.nsIContentPolicy,
Ci.nsISupportsWeakReference Ci.nsISupportsWeakReference
]), ]),
createInstance: function(outer, iid) { createInstance: function(outer, iid) {
if (outer) {
if ( outer ) {
throw Components.results.NS_ERROR_NO_AGGREGATION; throw Components.results.NS_ERROR_NO_AGGREGATION;
} }
@ -88,6 +92,7 @@ const contentPolicy = {
true true
); );
}, },
unregister: function() { unregister: function() {
this.componentRegistrar.unregisterFactory(this.classID, this); this.componentRegistrar.unregisterFactory(this.classID, this);
this.categoryManager.deleteCategoryEntry( this.categoryManager.deleteCategoryEntry(
@ -96,6 +101,7 @@ const contentPolicy = {
false false
); );
}, },
// https://bugzil.la/612921 // https://bugzil.la/612921
shouldLoad: function(type, location, origin, context) { shouldLoad: function(type, location, origin, context) {
// If we don't know what initiated the request, probably it's not a tab // If we don't know what initiated the request, probably it's not a tab
@ -128,14 +134,16 @@ const contentPolicy = {
const docObserver = { const docObserver = {
contentBaseURI: 'chrome://' + appName + '/content/js/', contentBaseURI: 'chrome://' + appName + '/content/js/',
QueryInterface: XPCOMUtils.generateQI([ QueryInterface: XPCOMUtils.generateQI([
Ci.nsIObserver, Ci.nsIObserver,
Ci.nsISupportsWeakReference Ci.nsISupportsWeakReference
]), ]),
initContext: function(win, sandbox) { initContext: function(win, sandbox) {
let messager = getMessageManager(win); let messager = getMessageManager(win);
if (sandbox) {
if ( sandbox ) {
win = Cu.Sandbox([win], { win = Cu.Sandbox([win], {
sandboxPrototype: win, sandboxPrototype: win,
wantComponents: false, wantComponents: false,
@ -147,7 +155,7 @@ const docObserver = {
// anonymous function needs to be used here // anonymous function needs to be used here
win.injectScript = Cu.exportFunction( win.injectScript = Cu.exportFunction(
function(script, evalCode) { function(script, evalCode) {
if (evalCode) {
if ( evalCode ) {
Cu.evalInSandbox(script, win); Cu.evalInSandbox(script, win);
return; return;
} }
@ -164,23 +172,26 @@ const docObserver = {
return win; return win;
}, },
register: function() { register: function() {
Services.obs.addObserver(this, 'document-element-inserted', true); Services.obs.addObserver(this, 'document-element-inserted', true);
}, },
unregister: function() { unregister: function() {
Services.obs.removeObserver(this, 'document-element-inserted'); Services.obs.removeObserver(this, 'document-element-inserted');
}, },
observe: function(doc) { observe: function(doc) {
let win = doc.defaultView; let win = doc.defaultView;
if (!win) {
if ( !win ) {
return; return;
} }
let loc = win.location; let loc = win.location;
if (loc.protocol !== 'http:' && loc.protocol !== 'https:') {
if (loc.protocol === 'chrome:' && loc.host === appName) {
if ( loc.protocol !== 'http:' && loc.protocol !== 'https:' ) {
if ( loc.protocol === 'chrome:' && loc.host === appName ) {
this.initContext(win); this.initContext(win);
} }

Loading…
Cancel
Save