1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/aboutAbout.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +const Cc = Components.classes; 1.9 +const Ci = Components.interfaces; 1.10 +var gProtocols = []; 1.11 +var gContainer; 1.12 +window.onload = function () { 1.13 + gContainer = document.getElementById("abouts"); 1.14 + findAbouts(); 1.15 +} 1.16 + 1.17 +function findAbouts() { 1.18 + var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); 1.19 + for (var cid in Cc) { 1.20 + var result = cid.match(/@mozilla.org\/network\/protocol\/about;1\?what\=(.*)$/); 1.21 + if (result) { 1.22 + var aboutType = result[1]; 1.23 + var contract = "@mozilla.org/network/protocol/about;1?what=" + aboutType; 1.24 + try { 1.25 + var am = Cc[contract].getService(Ci.nsIAboutModule); 1.26 + var uri = ios.newURI("about:"+aboutType, null, null); 1.27 + var flags = am.getURIFlags(uri); 1.28 + if (!(flags & Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT)) { 1.29 + gProtocols.push(aboutType); 1.30 + } 1.31 + } catch (e) { 1.32 + // getService might have thrown if the component doesn't actually 1.33 + // implement nsIAboutModule 1.34 + } 1.35 + } 1.36 + } 1.37 + gProtocols.sort().forEach(createProtocolListing); 1.38 +} 1.39 + 1.40 +function createProtocolListing(aProtocol) { 1.41 + var uri = "about:" + aProtocol; 1.42 + var li = document.createElement("li"); 1.43 + var link = document.createElement("a"); 1.44 + var text = document.createTextNode(uri); 1.45 + 1.46 + link.href = uri; 1.47 + link.appendChild(text); 1.48 + li.appendChild(link); 1.49 + gContainer.appendChild(li); 1.50 +}