From 59b4f62980312504a042d09859173f97c490cd95 Mon Sep 17 00:00:00 2001 From: brave-builds Date: Thu, 9 Jan 2025 13:53:27 +0000 Subject: [PATCH] Uplift of #27099 (squashed) to beta --- .../BVC+WKNavigationDelegate.swift | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+WKNavigationDelegate.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+WKNavigationDelegate.swift index 27abfcd7df3c..09f450bca98a 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+WKNavigationDelegate.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+WKNavigationDelegate.swift @@ -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, @@ -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 @@ -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) }