Bug 1472491: Part 5β - Add ShieldFrameChild actor. r=mconley

MozReview-Commit-ID: 5HqAEEO7nJy

--HG--
rename : toolkit/components/normandy/content/ShieldFrameListener.jsm => toolkit/components/normandy/content/ShieldFrameChild.jsm
extra : rebase_source : b480265ad0746c700716ed9011db4b2c0f39b9e8
This commit is contained in:
Kris Maglione 2018-07-29 23:45:18 -07:00
Родитель 4e1ac07ba3
Коммит 66f4ed7652
3 изменённых файлов: 13 добавлений и 32 удалений

Просмотреть файл

@ -220,6 +220,16 @@ let ACTORS = {
},
},
ShieldFrame: {
child: {
module: "resource://normandy-content/ShieldFrameChild.jsm",
events: {
"ShieldPageEvent": {wantUntrusted: true},
},
matches: ["about:studies"],
},
},
URIFixup: {
child: {
module: "resource:///actors/URIFixupChild.jsm",

Просмотреть файл

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["ShieldFrameListener"];
var EXPORTED_SYMBOLS = ["ShieldFrameChild"];
/**
* Listen for DOM events bubbling up from the about:studies page, and perform
@ -15,6 +15,7 @@ var EXPORTED_SYMBOLS = ["ShieldFrameListener"];
* is opened.
*/
ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
@ -36,17 +37,8 @@ XPCOMUtils.defineLazyGetter(this, "gStringBundle", function() {
* @implements nsIMessageListener
* @implements EventListener
*/
class ShieldFrameListener {
constructor(mm) {
this.mm = mm;
}
class ShieldFrameChild extends ActorChild {
handleEvent(event) {
// Abort if the current page isn't about:studies.
if (!this.ensureTrustedOrigin()) {
return;
}
// We waited until after we received an event to register message listeners
// in order to save resources for tabs that don't ever load about:studies.
this.mm.addMessageListener("Shield:ShuttingDown", this);
@ -92,14 +84,6 @@ class ShieldFrameListener {
}
}
/**
* Check that the current webpage's origin is about:studies.
* @return {Boolean}
*/
ensureTrustedOrigin() {
return this.mm.content.document.documentURI.startsWith("about:studies");
}
/**
* Handle messages from the parent process.
* @param {Object} message
@ -125,11 +109,6 @@ class ShieldFrameListener {
* @param {Object} detail
*/
triggerPageCallback(type, detail) {
// Do not communicate with untrusted pages.
if (!this.ensureTrustedOrigin()) {
return;
}
let {content} = this.mm;
// Clone details and use the event class from the unprivileged context.

Просмотреть файл

@ -26,12 +26,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "formFill",
var global = this;
XPCOMUtils.defineLazyProxy(this, "ShieldFrameListener", () => {
let tmp = {};
ChromeUtils.import("resource://normandy-content/ShieldFrameListener.jsm", tmp);
return new tmp.ShieldFrameListener(global);
});
XPCOMUtils.defineLazyProxy(this, "UITourListener", () => {
let tmp = {};
ChromeUtils.import("resource:///modules/ContentUITour.jsm", tmp);
@ -188,6 +182,4 @@ let ExtFind = {
ExtFind.init();
addEventListener("ShieldPageEvent", ShieldFrameListener, false, true);
addEventListener("mozUITour", UITourListener, false, true);