michael@0: /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: /** michael@0: * Fennec-specific actors. michael@0: */ michael@0: michael@0: /** michael@0: * Construct a root actor appropriate for use in a server running in a michael@0: * browser on Android. The returned root actor: michael@0: * - respects the factories registered with DebuggerServer.addGlobalActor, michael@0: * - uses a MobileTabList to supply tab actors, michael@0: * - sends all navigator:browser window documents a Debugger:Shutdown event michael@0: * when it exits. michael@0: * michael@0: * * @param aConnection DebuggerServerConnection michael@0: * The conection to the client. michael@0: */ michael@0: function createRootActor(aConnection) michael@0: { michael@0: let parameters = { michael@0: tabList: new MobileTabList(aConnection), michael@0: addonList: new BrowserAddonList(aConnection), michael@0: globalActorFactories: DebuggerServer.globalActorFactories, michael@0: onShutdown: sendShutdownEvent michael@0: }; michael@0: return new RootActor(aConnection, parameters); michael@0: } michael@0: michael@0: /** michael@0: * A live list of BrowserTabActors representing the current browser tabs, michael@0: * to be provided to the root actor to answer 'listTabs' requests. michael@0: * michael@0: * This object also takes care of listening for TabClose events and michael@0: * onCloseWindow notifications, and exiting the BrowserTabActors concerned. michael@0: * michael@0: * (See the documentation for RootActor for the definition of the "live michael@0: * list" interface.) michael@0: * michael@0: * @param aConnection DebuggerServerConnection michael@0: * The connection in which this list's tab actors may participate. michael@0: * michael@0: * @see BrowserTabList for more a extensive description of how tab list objects michael@0: * work. michael@0: */ michael@0: function MobileTabList(aConnection) michael@0: { michael@0: BrowserTabList.call(this, aConnection); michael@0: } michael@0: michael@0: MobileTabList.prototype = Object.create(BrowserTabList.prototype); michael@0: michael@0: MobileTabList.prototype.constructor = MobileTabList; michael@0: michael@0: MobileTabList.prototype._getSelectedBrowser = function(aWindow) { michael@0: return aWindow.BrowserApp.selectedBrowser; michael@0: }; michael@0: michael@0: MobileTabList.prototype._getChildren = function(aWindow) { michael@0: return aWindow.BrowserApp.tabs.map(tab => tab.browser); michael@0: };