Bug 1363327 - register about:debugging dynamically using a manifest;r=ochameau
MozReview-Commit-ID: 2WG5zN6p1EK
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -376,16 +376,18 @@
@RESPATH@/browser/components/WebContentConverter.js
@RESPATH@/browser/components/BrowserComponents.manifest
@RESPATH@/browser/components/nsBrowserContentHandler.js
@RESPATH@/browser/components/nsBrowserGlue.js
@RESPATH@/browser/components/nsSetDefaultBrowser.manifest
@RESPATH@/browser/components/nsSetDefaultBrowser.js
@RESPATH@/browser/components/devtools-startup.manifest
@RESPATH@/browser/components/devtools-startup.js
+@RESPATH@/browser/components/aboutdebugging-registration.js
+@RESPATH@/browser/components/aboutdebugging.manifest
@RESPATH@/browser/components/webideCli.js
@RESPATH@/browser/components/webideComponents.manifest
@RESPATH@/browser/components/Experiments.manifest
@RESPATH@/browser/components/ExperimentsService.js
@RESPATH@/browser/components/browser-newtab.xpt
@RESPATH@/browser/components/aboutNewTabService.js
@RESPATH@/browser/components/NewTabComponents.manifest
@RESPATH@/components/Downloads.manifest
new file mode 100644
--- /dev/null
+++ b/devtools/shim/aboutdebugging-registration.js
@@ -0,0 +1,45 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+// Register the about:debugging URL, that allows to debug various targets such as addons,
+// workers and tabs by launching a dedicated DevTools toolbox for the selected target.
+// If DevTools are not installed, this about page will display a shim landing page
+// encouraging the user to download and install DevTools.
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
+const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
+
+const { nsIAboutModule } = Ci;
+
+function AboutDebugging() {}
+
+AboutDebugging.prototype = {
+ uri: Services.io.newURI("chrome://devtools/content/aboutdebugging/aboutdebugging.xhtml"),
+ classDescription: "about:debugging",
+ classID: Components.ID("1060afaf-dc9e-43da-8646-23a2faf48493"),
+ contractID: "@mozilla.org/network/protocol/about;1?what=debugging",
+
+ QueryInterface: XPCOMUtils.generateQI([nsIAboutModule]),
+
+ newChannel: function (uri, loadInfo) {
+ let chan = Services.io.newChannelFromURIWithLoadInfo(
+ this.uri,
+ loadInfo
+ );
+ chan.owner = Services.scriptSecurityManager.getSystemPrincipal();
+ return chan;
+ },
+
+ getURIFlags: function (uri) {
+ return nsIAboutModule.ALLOW_SCRIPT;
+ }
+};
+
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([
+ AboutDebugging
+]);
new file mode 100644
--- /dev/null
+++ b/devtools/shim/aboutdebugging.manifest
@@ -0,0 +1,2 @@
+component {1060afaf-dc9e-43da-8646-23a2faf48493} aboutdebugging-registration.js
+contract @mozilla.org/network/protocol/about;1?what=debugging {1060afaf-dc9e-43da-8646-23a2faf48493}
\ No newline at end of file
--- a/devtools/shim/moz.build
+++ b/devtools/shim/moz.build
@@ -1,9 +1,16 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
JAR_MANIFESTS += ['jar.mn']
+# Register the about:debugging page only for 'addon' and 'all' builds.
+if CONFIG['MOZ_DEVTOOLS'] != 'server':
+ EXTRA_COMPONENTS += [
+ 'aboutdebugging-registration.js',
+ 'aboutdebugging.manifest',
+ ]
+
XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
--- a/docshell/base/nsAboutRedirector.cpp
+++ b/docshell/base/nsAboutRedirector.cpp
@@ -51,22 +51,16 @@ static const RedirEntry kRedirMap[] = {
{ "config", "chrome://global/content/config.xul", 0 },
#ifdef MOZ_CRASHREPORTER
{ "crashes", "chrome://global/content/crashes.xhtml", 0 },
#endif
{
"credits", "https://www.mozilla.org/credits/",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
},
-#ifdef MOZ_DEVTOOLS_ALL
- {
- "debugging", "chrome://devtools/content/aboutdebugging/aboutdebugging.xhtml",
- nsIAboutModule::ALLOW_SCRIPT
- },
-#endif
{
"license", "chrome://global/content/license.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::MAKE_LINKABLE
},
{
"logo", "chrome://branding/content/about.png",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
--- a/docshell/build/nsDocShellModule.cpp
+++ b/docshell/build/nsDocShellModule.cpp
@@ -172,19 +172,16 @@ const mozilla::Module::ContractIDEntry k
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "addons", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "buildconfig", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "checkerboard", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "config", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
#ifdef MOZ_CRASHREPORTER
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "crashes", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
#endif
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "credits", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-#ifdef MOZ_DEVTOOLS_ALL
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "debugging", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-#endif
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "license", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "logo", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "memory", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "mozilla", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "neterror", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "networking", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "newaddon", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "performance", &kNS_ABOUT_REDIRECTOR_MODULE_CID },