Skip to content

Commit

Permalink
Uplift of #27099 (squashed) to beta
Browse files Browse the repository at this point in the history
  • Loading branch information
brave-builds committed Jan 9, 2025
1 parent 3466b14 commit 59b4f62
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ extension BrowserViewController: WKNavigationDelegate {

// First special case are some schemes that are about Calling. We prompt the user to confirm this action. This
// gives us the exact same behaviour as Safari.

if ["sms", "tel", "facetime", "facetime-audio"].contains(requestURL.scheme) {
// tel:, facetime:, facetime-audio:, already has its own native alert displayed by the OS!f
if ["sms", "mailto"].contains(requestURL.scheme) {
let shouldOpen = await handleExternalURL(
requestURL,
tab: tab,
Expand Down Expand Up @@ -262,16 +262,6 @@ extension BrowserViewController: WKNavigationDelegate {
return (shouldOpen ? .allow : .cancel, preferences)
}

// Handles custom mailto URL schemes.
if requestURL.scheme == "mailto" {
let shouldOpen = await handleExternalURL(
requestURL,
tab: tab,
navigationAction: navigationAction
)
return (shouldOpen ? .allow : .cancel, preferences)
}

// handles Decentralized DNS
if let decentralizedDNSHelper = self.decentralizedDNSHelperFor(url: requestURL),
navigationAction.targetFrame?.isMainFrame == true
Expand Down Expand Up @@ -1266,7 +1256,11 @@ extension BrowserViewController {

var alertTitle = Strings.openExternalAppURLGenericTitle

if let displayHost = tab?.url?.withoutWWW.host {
if navigationAction.sourceFrame != nil {
let displayHost =
"\(navigationAction.sourceFrame.securityOrigin.protocol)://\(navigationAction.sourceFrame.securityOrigin.host):\(navigationAction.sourceFrame.securityOrigin.port)"
alertTitle = String(format: Strings.openExternalAppURLTitle, displayHost)
} else if let displayHost = tab?.url?.withoutWWW.host {
alertTitle = String(format: Strings.openExternalAppURLTitle, displayHost)
}

Expand Down

0 comments on commit 59b4f62

Please sign in to comment.