Bug 1669129 - [devtools] Enable devtools.overflow.debugging.enabled. r=jdescottes
[gecko.git] / toolkit / modules / AboutPagesUtils.jsm
blob2b5f27ac86523eea076540adf6e529f6085e24b9
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
2  * vim: sw=2 ts=2 sts=2 expandtab
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 "use strict";
9 const EXPORTED_SYMBOLS = ["AboutPagesUtils"];
11 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
12 const { XPCOMUtils } = ChromeUtils.import(
13   "resource://gre/modules/XPCOMUtils.jsm"
16 const AboutPagesUtils = {};
18 XPCOMUtils.defineLazyGetter(AboutPagesUtils, "visibleAboutUrls", () => {
19   const urls = [];
20   const rx = /@mozilla.org\/network\/protocol\/about;1\?what\=(.*)$/;
21   for (const cid in Cc) {
22     const result = cid.match(rx);
23     if (!result) {
24       continue;
25     }
26     const [, aboutType] = result;
27     try {
28       const am = Cc[cid].getService(Ci.nsIAboutModule);
29       const uri = Services.io.newURI(`about:${aboutType}`);
30       const flags = am.getURIFlags(uri);
31       if (!(flags & Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT)) {
32         urls.push(`about:${aboutType}`);
33       }
34     } catch (e) {
35       // getService() might have thrown if the component doesn't actually
36       // implement nsIAboutModule
37     }
38   }
39   urls.sort();
40   return urls;
41 });