From 315c4bda0e760713de64097b5e888c1e71efe06b Mon Sep 17 00:00:00 2001 From: Kyle Hickinson Date: Mon, 9 Sep 2024 17:47:31 -0400 Subject: [PATCH] [iOS] Show correct options when sharing a temporary doc like a PDF --- .../BVC+WKNavigationDelegate.swift | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 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 972ef3a88c57..03c6d2965e99 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 @@ -756,10 +756,6 @@ extension BrowserViewController: WKNavigationDelegate { return .download } - if canShowInWebView { - return .allow - } - // Check if this response should be handed off to Passbook. if shouldDownloadNavigationResponse { shouldDownloadNavigationResponse = false @@ -769,6 +765,26 @@ extension BrowserViewController: WKNavigationDelegate { } } + // If the content type is not HTML, create a temporary document so it can be downloaded and + // shared to external applications later. Otherwise, clear the old temporary document. + if let tab = tab, navigationResponse.isForMainFrame { + if response.mimeType?.isKindOfHTML == false, let request = request { + tab.temporaryDocument = TemporaryDocument( + preflightResponse: response, + request: request, + tab: tab + ) + } else { + tab.temporaryDocument = nil + } + + tab.mimeType = response.mimeType + } + + if canShowInWebView { + return .allow + } + // Check if this response should be downloaded. let cookieStore = webView.configuration.websiteDataStore.httpCookieStore if let downloadHelper = DownloadHelper( @@ -796,22 +812,6 @@ extension BrowserViewController: WKNavigationDelegate { return .cancel } - // If the content type is not HTML, create a temporary document so it can be downloaded and - // shared to external applications later. Otherwise, clear the old temporary document. - if let tab = tab, navigationResponse.isForMainFrame { - if response.mimeType?.isKindOfHTML == false, let request = request { - tab.temporaryDocument = TemporaryDocument( - preflightResponse: response, - request: request, - tab: tab - ) - } else { - tab.temporaryDocument = nil - } - - tab.mimeType = response.mimeType - } - // If none of our helpers are responsible for handling this response, // just let the webview handle it as normal. return .download