mobile/android/chrome/content/dbg-browser-actors.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/chrome/content/dbg-browser-actors.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +"use strict";
    1.10 +/**
    1.11 + * Fennec-specific actors.
    1.12 + */
    1.13 +
    1.14 +/**
    1.15 + * Construct a root actor appropriate for use in a server running in a
    1.16 + * browser on Android. The returned root actor:
    1.17 + * - respects the factories registered with DebuggerServer.addGlobalActor,
    1.18 + * - uses a MobileTabList to supply tab actors,
    1.19 + * - sends all navigator:browser window documents a Debugger:Shutdown event
    1.20 + *   when it exits.
    1.21 + *
    1.22 + * * @param aConnection DebuggerServerConnection
    1.23 + *        The conection to the client.
    1.24 + */
    1.25 +function createRootActor(aConnection)
    1.26 +{
    1.27 +  let parameters = {
    1.28 +    tabList: new MobileTabList(aConnection),
    1.29 +    addonList: new BrowserAddonList(aConnection),
    1.30 +    globalActorFactories: DebuggerServer.globalActorFactories,
    1.31 +    onShutdown: sendShutdownEvent
    1.32 +  };
    1.33 +  return new RootActor(aConnection, parameters);
    1.34 +}
    1.35 +
    1.36 +/**
    1.37 + * A live list of BrowserTabActors representing the current browser tabs,
    1.38 + * to be provided to the root actor to answer 'listTabs' requests.
    1.39 + *
    1.40 + * This object also takes care of listening for TabClose events and
    1.41 + * onCloseWindow notifications, and exiting the BrowserTabActors concerned.
    1.42 + *
    1.43 + * (See the documentation for RootActor for the definition of the "live
    1.44 + * list" interface.)
    1.45 + *
    1.46 + * @param aConnection DebuggerServerConnection
    1.47 + *     The connection in which this list's tab actors may participate.
    1.48 + *
    1.49 + * @see BrowserTabList for more a extensive description of how tab list objects
    1.50 + *      work.
    1.51 + */
    1.52 +function MobileTabList(aConnection)
    1.53 +{
    1.54 +  BrowserTabList.call(this, aConnection);
    1.55 +}
    1.56 +
    1.57 +MobileTabList.prototype = Object.create(BrowserTabList.prototype);
    1.58 +
    1.59 +MobileTabList.prototype.constructor = MobileTabList;
    1.60 +
    1.61 +MobileTabList.prototype._getSelectedBrowser = function(aWindow) {
    1.62 +  return aWindow.BrowserApp.selectedBrowser;
    1.63 +};
    1.64 +
    1.65 +MobileTabList.prototype._getChildren = function(aWindow) {
    1.66 +  return aWindow.BrowserApp.tabs.map(tab => tab.browser);
    1.67 +};

mercurial