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