1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 const Cc = Components.classes;
5 const Ci = Components.interfaces;
7 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
8 Components.utils.import("resource://gre/modules/Services.jsm");
11 //dump("B2GAboutRedirector: " + msg + "\n");
14 function netErrorURL() {
15 let uri = "app://system.gaiamobile.org/net_error.html";
17 uri = Services.prefs.getCharPref("b2g.neterror.url");
24 uri: "chrome://b2g/content/aboutCertError.xhtml",
35 function B2GAboutRedirector() {}
36 B2GAboutRedirector.prototype = {
37 QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
38 classID: Components.ID("{920400b1-cf8f-4760-a9c4-441417b15134}"),
40 _getModuleInfo: function (aURI) {
41 let moduleName = aURI.path.replace(/[?#].*/, "").toLowerCase();
42 return modules[moduleName];
46 getURIFlags: function(aURI) {
48 let moduleInfo = this._getModuleInfo(aURI);
50 flags = Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT;
52 return flags | Ci.nsIAboutModule.ALLOW_SCRIPT;
55 newChannel: function(aURI) {
56 let moduleInfo = this._getModuleInfo(aURI);
58 var ios = Cc["@mozilla.org/network/io-service;1"].
59 getService(Ci.nsIIOService);
61 var channel = ios.newChannel(moduleInfo.uri, null, null);
63 if (!moduleInfo.privileged) {
64 // Setting the owner to null means that we'll go through the normal
65 // path in GetChannelPrincipal and create a codebase principal based
66 // on the channel's originalURI
70 channel.originalURI = aURI;
76 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([B2GAboutRedirector]);