michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: var gProtocols = []; michael@0: var gContainer; michael@0: window.onload = function () { michael@0: gContainer = document.getElementById("abouts"); michael@0: findAbouts(); michael@0: } michael@0: michael@0: function findAbouts() { michael@0: var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); michael@0: for (var cid in Cc) { michael@0: var result = cid.match(/@mozilla.org\/network\/protocol\/about;1\?what\=(.*)$/); michael@0: if (result) { michael@0: var aboutType = result[1]; michael@0: var contract = "@mozilla.org/network/protocol/about;1?what=" + aboutType; michael@0: try { michael@0: var am = Cc[contract].getService(Ci.nsIAboutModule); michael@0: var uri = ios.newURI("about:"+aboutType, null, null); michael@0: var flags = am.getURIFlags(uri); michael@0: if (!(flags & Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT)) { michael@0: gProtocols.push(aboutType); michael@0: } michael@0: } catch (e) { michael@0: // getService might have thrown if the component doesn't actually michael@0: // implement nsIAboutModule michael@0: } michael@0: } michael@0: } michael@0: gProtocols.sort().forEach(createProtocolListing); michael@0: } michael@0: michael@0: function createProtocolListing(aProtocol) { michael@0: var uri = "about:" + aProtocol; michael@0: var li = document.createElement("li"); michael@0: var link = document.createElement("a"); michael@0: var text = document.createTextNode(uri); michael@0: michael@0: link.href = uri; michael@0: link.appendChild(text); michael@0: li.appendChild(link); michael@0: gContainer.appendChild(li); michael@0: }