Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | const Cc = Components.classes; |
michael@0 | 5 | const Ci = Components.interfaces; |
michael@0 | 6 | |
michael@0 | 7 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 8 | |
michael@0 | 9 | let modules = { |
michael@0 | 10 | // about: |
michael@0 | 11 | "": { |
michael@0 | 12 | uri: "chrome://browser/content/about.xhtml", |
michael@0 | 13 | privileged: true |
michael@0 | 14 | }, |
michael@0 | 15 | |
michael@0 | 16 | // about:fennec and about:firefox are aliases for about:, |
michael@0 | 17 | // but hidden from about:about |
michael@0 | 18 | fennec: { |
michael@0 | 19 | uri: "chrome://browser/content/about.xhtml", |
michael@0 | 20 | privileged: true, |
michael@0 | 21 | hide: true |
michael@0 | 22 | }, |
michael@0 | 23 | get firefox() this.fennec, |
michael@0 | 24 | |
michael@0 | 25 | // about:blank has some bad loading behavior we can avoid, if we use an alias |
michael@0 | 26 | empty: { |
michael@0 | 27 | uri: "about:blank", |
michael@0 | 28 | privileged: false, |
michael@0 | 29 | hide: true |
michael@0 | 30 | }, |
michael@0 | 31 | |
michael@0 | 32 | rights: { |
michael@0 | 33 | #ifdef MOZ_OFFICIAL_BRANDING |
michael@0 | 34 | uri: "chrome://browser/content/aboutRights.xhtml", |
michael@0 | 35 | #else |
michael@0 | 36 | uri: "chrome://global/content/aboutRights-unbranded.xhtml", |
michael@0 | 37 | #endif |
michael@0 | 38 | privileged: false |
michael@0 | 39 | }, |
michael@0 | 40 | blocked: { |
michael@0 | 41 | uri: "chrome://browser/content/blockedSite.xhtml", |
michael@0 | 42 | privileged: false, |
michael@0 | 43 | hide: true |
michael@0 | 44 | }, |
michael@0 | 45 | certerror: { |
michael@0 | 46 | uri: "chrome://browser/content/aboutCertError.xhtml", |
michael@0 | 47 | privileged: false, |
michael@0 | 48 | hide: true |
michael@0 | 49 | }, |
michael@0 | 50 | home: { |
michael@0 | 51 | uri: "chrome://browser/content/aboutHome.xhtml", |
michael@0 | 52 | privileged: false |
michael@0 | 53 | }, |
michael@0 | 54 | apps: { |
michael@0 | 55 | uri: "chrome://browser/content/aboutApps.xhtml", |
michael@0 | 56 | privileged: true |
michael@0 | 57 | }, |
michael@0 | 58 | downloads: { |
michael@0 | 59 | uri: "chrome://browser/content/aboutDownloads.xhtml", |
michael@0 | 60 | privileged: true |
michael@0 | 61 | }, |
michael@0 | 62 | reader: { |
michael@0 | 63 | uri: "chrome://browser/content/aboutReader.html", |
michael@0 | 64 | privileged: false, |
michael@0 | 65 | hide: true |
michael@0 | 66 | }, |
michael@0 | 67 | feedback: { |
michael@0 | 68 | uri: "chrome://browser/content/aboutFeedback.xhtml", |
michael@0 | 69 | privileged: true |
michael@0 | 70 | }, |
michael@0 | 71 | privatebrowsing: { |
michael@0 | 72 | uri: "chrome://browser/content/aboutPrivateBrowsing.xhtml", |
michael@0 | 73 | privileged: true |
michael@0 | 74 | }, |
michael@0 | 75 | #ifdef MOZ_SERVICES_HEALTHREPORT |
michael@0 | 76 | healthreport: { |
michael@0 | 77 | uri: "chrome://browser/content/aboutHealthReport.xhtml", |
michael@0 | 78 | privileged: true |
michael@0 | 79 | }, |
michael@0 | 80 | #endif |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | function AboutRedirector() {} |
michael@0 | 84 | AboutRedirector.prototype = { |
michael@0 | 85 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]), |
michael@0 | 86 | classID: Components.ID("{322ba47e-7047-4f71-aebf-cb7d69325cd9}"), |
michael@0 | 87 | |
michael@0 | 88 | _getModuleInfo: function (aURI) { |
michael@0 | 89 | let moduleName = aURI.path.replace(/[?#].*/, "").toLowerCase(); |
michael@0 | 90 | return modules[moduleName]; |
michael@0 | 91 | }, |
michael@0 | 92 | |
michael@0 | 93 | // nsIAboutModule |
michael@0 | 94 | getURIFlags: function(aURI) { |
michael@0 | 95 | let flags; |
michael@0 | 96 | let moduleInfo = this._getModuleInfo(aURI); |
michael@0 | 97 | if (moduleInfo.hide) |
michael@0 | 98 | flags = Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT; |
michael@0 | 99 | |
michael@0 | 100 | return flags | Ci.nsIAboutModule.ALLOW_SCRIPT; |
michael@0 | 101 | }, |
michael@0 | 102 | |
michael@0 | 103 | newChannel: function(aURI) { |
michael@0 | 104 | let moduleInfo = this._getModuleInfo(aURI); |
michael@0 | 105 | |
michael@0 | 106 | var ios = Cc["@mozilla.org/network/io-service;1"]. |
michael@0 | 107 | getService(Ci.nsIIOService); |
michael@0 | 108 | |
michael@0 | 109 | var channel = ios.newChannel(moduleInfo.uri, null, null); |
michael@0 | 110 | |
michael@0 | 111 | if (!moduleInfo.privileged) { |
michael@0 | 112 | // Setting the owner to null means that we'll go through the normal |
michael@0 | 113 | // path in GetChannelPrincipal and create a codebase principal based |
michael@0 | 114 | // on the channel's originalURI |
michael@0 | 115 | channel.owner = null; |
michael@0 | 116 | } |
michael@0 | 117 | |
michael@0 | 118 | channel.originalURI = aURI; |
michael@0 | 119 | |
michael@0 | 120 | return channel; |
michael@0 | 121 | } |
michael@0 | 122 | }; |
michael@0 | 123 | |
michael@0 | 124 | const components = [AboutRedirector]; |
michael@0 | 125 | this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components); |