2019-06-11 16:05:33 +03:00
|
|
|
/* 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";
|
|
|
|
|
|
|
|
var EXPORTED_SYMBOLS = ["BrowserTabParent"];
|
|
|
|
|
|
|
|
class BrowserTabParent extends JSWindowActorParent {
|
|
|
|
receiveMessage(message) {
|
|
|
|
let browser = this.manager.browsingContext.embedderElement;
|
|
|
|
if (!browser) {
|
|
|
|
return; // Can happen sometimes if browser is being destroyed
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:19:14 +03:00
|
|
|
if (browser.outerBrowser) {
|
|
|
|
browser = browser.outerBrowser; // handle RDM mode
|
|
|
|
}
|
|
|
|
|
2019-06-11 16:05:33 +03:00
|
|
|
let gBrowser = browser.ownerGlobal.gBrowser;
|
2019-07-09 23:58:51 +03:00
|
|
|
|
2019-06-11 16:05:33 +03:00
|
|
|
if (!gBrowser) {
|
|
|
|
// Note: gBrowser might be null because this message might be received
|
|
|
|
// from the extension process. There's still an embedderElement involved,
|
|
|
|
// but it's the one coming from dummy.xul.
|
|
|
|
// This should probably be fixed by adding support to specifying "group: 'browsers"
|
|
|
|
// in the registerWindowActor options/. See bug 1557118.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-09 23:58:51 +03:00
|
|
|
if (!gBrowser.tabpanels || !gBrowser.tabpanels.contains(browser)) {
|
|
|
|
// Note: This is ignoring browser elements related to extension pages that are not loaded
|
|
|
|
// as a browser tab (like sidebars, devtools panels and options pages embedded into
|
|
|
|
// about:addons, browserAction and pageAction popup panels.
|
|
|
|
// (Ideally we could call gBrowser.getTabForBrowser, but it returns undefined early in
|
|
|
|
// the tab browser creation and we would ignore browsers related to newly created tabs).
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-11 16:05:33 +03:00
|
|
|
switch (message.name) {
|
|
|
|
case "Browser:WindowCreated": {
|
|
|
|
gBrowser.announceWindowCreated(browser, message.data.userContextId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case "Browser:FirstPaint": {
|
|
|
|
browser.ownerGlobal.gBrowserInit._firstBrowserPaintDeferred.resolve();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:19:14 +03:00
|
|
|
case "Browser:LoadURI": {
|
|
|
|
gBrowser.ownerGlobal.RedirectLoad(browser, message.data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-09-12 15:08:41 +03:00
|
|
|
case "PointerLock:Entered": {
|
2019-06-11 16:05:33 +03:00
|
|
|
browser.ownerGlobal.PointerLock.entered(message.data.originNoSuffix);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-09-12 15:08:41 +03:00
|
|
|
case "PointerLock:Exited":
|
2019-06-11 16:05:33 +03:00
|
|
|
browser.ownerGlobal.PointerLock.exited();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|