mobile/android/components/AboutRedirector.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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");
     9 let modules = {
    10   // about:
    11   "": {
    12     uri: "chrome://browser/content/about.xhtml",
    13     privileged: true
    14   },
    16   // about:fennec and about:firefox are aliases for about:,
    17   // but hidden from about:about
    18   fennec: {
    19     uri: "chrome://browser/content/about.xhtml",
    20     privileged: true,
    21     hide: true
    22   },
    23   get firefox() this.fennec,
    25   // about:blank has some bad loading behavior we can avoid, if we use an alias
    26   empty: {
    27     uri: "about:blank",
    28     privileged: false,
    29     hide: true
    30   },
    32   rights: {
    33 #ifdef MOZ_OFFICIAL_BRANDING
    34     uri: "chrome://browser/content/aboutRights.xhtml",
    35 #else
    36     uri: "chrome://global/content/aboutRights-unbranded.xhtml",
    37 #endif
    38     privileged: false
    39   },
    40   blocked: {
    41     uri: "chrome://browser/content/blockedSite.xhtml",
    42     privileged: false,
    43     hide: true
    44   },
    45   certerror: {
    46     uri: "chrome://browser/content/aboutCertError.xhtml",
    47     privileged: false,
    48     hide: true
    49   },
    50   home: {
    51     uri: "chrome://browser/content/aboutHome.xhtml",
    52     privileged: false
    53   },
    54   apps: {
    55     uri: "chrome://browser/content/aboutApps.xhtml",
    56     privileged: true
    57   },
    58   downloads: {
    59     uri: "chrome://browser/content/aboutDownloads.xhtml",
    60     privileged: true
    61   },
    62   reader: {
    63     uri: "chrome://browser/content/aboutReader.html",
    64     privileged: false,
    65     hide: true
    66   },
    67   feedback: {
    68     uri: "chrome://browser/content/aboutFeedback.xhtml",
    69     privileged: true
    70   },
    71   privatebrowsing: {
    72     uri: "chrome://browser/content/aboutPrivateBrowsing.xhtml",
    73     privileged: true
    74   },
    75 #ifdef MOZ_SERVICES_HEALTHREPORT
    76   healthreport: {
    77     uri: "chrome://browser/content/aboutHealthReport.xhtml",
    78     privileged: true
    79   },
    80 #endif
    81 }
    83 function AboutRedirector() {}
    84 AboutRedirector.prototype = {
    85   QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
    86   classID: Components.ID("{322ba47e-7047-4f71-aebf-cb7d69325cd9}"),
    88   _getModuleInfo: function (aURI) {
    89     let moduleName = aURI.path.replace(/[?#].*/, "").toLowerCase();
    90     return modules[moduleName];
    91   },
    93   // nsIAboutModule
    94   getURIFlags: function(aURI) {
    95     let flags;
    96     let moduleInfo = this._getModuleInfo(aURI);
    97     if (moduleInfo.hide)
    98       flags = Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT;
   100     return flags | Ci.nsIAboutModule.ALLOW_SCRIPT;
   101   },
   103   newChannel: function(aURI) {
   104     let moduleInfo = this._getModuleInfo(aURI);
   106     var ios = Cc["@mozilla.org/network/io-service;1"].
   107               getService(Ci.nsIIOService);
   109     var channel = ios.newChannel(moduleInfo.uri, null, null);
   111     if (!moduleInfo.privileged) {
   112       // Setting the owner to null means that we'll go through the normal
   113       // path in GetChannelPrincipal and create a codebase principal based
   114       // on the channel's originalURI
   115       channel.owner = null;
   116     }
   118     channel.originalURI = aURI;
   120     return channel;
   121   }
   122 };
   124 const components = [AboutRedirector];
   125 this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);

mercurial