Skip to content

Commit

Permalink
FXIOS-7871 mozilla-mobile#17571 ⁃ Opening a link in external app leav…
Browse files Browse the repository at this point in the history
…es a "loading" about:blank page behind (mozilla-mobile#19288)

Co-authored-by: Alexandru Farcasanu <c_afarcasanu@groupon.com>
  • Loading branch information
dicarobinho and Alexandru Farcasanu authored Mar 20, 2024
1 parent 7c0f613 commit 85cebaa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ extension BrowserViewController: WKUIDelegate {
screenshotHelper.takeScreenshot(currentTab)
}

if navigationAction.canOpenExternalApp, let url = navigationAction.request.url {
UIApplication.shared.open(url)
return nil
}

// If the page uses `window.open()` or `[target="_blank"]`, open the page in a new tab.
// IMPORTANT!!: WebKit will perform the `URLRequest` automatically!! Attempting to do
// the request here manually leads to incorrect results!!
Expand Down Expand Up @@ -1082,4 +1087,14 @@ extension WKNavigationAction {
return false
}
}

var canOpenExternalApp: Bool {
guard let urlShortDomain = request.url?.shortDomain else { return false }

if let url = URL(string: "\(urlShortDomain)://"), UIApplication.shared.canOpenURL(url) {
return true
}

return false
}
}
3 changes: 3 additions & 0 deletions firefox-ios/Client/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
<false/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>paypal</string>
<string>instagram</string>
<string>youtube</string>
<string>pocket</string>
<string>firefox-focus</string>
<string>firefox-klar</string>
Expand Down

0 comments on commit 85cebaa

Please sign in to comment.