michael@0: // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- 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: newtab: { michael@0: uri: "chrome://browser/content/Start.xul", michael@0: privileged: true 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: }, michael@0: firstrun: { michael@0: uri: "chrome://browser/content/firstrun/firstrun.xhtml", michael@0: privileged: true 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: true michael@0: }, michael@0: certerror: { michael@0: uri: "chrome://browser/content/aboutCertError.xhtml", michael@0: privileged: true michael@0: }, michael@0: start: { michael@0: uri: "about:newtab", michael@0: privileged: true michael@0: }, michael@0: home: { michael@0: uri: "about:newtab", michael@0: privileged: true michael@0: }, michael@0: #ifdef MOZ_CRASHREPORTER michael@0: crashprompt: { michael@0: uri: "chrome://browser/content/crashprompt.xhtml", michael@0: privileged: true michael@0: }, michael@0: #endif michael@0: } michael@0: michael@0: function AboutGeneric() {} michael@0: michael@0: AboutGeneric.prototype = { michael@0: classID: Components.ID("{433d2d75-5923-49b0-854d-f37267b03dc7}"), michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]), 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: getURIFlags: function(aURI) { michael@0: return 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: return channel; michael@0: } michael@0: }; michael@0: michael@0: const components = [AboutGeneric]; michael@0: const NSGetFactory = XPCOMUtils.generateNSGetFactory(components);