Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #6782: Remove empty tabs when handling external URLs (#7033)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson authored Feb 28, 2023
1 parent 8ecd04d commit b1352d7
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,8 @@ extension BrowserViewController {
_ url: URL,
tab: Tab?,
navigationAction: WKNavigationAction,
openedURLCompletionHandler: ((Bool) -> Void)? = nil) {
openedURLCompletionHandler: ((Bool) -> Void)? = nil
) {

let isMainFrame = navigationAction.targetFrame?.isMainFrame == true

Expand All @@ -765,6 +766,13 @@ extension BrowserViewController {
}
}

// If the tab is empty when handling an external URL we should remove the tab once the user decides
func removeTabIfEmpty() {
if let tab = tab, tab.url == nil {
tabManager.removeTab(tab)
}
}

view.endEditing(true)
let popup = AlertPopupView(
imageView: nil,
Expand All @@ -774,10 +782,12 @@ extension BrowserViewController {
titleSize: 21
)
popup.addButton(title: Strings.openExternalAppURLDontAllow, fontSize: 16) { () -> PopupViewDismissType in
removeTabIfEmpty()
return .flyDown
}
popup.addButton(title: Strings.openExternalAppURLAllow, type: .primary, fontSize: 16) { () -> PopupViewDismissType in
UIApplication.shared.open(url, options: [:], completionHandler: openedURLCompletionHandler)
removeTabIfEmpty()
return .flyDown
}
popup.showWithType(showType: .flyUp)
Expand Down

0 comments on commit b1352d7

Please sign in to comment.