toolkit/content/aboutAbout.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.

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
michael@0 5 const Cc = Components.classes;
michael@0 6 const Ci = Components.interfaces;
michael@0 7 var gProtocols = [];
michael@0 8 var gContainer;
michael@0 9 window.onload = function () {
michael@0 10 gContainer = document.getElementById("abouts");
michael@0 11 findAbouts();
michael@0 12 }
michael@0 13
michael@0 14 function findAbouts() {
michael@0 15 var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
michael@0 16 for (var cid in Cc) {
michael@0 17 var result = cid.match(/@mozilla.org\/network\/protocol\/about;1\?what\=(.*)$/);
michael@0 18 if (result) {
michael@0 19 var aboutType = result[1];
michael@0 20 var contract = "@mozilla.org/network/protocol/about;1?what=" + aboutType;
michael@0 21 try {
michael@0 22 var am = Cc[contract].getService(Ci.nsIAboutModule);
michael@0 23 var uri = ios.newURI("about:"+aboutType, null, null);
michael@0 24 var flags = am.getURIFlags(uri);
michael@0 25 if (!(flags & Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT)) {
michael@0 26 gProtocols.push(aboutType);
michael@0 27 }
michael@0 28 } catch (e) {
michael@0 29 // getService might have thrown if the component doesn't actually
michael@0 30 // implement nsIAboutModule
michael@0 31 }
michael@0 32 }
michael@0 33 }
michael@0 34 gProtocols.sort().forEach(createProtocolListing);
michael@0 35 }
michael@0 36
michael@0 37 function createProtocolListing(aProtocol) {
michael@0 38 var uri = "about:" + aProtocol;
michael@0 39 var li = document.createElement("li");
michael@0 40 var link = document.createElement("a");
michael@0 41 var text = document.createTextNode(uri);
michael@0 42
michael@0 43 link.href = uri;
michael@0 44 link.appendChild(text);
michael@0 45 li.appendChild(link);
michael@0 46 gContainer.appendChild(li);
michael@0 47 }

mercurial