1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/metro/components/AboutRedirector.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,92 @@ 1.4 + // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 +const Cc = Components.classes; 1.9 +const Ci = Components.interfaces; 1.10 + 1.11 +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); 1.12 + 1.13 +let modules = { 1.14 + newtab: { 1.15 + uri: "chrome://browser/content/Start.xul", 1.16 + privileged: true 1.17 + }, 1.18 + // about:blank has some bad loading behavior we can avoid, if we use an alias 1.19 + empty: { 1.20 + uri: "about:blank", 1.21 + privileged: false 1.22 + }, 1.23 + firstrun: { 1.24 + uri: "chrome://browser/content/firstrun/firstrun.xhtml", 1.25 + privileged: true 1.26 + }, 1.27 + rights: { 1.28 +#ifdef MOZ_OFFICIAL_BRANDING 1.29 + uri: "chrome://browser/content/aboutRights.xhtml", 1.30 +#else 1.31 + uri: "chrome://global/content/aboutRights-unbranded.xhtml", 1.32 +#endif 1.33 + privileged: false 1.34 + }, 1.35 + blocked: { 1.36 + uri: "chrome://browser/content/blockedSite.xhtml", 1.37 + privileged: true 1.38 + }, 1.39 + certerror: { 1.40 + uri: "chrome://browser/content/aboutCertError.xhtml", 1.41 + privileged: true 1.42 + }, 1.43 + start: { 1.44 + uri: "about:newtab", 1.45 + privileged: true 1.46 + }, 1.47 + home: { 1.48 + uri: "about:newtab", 1.49 + privileged: true 1.50 + }, 1.51 +#ifdef MOZ_CRASHREPORTER 1.52 + crashprompt: { 1.53 + uri: "chrome://browser/content/crashprompt.xhtml", 1.54 + privileged: true 1.55 + }, 1.56 +#endif 1.57 +} 1.58 + 1.59 +function AboutGeneric() {} 1.60 + 1.61 +AboutGeneric.prototype = { 1.62 + classID: Components.ID("{433d2d75-5923-49b0-854d-f37267b03dc7}"), 1.63 + QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]), 1.64 + 1.65 + _getModuleInfo: function (aURI) { 1.66 + let moduleName = aURI.path.replace(/[?#].*/, "").toLowerCase(); 1.67 + return modules[moduleName]; 1.68 + }, 1.69 + 1.70 + getURIFlags: function(aURI) { 1.71 + return Ci.nsIAboutModule.ALLOW_SCRIPT; 1.72 + }, 1.73 + 1.74 + newChannel: function(aURI) { 1.75 + let moduleInfo = this._getModuleInfo(aURI); 1.76 + 1.77 + var ios = Cc["@mozilla.org/network/io-service;1"]. 1.78 + getService(Ci.nsIIOService); 1.79 + 1.80 + var channel = ios.newChannel(moduleInfo.uri, null, null); 1.81 + 1.82 + if (!moduleInfo.privileged) { 1.83 + // Setting the owner to null means that we'll go through the normal 1.84 + // path in GetChannelPrincipal and create a codebase principal based 1.85 + // on the channel's originalURI 1.86 + channel.owner = null; 1.87 + } 1.88 + 1.89 + channel.originalURI = aURI; 1.90 + return channel; 1.91 + } 1.92 +}; 1.93 + 1.94 +const components = [AboutGeneric]; 1.95 +const NSGetFactory = XPCOMUtils.generateNSGetFactory(components);