michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: michael@0: Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: michael@0: let modules = { michael@0: // about: michael@0: "": { michael@0: uri: "chrome://browser/content/about.xhtml", michael@0: privileged: true michael@0: }, michael@0: michael@0: // about:fennec and about:firefox are aliases for about:, michael@0: // but hidden from about:about michael@0: fennec: { michael@0: uri: "chrome://browser/content/about.xhtml", michael@0: privileged: true, michael@0: hide: true michael@0: }, michael@0: get firefox() this.fennec, michael@0: michael@0: // about:blank has some bad loading behavior we can avoid, if we use an alias michael@0: empty: { michael@0: uri: "about:blank", michael@0: privileged: false, michael@0: hide: true michael@0: }, michael@0: michael@0: rights: { michael@0: #ifdef MOZ_OFFICIAL_BRANDING michael@0: uri: "chrome://browser/content/aboutRights.xhtml", michael@0: #else michael@0: uri: "chrome://global/content/aboutRights-unbranded.xhtml", michael@0: #endif michael@0: privileged: false michael@0: }, michael@0: blocked: { michael@0: uri: "chrome://browser/content/blockedSite.xhtml", michael@0: privileged: false, michael@0: hide: true michael@0: }, michael@0: certerror: { michael@0: uri: "chrome://browser/content/aboutCertError.xhtml", michael@0: privileged: false, michael@0: hide: true michael@0: }, michael@0: home: { michael@0: uri: "chrome://browser/content/aboutHome.xhtml", michael@0: privileged: false michael@0: }, michael@0: apps: { michael@0: uri: "chrome://browser/content/aboutApps.xhtml", michael@0: privileged: true michael@0: }, michael@0: downloads: { michael@0: uri: "chrome://browser/content/aboutDownloads.xhtml", michael@0: privileged: true michael@0: }, michael@0: reader: { michael@0: uri: "chrome://browser/content/aboutReader.html", michael@0: privileged: false, michael@0: hide: true michael@0: }, michael@0: feedback: { michael@0: uri: "chrome://browser/content/aboutFeedback.xhtml", michael@0: privileged: true michael@0: }, michael@0: privatebrowsing: { michael@0: uri: "chrome://browser/content/aboutPrivateBrowsing.xhtml", michael@0: privileged: true michael@0: }, michael@0: #ifdef MOZ_SERVICES_HEALTHREPORT michael@0: healthreport: { michael@0: uri: "chrome://browser/content/aboutHealthReport.xhtml", michael@0: privileged: true michael@0: }, michael@0: #endif michael@0: } michael@0: michael@0: function AboutRedirector() {} michael@0: AboutRedirector.prototype = { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]), michael@0: classID: Components.ID("{322ba47e-7047-4f71-aebf-cb7d69325cd9}"), michael@0: michael@0: _getModuleInfo: function (aURI) { michael@0: let moduleName = aURI.path.replace(/[?#].*/, "").toLowerCase(); michael@0: return modules[moduleName]; michael@0: }, michael@0: michael@0: // nsIAboutModule michael@0: getURIFlags: function(aURI) { michael@0: let flags; michael@0: let moduleInfo = this._getModuleInfo(aURI); michael@0: if (moduleInfo.hide) michael@0: flags = Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT; michael@0: michael@0: return flags | Ci.nsIAboutModule.ALLOW_SCRIPT; michael@0: }, michael@0: michael@0: newChannel: function(aURI) { michael@0: let moduleInfo = this._getModuleInfo(aURI); michael@0: michael@0: var ios = Cc["@mozilla.org/network/io-service;1"]. michael@0: getService(Ci.nsIIOService); michael@0: michael@0: var channel = ios.newChannel(moduleInfo.uri, null, null); michael@0: michael@0: if (!moduleInfo.privileged) { michael@0: // Setting the owner to null means that we'll go through the normal michael@0: // path in GetChannelPrincipal and create a codebase principal based michael@0: // on the channel's originalURI michael@0: channel.owner = null; michael@0: } michael@0: michael@0: channel.originalURI = aURI; michael@0: michael@0: return channel; michael@0: } michael@0: }; michael@0: michael@0: const components = [AboutRedirector]; michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);