browser/metro/components/AboutRedirector.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1  // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 const Cc = Components.classes;
     6 const Ci = Components.interfaces;
     8 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
    10 let modules = {
    11   newtab: {
    12     uri: "chrome://browser/content/Start.xul",
    13     privileged: true
    14   },
    15   // about:blank has some bad loading behavior we can avoid, if we use an alias
    16   empty: {
    17     uri: "about:blank",
    18     privileged: false
    19   },
    20   firstrun: {
    21     uri: "chrome://browser/content/firstrun/firstrun.xhtml",
    22     privileged: true
    23   },
    24   rights: {
    25 #ifdef MOZ_OFFICIAL_BRANDING
    26     uri: "chrome://browser/content/aboutRights.xhtml",
    27 #else
    28     uri: "chrome://global/content/aboutRights-unbranded.xhtml",
    29 #endif
    30     privileged: false
    31   },
    32   blocked: {
    33     uri: "chrome://browser/content/blockedSite.xhtml",
    34     privileged: true
    35   },
    36   certerror: {
    37     uri: "chrome://browser/content/aboutCertError.xhtml",
    38     privileged: true
    39   },
    40   start: {
    41     uri: "about:newtab",
    42     privileged: true
    43   },
    44   home: {
    45     uri: "about:newtab",
    46     privileged: true
    47   },
    48 #ifdef MOZ_CRASHREPORTER
    49   crashprompt: {
    50     uri: "chrome://browser/content/crashprompt.xhtml",
    51     privileged: true
    52   },
    53 #endif
    54 }
    56 function AboutGeneric() {}
    58 AboutGeneric.prototype = {
    59   classID: Components.ID("{433d2d75-5923-49b0-854d-f37267b03dc7}"),
    60   QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
    62   _getModuleInfo: function (aURI) {
    63     let moduleName = aURI.path.replace(/[?#].*/, "").toLowerCase();
    64     return modules[moduleName];
    65   },
    67   getURIFlags: function(aURI) {
    68     return Ci.nsIAboutModule.ALLOW_SCRIPT;
    69   },
    71   newChannel: function(aURI) {
    72     let moduleInfo = this._getModuleInfo(aURI);
    74     var ios = Cc["@mozilla.org/network/io-service;1"].
    75               getService(Ci.nsIIOService);
    77     var channel = ios.newChannel(moduleInfo.uri, null, null);
    79     if (!moduleInfo.privileged) {
    80       // Setting the owner to null means that we'll go through the normal
    81       // path in GetChannelPrincipal and create a codebase principal based
    82       // on the channel's originalURI
    83       channel.owner = null;
    84     }
    86     channel.originalURI = aURI;
    87     return channel;
    88   }
    89 };
    91 const components = [AboutGeneric];
    92 const NSGetFactory = XPCOMUtils.generateNSGetFactory(components);

mercurial