Bug 1472491: Part 5v - Add AboutHomeChild actor. r?felipe draft
authorKris Maglione <maglione.k@gmail.com>
Sun, 29 Jul 2018 22:34:20 -0700
changeset 825201 e759b049dd8ebe64ba128e87f87871f8939cf24c
parent 825200 ee69af0cc5e7f02a7fa5ff87b0b019736cec1250
child 825202 ce0e6bf91c8ca00824e42d15f6fdd7f89e2d460e
push id118036
push usermaglione.k@gmail.com
push dateWed, 01 Aug 2018 02:23:07 +0000
reviewersfelipe
bugs1472491
milestone63.0a1
Bug 1472491: Part 5v - Add AboutHomeChild actor. r?felipe MozReview-Commit-ID: FyCY7PCGD2H
browser/base/content/tab-content.js
browser/components/nsBrowserGlue.js
browser/modules/AboutHomeChild.jsm
browser/modules/moz.build
--- a/browser/base/content/tab-content.js
+++ b/browser/base/content/tab-content.js
@@ -21,26 +21,16 @@ ChromeUtils.defineModuleGetter(this, "Pr
 
 ChromeUtils.import("resource://gre/modules/ActorManagerChild.jsm");
 
 ActorManagerChild.attach(this, "browsers");
 
 // TabChildGlobal
 var global = this;
 
-addMessageListener("Browser:HideSessionRestoreButton", function(message) {
-  // Hide session restore button on about:home
-  let doc = content.document;
-  let container;
-  if (doc.documentURI.toLowerCase() == "about:home" &&
-      (container = doc.getElementById("sessionRestoreContainer"))) {
-    container.hidden = true;
-  }
-});
-
 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);
 });
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -7,16 +7,27 @@ const XULNS = "http://www.mozilla.org/ke
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 ChromeUtils.defineModuleGetter(this, "ActorManagerParent",
                                "resource://gre/modules/ActorManagerParent.jsm");
 
 let ACTORS = {
+  AboutHome: {
+    module: "resource:///modules/AboutHome",
+    child: {
+      group: "browsers",
+      matches: ["about:home"],
+      messages: [
+        "Browser:HideSessionRestoreButton",
+      ],
+    },
+  },
+
   AboutReader: {
     module: "resource:///modules/AboutReader",
     child: {
       group: "browsers",
       events: {
         "AboutReaderContentLoaded": {wantUntrusted: true},
         "DOMContentLoaded": {},
         "pageshow": {},
new file mode 100644
--- /dev/null
+++ b/browser/modules/AboutHomeChild.jsm
@@ -0,0 +1,22 @@
+/* vim: set ts=2 sw=2 sts=2 et tw=80: */
+/* 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";
+
+var EXPORTED_SYMBOLS = ["AboutHomeChild"];
+
+ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
+
+class AboutHomeChild extends ActorChild {
+  receiveMessage(message) {
+    if (message.name == "Browser:HideSessionRestoreButton") {
+      let doc = this.content.document;
+      let container;
+      if (doc.documentURI.toLowerCase() == "about:home" &&
+          (container = doc.getElementById("sessionRestoreContainer"))) {
+        container.hidden = true;
+      }
+    }
+  }
+}
--- a/browser/modules/moz.build
+++ b/browser/modules/moz.build
@@ -127,16 +127,17 @@ with Files("ZoomUI.jsm"):
 
 BROWSER_CHROME_MANIFESTS += [
     'test/browser/browser.ini',
     'test/browser/formValidation/browser.ini',
 ]
 XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']
 
 EXTRA_JS_MODULES += [
+    'AboutHomeChild.jsm',
     'AboutNewTab.jsm',
     'AboutReaderChild.jsm',
     'AsyncTabSwitcher.jsm',
     'BlockedSiteChild.jsm',
     'BrowserErrorReporter.jsm',
     'BrowserTabChild.jsm',
     'BrowserUsageTelemetry.jsm',
     'BrowserWindowTracker.jsm',