gecko-dev/b2g/components/DebuggerActors.js
Ehsan Akhgari eac76d9772 Bug 1310845 - Remove support for mozapp iframes; r=fabrice,jryans,baku,mcmanus
This patch removes support for mozapp iframes, leaving support for
mozbrowser iframes intact.  Some of the code has been rewritten in order
to phrase things in terms of mozbrowser only, as opposed to mozbrowser
or app.  In some places, code that was only useful with apps has been
completely removed, so that the APIs consumed can also be removed.  In
some places where the notion of appId was bleeding out of this API, now
we use NO_APP_ID.  Other notions of appId which were restricted to this
API have been removed.
2016-11-16 09:13:38 -05:00

71 lines
2.2 KiB
JavaScript

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* 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";
const { Cu } = require("chrome");
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
const promise = require("promise");
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
const { BrowserTabList } = require("devtools/server/actors/webbrowser");
XPCOMUtils.defineLazyGetter(this, "Frames", function() {
const { Frames } =
Cu.import("resource://gre/modules/Frames.jsm", {});
return Frames;
});
/**
* Unlike the original BrowserTabList which iterates over XUL windows, we
* override many portions to refer to Frames for the info needed here.
*/
function B2GTabList(connection) {
BrowserTabList.call(this, connection);
this._listening = false;
}
B2GTabList.prototype = Object.create(BrowserTabList.prototype);
B2GTabList.prototype._getBrowsers = function() {
return Frames.list();
};
B2GTabList.prototype._getSelectedBrowser = function() {
return this._getBrowsers().find(frame => {
// Find the one visible browser (if any)
return !frame.classList.contains("hidden");
});
};
B2GTabList.prototype._checkListening = function() {
// The conditions from BrowserTabList are merged here, since we must listen to
// all events with our observer design.
this._listenForEventsIf(this._onListChanged && this._mustNotify ||
this._actorByBrowser.size > 0);
};
B2GTabList.prototype._listenForEventsIf = function(shouldListen) {
if (this._listening != shouldListen) {
let op = shouldListen ? "addObserver" : "removeObserver";
Frames[op](this);
this._listening = shouldListen;
}
};
B2GTabList.prototype.onFrameCreated = function(frame) {
this._notifyListChanged();
this._checkListening();
};
B2GTabList.prototype.onFrameDestroyed = function(frame) {
let actor = this._actorByBrowser.get(frame);
if (actor) {
this._handleActorClose(actor, frame);
}
};
exports.B2GTabList = B2GTabList;