Bug 1472491: Part 5κ - Add ManifestMessagesChild actor. r?felipe draft
authorKris Maglione <maglione.k@gmail.com>
Mon, 30 Jul 2018 11:39:52 -0700
changeset 825215 574124549bdd697c9b2e5729d9abdfaa67cc3b51
parent 825214 9c99fb57c6008fb3e4d70712a0ebd49325cc29dd
child 825216 1505e53137dc623c3386ef78d1b42ed94b352ed1
push id118036
push usermaglione.k@gmail.com
push dateWed, 01 Aug 2018 02:23:07 +0000
reviewersfelipe
bugs1472491
milestone63.0a1
Bug 1472491: Part 5κ - Add ManifestMessagesChild actor. r?felipe MozReview-Commit-ID: 20toouW9YzT
browser/base/content/tab-content.js
dom/ipc/ManifestMessages.jsm
dom/ipc/ManifestMessagesChild.jsm
dom/ipc/moz.build
toolkit/modules/ActorManagerParent.jsm
--- a/browser/base/content/tab-content.js
+++ b/browser/base/content/tab-content.js
@@ -24,22 +24,16 @@ ChromeUtils.import("resource://gre/modul
 ActorManagerChild.attach(this, "browsers");
 
 // TabChildGlobal
 var global = this;
 
 XPCOMUtils.defineLazyProxy(this, "LightweightThemeChildHelper",
   "resource:///modules/LightweightThemeChildHelper.jsm");
 
-XPCOMUtils.defineLazyProxy(this, "ManifestMessages", () => {
-  let tmp = {};
-  ChromeUtils.import("resource://gre/modules/ManifestMessages.jsm", tmp);
-  return new tmp.ManifestMessages(global);
-});
-
 let themeablePagesWhitelist = new Set([
   "about:home",
   "about:newtab",
   "about:welcome",
 ]);
 
 addEventListener("pageshow", function({ originalTarget }) {
   if (originalTarget.defaultView == content && themeablePagesWhitelist.has(content.document.documentURI)) {
@@ -91,13 +85,8 @@ Services.obs.notifyObservers(this, "tab-
 
 // Remove this once bug 1397365 is fixed.
 addEventListener("MozAfterPaint", function onFirstNonBlankPaint() {
   if (content.document.documentURI == "about:blank" && !content.opener)
     return;
   removeEventListener("MozAfterPaint", onFirstNonBlankPaint);
   sendAsyncMessage("Browser:FirstNonBlankPaint");
 });
-
-addMessageListener("DOM:WebManifest:hasManifestLink", ManifestMessages);
-addMessageListener("DOM:ManifestObtainer:Obtain", ManifestMessages);
-addMessageListener("DOM:Manifest:FireAppInstalledEvent", ManifestMessages);
-addMessageListener("DOM:WebManifest:fetchIcon", ManifestMessages);
rename from dom/ipc/ManifestMessages.jsm
rename to dom/ipc/ManifestMessagesChild.jsm
--- a/dom/ipc/ManifestMessages.jsm
+++ b/dom/ipc/ManifestMessagesChild.jsm
@@ -8,32 +8,29 @@
  * It searches a top-level browsing context for
  * a <link rel=manifest> element. Then fetches
  * and processes the linked manifest.
  *
  * BUG: https://bugzilla.mozilla.org/show_bug.cgi?id=1083410
  */
 "use strict";
 
-var EXPORTED_SYMBOLS = ["ManifestMessages"];
+var EXPORTED_SYMBOLS = ["ManifestMessagesChild"];
 
+ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.defineModuleGetter(this, "ManifestObtainer",
                                "resource://gre/modules/ManifestObtainer.jsm");
 ChromeUtils.defineModuleGetter(this, "ManifestFinder",
                                "resource://gre/modules/ManifestFinder.jsm");
 ChromeUtils.defineModuleGetter(this, "ManifestIcons",
                                "resource://gre/modules/ManifestIcons.jsm");
 
-class ManifestMessages {
-  constructor(mm) {
-    this.mm = mm;
-  }
-
+class ManifestMessagesChild extends ActorChild {
   receiveMessage(message) {
     switch (message.name) {
     case "DOM:WebManifest:hasManifestLink":
       return this.hasManifestLink(message);
     case "DOM:ManifestObtainer:Obtain":
       return this.obtainManifest(message);
     case "DOM:Manifest:FireAppInstalledEvent":
       return this.fireAppInstalledEvent(message);
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -9,17 +9,17 @@ with Files("**"):
 
 XPIDL_SOURCES += [
     'nsIHangReport.idl',
 ]
 
 XPIDL_MODULE = 'dom'
 
 EXTRA_JS_MODULES += [
-    'ManifestMessages.jsm',
+    'ManifestMessagesChild.jsm',
 ]
 
 EXPORTS.mozilla.dom.ipc += [
     'IdType.h',
     'MemMapSnapshot.h',
     'SharedMap.h',
     'SharedMapChangeEvent.h',
     'SharedStringMap.h',
--- a/toolkit/modules/ActorManagerParent.jsm
+++ b/toolkit/modules/ActorManagerParent.jsm
@@ -174,16 +174,29 @@ let ACTORS = {
       events: {
         "DOMAutoComplete": {},
         "DOMFormHasPassword": {},
         "DOMInputPasswordAdded": {},
       },
     },
   },
 
+  ManifestMessages: {
+    module: "resource://gre/modules/ManifestMessages",
+    child: {
+      group: "browsers",
+      messages: [
+        "DOM:Manifest:FireAppInstalledEvent",
+        "DOM:ManifestObtainer:Obtain",
+        "DOM:WebManifest:fetchIcon",
+        "DOM:WebManifest:hasManifestLink",
+      ],
+    },
+  },
+
   PopupBlocking: {
     module: "resource://gre/modules/PopupBlocking",
     child: {
       events: {
         "DOMPopupBlocked": {capture: true},
       },
     },
   },