Bug 1472491: Part 5γ - Add UITourChild actor. r=MattN draft
authorKris Maglione <maglione.k@gmail.com>
Sun, 29 Jul 2018 23:47:26 -0700
changeset 828464 bb638221f8681760e78f06b70ed14066f049b1f8
parent 828463 7ece0606d4197e0b1fc1acb94bf476d583008908
child 828465 9d3e9ff2a60aa01ac44ef6b66b4e8d06011fe617
push id118680
push usermaglione.k@gmail.com
push dateFri, 10 Aug 2018 23:04:22 +0000
reviewersMattN
bugs1472491
milestone63.0a1
Bug 1472491: Part 5γ - Add UITourChild actor. r=MattN MozReview-Commit-ID: 7Pfu7sSOE1i
browser/components/nsBrowserGlue.js
browser/components/uitour/ContentUITour.jsm
browser/components/uitour/UITourChild.jsm
browser/components/uitour/moz.build
toolkit/content/browser-content.js
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -225,16 +225,26 @@ let ACTORS = {
       module: "resource://normandy-content/ShieldFrameChild.jsm",
       events: {
         "ShieldPageEvent": {wantUntrusted: true},
       },
       matches: ["about:studies"],
     },
   },
 
+  UITour: {
+    child: {
+      module: "resource:///modules/UITourChild.jsm",
+      events: {
+        "mozUITour": {wantUntrusted: true},
+      },
+      permissions: ["uitour"],
+    },
+  },
+
   URIFixup: {
     child: {
       module: "resource:///actors/URIFixupChild.jsm",
       group: "browsers",
       observers: ["keyword-uri-fixup"],
     },
   },
 };
rename from browser/components/uitour/ContentUITour.jsm
rename to browser/components/uitour/UITourChild.jsm
--- a/browser/components/uitour/ContentUITour.jsm
+++ b/browser/components/uitour/UITourChild.jsm
@@ -1,24 +1,21 @@
 /* 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/. */
 
-var EXPORTED_SYMBOLS = ["UITourListener"];
+var EXPORTED_SYMBOLS = ["UITourChild"];
 
+ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 const PREF_TEST_WHITELIST = "browser.uitour.testingOrigins";
 const UITOUR_PERMISSION   = "uitour";
 
-class UITourListener {
-  constructor(mm) {
-    this.mm = mm;
-  }
-
+class UITourChild extends ActorChild {
   handleEvent(event) {
     if (!Services.prefs.getBoolPref("browser.uitour.enabled")) {
       return;
     }
     if (!this.ensureTrustedOrigin()) {
       return;
     }
     this.mm.addMessageListener("UITour:SendPageCallback", this);
--- a/browser/components/uitour/moz.build
+++ b/browser/components/uitour/moz.build
@@ -1,15 +1,15 @@
 # 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/.
 
 EXTRA_JS_MODULES += [
-    'ContentUITour.jsm',
     'UITour.jsm',
+    'UITourChild.jsm',
 ]
 
 BROWSER_CHROME_MANIFESTS += [
     'test/browser.ini',
 ]
 
 with Files('**'):
     BUG_COMPONENT = ('Firefox', 'Tours')
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -19,22 +19,16 @@ ChromeUtils.defineModuleGetter(this, "Au
   "resource://gre/modules/AutoScrollController.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "formFill",
                                    "@mozilla.org/satchel/form-fill-controller;1",
                                    "nsIFormFillController");
 
 var global = this;
 
-XPCOMUtils.defineLazyProxy(this, "UITourListener", () => {
-  let tmp = {};
-  ChromeUtils.import("resource:///modules/ContentUITour.jsm", tmp);
-  return new tmp.UITourListener(global);
-});
-
 // Lazily load the finder code
 addMessageListener("Finder:Initialize", function() {
   let {RemoteFinderListener} = ChromeUtils.import("resource://gre/modules/RemoteFinder.jsm", {});
   new RemoteFinderListener(global);
 });
 
 var AutoScrollListener = {
   handleEvent(event) {
@@ -139,10 +133,8 @@ let AutoComplete = {
         this._connected = false;
       }
       break;
     }
   },
 };
 
 AutoComplete.init();
-
-addEventListener("mozUITour", UITourListener, false, true);