Bug 1363327 - register about:debugging via manifest draft
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 12 May 2017 16:12:45 +0200
changeset 576936 8eedfe3fa2dcefcc94aaa2b3e61a3a03171f1fa8
parent 576933 6f7ac2c6820ff54135330b0f7857a6ea422bb289
child 576937 d903ca619091c9bef05e8a0e7d9c0b4f963621ce
push id58535
push userjdescottes@mozilla.com
push dateFri, 12 May 2017 14:16:03 +0000
bugs1363327
milestone55.0a1
Bug 1363327 - register about:debugging via manifest MozReview-Commit-ID: Ec7yRRyTITo
devtools/moz.build
devtools/shim/aboutdebugging-registration.js
devtools/shim/aboutdebugging.manifest
--- a/devtools/moz.build
+++ b/devtools/moz.build
@@ -13,16 +13,21 @@ if CONFIG['MOZ_DEVTOOLS'] == 'all':
     ]
 
 DIRS += [
     'server',
     'shared',
     'shim',
 ]
 
+EXTRA_COMPONENTS += [
+    'shim/aboutdebugging-registration.js',
+    'shim/aboutdebugging.manifest',
+]
+
 # /browser uses DIST_SUBDIR.  We opt-in to this treatment when building
 # DevTools for the browser to keep the root omni.ja slim for use by external XUL
 # apps.  Mulet also uses this since it includes /browser.
 if CONFIG['MOZ_BUILD_APP'] == 'browser':
     DIST_SUBDIR = 'browser'
     export('DIST_SUBDIR')
 
 with Files('**'):
new file mode 100644
--- /dev/null
+++ b/devtools/shim/aboutdebugging-registration.js
@@ -0,0 +1,43 @@
+/* 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 about:devtools-toolbox which allows to open a devtools toolbox
+// in a Firefox tab or a custom html iframe in browser.html
+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 || nsIAboutModule.ENABLE_INDEXED_DB;
+  }
+};
+
+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