Skip to content

Commit

Permalink
Uplift of #25496 (squashed) to release
Browse files Browse the repository at this point in the history
  • Loading branch information
brave-builds committed Sep 10, 2024
1 parent ef7e8e1 commit ef251dc
Showing 1 changed file with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -755,10 +755,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 @@ -768,6 +764,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 @@ -795,22 +811,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

0 comments on commit ef251dc

Please sign in to comment.