Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Show correct options when sharing a temporary doc like a PDF #25496

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down
Loading