tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

GeckoViewActorParent.sys.mjs (1474B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 import { GeckoViewUtils } from "resource://gre/modules/GeckoViewUtils.sys.mjs";
      6 
      7 export class GeckoViewActorParent extends JSWindowActorParent {
      8  static initLogging(aModuleName) {
      9    const tag = aModuleName.replace("GeckoView", "");
     10    return GeckoViewUtils.initLogging(tag);
     11  }
     12 
     13  get browser() {
     14    return this.browsingContext.top.embedderElement;
     15  }
     16 
     17  get window() {
     18    const { browsingContext } = this;
     19    // If this is a chrome actor, the chrome window will be at
     20    // browsingContext.window.
     21    if (!browsingContext.isContent && browsingContext.window) {
     22      return browsingContext.window;
     23    }
     24    return this.browser?.ownerGlobal;
     25  }
     26 
     27  get eventDispatcher() {
     28    return this.window?.moduleManager.eventDispatcher;
     29  }
     30 
     31  receiveMessage(aMessage) {
     32    if (!this.window) {
     33      // If we have no window, it means that this browsingContext has been
     34      // destroyed already and there's nothing to do here for us.
     35      debug`receiveMessage window destroyed ${aMessage.name} ${aMessage.data?.type}`;
     36      return null;
     37    }
     38 
     39    // By default messages are forwarded to the module.
     40    return this.window.moduleManager.onMessageFromActor(this.name, aMessage);
     41  }
     42 }
     43 
     44 const { debug, warn } = GeckoViewUtils.initLogging("GeckoViewActorParent");