mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
eac76d9772
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.
71 lines
2.2 KiB
JavaScript
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;
|