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

Merge Hotfix/7.141.1 into 7.142.0 release branch #3481

Merged
merged 3 commits into from
Oct 25, 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
9 changes: 8 additions & 1 deletion DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,7 @@ extension TabViewController: WKNavigationDelegate {

let mimeType = MIMEType(from: navigationResponse.response.mimeType, fileExtension: navigationResponse.response.url?.pathExtension)
let urlSchemeType = navigationResponse.response.url.map { SchemeHandler.schemeType(for: $0) } ?? .unknown
let urlNavigationalScheme = navigationResponse.response.url?.scheme.map { URL.NavigationalScheme(rawValue: $0) }

let httpResponse = navigationResponse.response as? HTTPURLResponse
let isSuccessfulResponse = httpResponse?.isSuccessfulResponse ?? false
Expand Down Expand Up @@ -1355,7 +1356,13 @@ extension TabViewController: WKNavigationDelegate {
withAdditionalParameters: [PixelParameters.canAutoPreviewMIMEType: "1"])
} else if shouldTriggerDownloadAction(for: navigationResponse),
let downloadMetadata = AppDependencyProvider.shared.downloadManager.downloadMetaData(for: navigationResponse.response) {
// 3. We know the response should trigger the file download prompt
// 3a. We know it is a download, but allow WebKit handle the "data" scheme natively
if urlNavigationalScheme == .data {
decisionHandler(.download)
return
}

// 3b. We know the response should trigger the file download prompt
self.presentSaveToDownloadsAlert(with: downloadMetadata) {
self.startDownload(with: navigationResponse, decisionHandler: decisionHandler)
} cancelHandler: {
Expand Down
Loading