From 96bdaf839ba51416cfef010b2543fd99e76648db Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sun, 29 Jul 2018 23:08:52 -0700 Subject: [PATCH] Bug 1472491: Part 5w - Add PageMetadataChild actor. r=mconley MozReview-Commit-ID: DpTG8tTJCL4 --HG-- rename : browser/base/content/content.js => browser/actors/PageMetadataChild.jsm extra : rebase_source : 6b6d4cd46b43ea784a05b60120b819500f2f4601 --- browser/actors/PageMetadataChild.jsm | 33 ++++++++++++++++++++++++++++ browser/actors/moz.build | 1 + browser/base/content/content.js | 26 ---------------------- browser/components/nsBrowserGlue.js | 10 +++++++++ 4 files changed, 44 insertions(+), 26 deletions(-) create mode 100644 browser/actors/PageMetadataChild.jsm diff --git a/browser/actors/PageMetadataChild.jsm b/browser/actors/PageMetadataChild.jsm new file mode 100644 index 000000000000..ff1512dd443e --- /dev/null +++ b/browser/actors/PageMetadataChild.jsm @@ -0,0 +1,33 @@ +/* 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 = ["PageMetadataChild"]; + +ChromeUtils.import("resource://gre/actors/ActorChild.jsm"); + +ChromeUtils.defineModuleGetter(this, "ContextMenuChild", + "resource:///modules/ContextMenuChild.jsm"); +ChromeUtils.defineModuleGetter(this, "PageMetadata", + "resource://gre/modules/PageMetadata.jsm"); + +class PageMetadataChild extends ActorChild { + receiveMessage(message) { + switch (message.name) { + case "PageMetadata:GetPageData": { + let target = ContextMenuChild.getTarget(this.mm, message); + let result = PageMetadata.getData(this.content.document, target); + this.mm.sendAsyncMessage("PageMetadata:PageDataResult", result); + break; + } + case "PageMetadata:GetMicroformats": { + let target = ContextMenuChild.getTarget(this.mm, message); + let result = PageMetadata.getMicroformats(this.content.document, target); + this.mm.sendAsyncMessage("PageMetadata:MicroformatsResult", result); + break; + } + } + } +} diff --git a/browser/actors/moz.build b/browser/actors/moz.build index 959138bb0ddf..b8d8cb7cf698 100644 --- a/browser/actors/moz.build +++ b/browser/actors/moz.build @@ -28,6 +28,7 @@ FINAL_TARGET_FILES.actors += [ 'NetErrorChild.jsm', 'OfflineAppsChild.jsm', 'PageInfoChild.jsm', + 'PageMetadataChild.jsm', 'PageStyleChild.jsm', 'PluginChild.jsm', 'URIFixupChild.jsm', diff --git a/browser/base/content/content.js b/browser/base/content/content.js index 13d9a489a69f..efd88f3c4dd9 100644 --- a/browser/base/content/content.js +++ b/browser/base/content/content.js @@ -22,7 +22,6 @@ XPCOMUtils.defineLazyModuleGetters(this, { LoginFormFactory: "resource://gre/modules/LoginManagerContent.jsm", InsecurePasswordUtils: "resource://gre/modules/InsecurePasswordUtils.jsm", FormSubmitObserver: "resource:///modules/FormSubmitObserver.jsm", - PageMetadata: "resource://gre/modules/PageMetadata.jsm", ContextMenuChild: "resource:///actors/ContextMenuChild.jsm", }); @@ -81,28 +80,3 @@ addMessageListener("rtcpeer:Deny", ContentWebRTCShim); addMessageListener("webrtc:Allow", ContentWebRTCShim); addMessageListener("webrtc:Deny", ContentWebRTCShim); addMessageListener("webrtc:StopSharing", ContentWebRTCShim); - -var PageMetadataMessenger = { - init() { - addMessageListener("PageMetadata:GetPageData", this); - addMessageListener("PageMetadata:GetMicroformats", this); - this.init = null; - }, - receiveMessage(message) { - switch (message.name) { - case "PageMetadata:GetPageData": { - let target = ContextMenuChild.getTarget(global, message); - let result = PageMetadata.getData(content.document, target); - sendAsyncMessage("PageMetadata:PageDataResult", result); - break; - } - case "PageMetadata:GetMicroformats": { - let target = ContextMenuChild.getTarget(global, message); - let result = PageMetadata.getMicroformats(content.document, target); - sendAsyncMessage("PageMetadata:MicroformatsResult", result); - break; - } - } - } -}; -PageMetadataMessenger.init(); diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index 827a13afedc3..ae6e95a482af 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -169,6 +169,16 @@ let ACTORS = { }, }, + PageMetadata: { + child: { + module: "resource:///actors/PageMetadataChild.jsm", + messages: [ + "PageMetadata:GetPageData", + "PageMetadata:GetMicroformats", + ], + }, + }, + PageStyle: { child: { module: "resource:///actors/PageStyleChild.jsm",