mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 1385124 - Close tab when new tab redirects to external app; r=sebastian
When a site opens link in a new tab that redirects to an external app, we should close the new (empty) tab and return to the previous page. MozReview-Commit-ID: KXWA2d26RBh --HG-- extra : rebase_source : 601dd7a26b070102c7785f68bf2f3fec3f6f003b
This commit is contained in:
parent
9bc80ca4da
commit
549f69252b
@ -34,6 +34,15 @@ ContentDispatchChooser.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
_closeBlankWindow: function(aWindow) {
|
||||
if (!aWindow || aWindow.history.length) {
|
||||
return;
|
||||
}
|
||||
if (!aWindow.location.href || aWindow.location.href === "about:blank") {
|
||||
aWindow.close();
|
||||
}
|
||||
},
|
||||
|
||||
ask: function ask(aHandler, aWindowContext, aURI, aReason) {
|
||||
let window = null;
|
||||
try {
|
||||
@ -49,6 +58,8 @@ ContentDispatchChooser.prototype =
|
||||
// If we have more than one option, let the OS handle showing a list (if needed).
|
||||
if (aHandler.possibleApplicationHandlers.length > 1) {
|
||||
aHandler.launchWithURI(aURI, aWindowContext);
|
||||
this._closeBlankWindow(window);
|
||||
|
||||
} else {
|
||||
// xpcshell tests do not have an Android Bridge but we require Android
|
||||
// Bridge when using Messaging so we guard against this case. xpcshell
|
||||
@ -65,6 +76,8 @@ ContentDispatchChooser.prototype =
|
||||
|
||||
EventDispatcher.instance.sendRequestForResult(msg).then(() => {
|
||||
// Java opens an app on success: take no action.
|
||||
this._closeBlankWindow(window);
|
||||
|
||||
}, (data) => {
|
||||
if (data.isFallback) {
|
||||
// We always want to open a fallback url
|
||||
@ -79,6 +92,8 @@ ContentDispatchChooser.prototype =
|
||||
let millis = dwu.millisSinceLastUserInput;
|
||||
if (millis > 0 && millis >= 1000) {
|
||||
window.location.href = data.uri;
|
||||
} else {
|
||||
this._closeBlankWindow(window);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user