tor-browser

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

dbg-browser-actors.js (2897B)


      1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 /* eslint-env commonjs */
      7 
      8 "use strict";
      9 /**
     10 * Fennec-specific actors.
     11 */
     12 
     13 const { RootActor } = require("devtools/server/actors/root");
     14 const {
     15  ActorRegistry,
     16 } = require("devtools/server/actors/utils/actor-registry");
     17 const {
     18  BrowserTabList,
     19  BrowserAddonList,
     20  sendShutdownEvent,
     21 } = require("devtools/server/actors/webbrowser");
     22 const {
     23  ServiceWorkerRegistrationActorList,
     24 } = require("devtools/server/actors/worker/service-worker-registration-list");
     25 const {
     26  WorkerDescriptorActorList,
     27 } = require("devtools/server/actors/worker/worker-descriptor-actor-list");
     28 
     29 const { ProcessActorList } = require("devtools/server/actors/process");
     30 
     31 /**
     32 * Construct a root actor appropriate for use in a server running in a
     33 * browser on Android. The returned root actor:
     34 * - respects the factories registered with ActorRegistry.addGlobalActor,
     35 * - uses a MobileTabList to supply tab actors,
     36 * - sends all navigator:browser window documents a Debugger:Shutdown event
     37 *   when it exits.
     38 *
     39 * * @param aConnection DevToolsServerConnection
     40 *        The conection to the client.
     41 */
     42 exports.createRootActor = function createRootActor(aConnection) {
     43  const parameters = {
     44    tabList: new MobileTabList(aConnection),
     45    addonList: new BrowserAddonList(aConnection),
     46    workerList: new WorkerDescriptorActorList(aConnection, {}),
     47    serviceWorkerRegistrationList: new ServiceWorkerRegistrationActorList(
     48      aConnection
     49    ),
     50    processList: new ProcessActorList(),
     51    globalActorFactories: ActorRegistry.globalActorFactories,
     52    onShutdown: sendShutdownEvent,
     53  };
     54  return new RootActor(aConnection, parameters);
     55 };
     56 
     57 /**
     58 * A live list of BrowserTabActors representing the current browser tabs,
     59 * to be provided to the root actor to answer 'listTabs' requests.
     60 *
     61 * This object also takes care of listening for TabClose events and
     62 * onCloseWindow notifications, and exiting the BrowserTabActors concerned.
     63 *
     64 * (See the documentation for RootActor for the definition of the "live
     65 * list" interface.)
     66 *
     67 * @param aConnection DevToolsServerConnection
     68 *     The connection in which this list's tab actors may participate.
     69 *
     70 * @see BrowserTabList for more a extensive description of how tab list objects
     71 *      work.
     72 */
     73 function MobileTabList(aConnection) {
     74  BrowserTabList.call(this, aConnection);
     75 }
     76 
     77 MobileTabList.prototype = Object.create(BrowserTabList.prototype);
     78 
     79 MobileTabList.prototype.constructor = MobileTabList;
     80 
     81 MobileTabList.prototype._getSelectedBrowser = function (aWindow) {
     82  return aWindow.browser;
     83 };
     84 
     85 MobileTabList.prototype._getChildren = function (aWindow) {
     86  return [aWindow.browser];
     87 };