aboutsummaryrefslogtreecommitdiff
path: root/components/redirector.component.js
blob: 6dce4556fb8e236da386a93e516e3e1beddd6d33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//// $Id$

Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Ci = Components.interfaces;
Cr = Components.results;
Cc = Components.classes;
const loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);

function Redirector() {
	this.init();
	this.wrappedJSObject = this;
}

try {
	loader.loadSubScript('chrome://redirector/content/code/redirector.prototype.js');
	loader.loadSubScript('chrome://redirector/content/code/redirect.js');
	loader.loadSubScript('chrome://redirector/content/code/prefs.js');
} catch(e) {
	for (i in e) {
		Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage('REDIRECTOR: Loading Redirector implementation failed: ' + i + e[i]);
	}
}

//Add the xpcom stuff to the prototype
var xpcomInfo = Redirector.prototype;
xpcomInfo.classDescription 	= "Redirector Component";
xpcomInfo.classID 			= Components.ID("{b7a7a54f-0581-47ff-b086-d6920cb7a3f7}");
xpcomInfo.contractID 		= "@einaregilsson.com/redirector;1";
xpcomInfo._xpcom_categories = [{category:'content-policy'},{category:'net-channel-event-sinks'}];
xpcomInfo.QueryInterface 	= XPCOMUtils.generateQI([Ci.nsIContentPolicy, Ci.nsIChannelEventSink]);
xpcomInfo._xpcom_factory 	= {
	createInstance: function(outer, iid) {
		if (outer) throw Cr.NS_ERROR_NO_AGGREGATION;
		return redirector.QueryInterface(iid);
	}
};

function NSGetModule(compMgr, fileSpec) {
	return XPCOMUtils.generateModule([Redirector]);
}

const redirector = new Redirector();