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

Properly handle responses that should trigger download action #3407

Merged
merged 12 commits into from
Oct 16, 2024
Merged
2 changes: 0 additions & 2 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ extension Pixel {
case cachedTabPreviewRemovalError

case missingDownloadedFile
case unhandledDownload

case compilationResult(result: CompileRulesResult, waitTime: BucketAggregation, appState: AppState)

Expand Down Expand Up @@ -1326,7 +1325,6 @@ extension Pixel.Event {
case .cachedTabPreviewRemovalError: return "m_d_tpre"

case .missingDownloadedFile: return "m_d_missing_downloaded_file"
case .unhandledDownload: return "m_d_unhandled_download"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the code path and confirming in Kibana this pixel is/was not being fired.


case .compilationResult(result: let result, waitTime: let waitTime, appState: let appState):
return "m_compilation_result_\(result)_time_\(waitTime)_state_\(appState)"
Expand Down
12 changes: 8 additions & 4 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
1E4FAA6427D8DFB900ADC5B3 /* OngoingDownloadRowViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E4FAA6327D8DFB900ADC5B3 /* OngoingDownloadRowViewModel.swift */; };
1E4FAA6627D8DFC800ADC5B3 /* CompleteDownloadRowViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E4FAA6527D8DFC800ADC5B3 /* CompleteDownloadRowViewModel.swift */; };
1E53508F2C7C9A1F00818DAA /* DefaultSubscriptionManager+AccountManagerKeychainAccessDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E53508E2C7C9A1F00818DAA /* DefaultSubscriptionManager+AccountManagerKeychainAccessDelegate.swift */; };
1E5918472CA422A7008ED2B3 /* Navigation in Frameworks */ = {isa = PBXBuildFile; productRef = 1E5918462CA422A7008ED2B3 /* Navigation */; };
1E60989B290009C700A508F9 /* Common in Frameworks */ = {isa = PBXBuildFile; productRef = 1E7060BD28F88EE200E4CCDB /* Common */; };
1E60989D290011E600A508F9 /* ContentBlocking in Frameworks */ = {isa = PBXBuildFile; productRef = 1E60989C290011E600A508F9 /* ContentBlocking */; };
1E6098A1290011E600A508F9 /* UserScript in Frameworks */ = {isa = PBXBuildFile; productRef = 1E6098A0290011E600A508F9 /* UserScript */; };
Expand Down Expand Up @@ -816,7 +817,6 @@
B6BA95C328891E33004ABA20 /* BrowsingMenuAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6BA95C228891E33004ABA20 /* BrowsingMenuAnimator.swift */; };
B6BA95C528894A28004ABA20 /* BrowsingMenuViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B6BA95C428894A28004ABA20 /* BrowsingMenuViewController.storyboard */; };
B6BA95E828924730004ABA20 /* JSAlertController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B6BA95E728924730004ABA20 /* JSAlertController.storyboard */; };
B6CB93E5286445AB0090FEB4 /* Base64DownloadSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6CB93E4286445AB0090FEB4 /* Base64DownloadSession.swift */; };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer used anywhere.

BBFF18B12C76448100C48D7D /* QuerySubmittedTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFF18B02C76448100C48D7D /* QuerySubmittedTests.swift */; };
BD10B8AA2C7629740033115D /* Logger+Subscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD10B8A92C7629740033115D /* Logger+Subscription.swift */; };
BD15DB852B959CFD00821457 /* BundleExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD15DB842B959CFD00821457 /* BundleExtension.swift */; };
Expand Down Expand Up @@ -2617,7 +2617,6 @@
B6BA95C228891E33004ABA20 /* BrowsingMenuAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowsingMenuAnimator.swift; sourceTree = "<group>"; };
B6BA95C428894A28004ABA20 /* BrowsingMenuViewController.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = BrowsingMenuViewController.storyboard; sourceTree = "<group>"; };
B6BA95E728924730004ABA20 /* JSAlertController.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = JSAlertController.storyboard; sourceTree = "<group>"; };
B6CB93E4286445AB0090FEB4 /* Base64DownloadSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base64DownloadSession.swift; sourceTree = "<group>"; };
B6DFE6CF2BC7E47500A9CE59 /* SwiftLintTool.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftLintTool.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
B6DFE6D92BC7E61B00A9CE59 /* SwiftLintToolBundleConfiguration.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = SwiftLintToolBundleConfiguration.xcconfig; sourceTree = "<group>"; };
BBFF18B02C76448100C48D7D /* QuerySubmittedTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuerySubmittedTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3042,6 +3041,7 @@
31E69A63280F4CB600478327 /* DuckUI in Frameworks */,
CB941A6E2B96AB08000F9E7A /* PrivacyDashboard in Frameworks */,
F42D541D29DCA40B004C4FF1 /* DesignResourcesKit in Frameworks */,
1E5918472CA422A7008ED2B3 /* Navigation in Frameworks */,
85875B6129912A9900115F05 /* SyncUI in Frameworks */,
F4D7F634298C00C3006C3AE9 /* FindInPageIOSJSSupport in Frameworks */,
9F96F73B2C9144D5009E45D5 /* Onboarding in Frameworks */,
Expand Down Expand Up @@ -3484,7 +3484,6 @@
B623C1C12862CA9E0043013E /* DownloadSession.swift */,
31C138A727A3E9C900FFD4B2 /* URLDownloadSession.swift */,
B623C1C32862CD670043013E /* WKDownloadSession.swift */,
B6CB93E4286445AB0090FEB4 /* Base64DownloadSession.swift */,
B609D5512862EAFF0088CAC2 /* InlineWKDownloadDelegate.swift */,
310D09202799FD1A00DC0060 /* MIMEType.swift */,
3161D13127AC161B00285CF6 /* DownloadMetadata.swift */,
Expand Down Expand Up @@ -6517,6 +6516,7 @@
F1D43AF92B99C1D300BAB743 /* BareBonesBrowserKit */,
9F8FE9482BAE50E50071E372 /* Lottie */,
9F96F73A2C9144D5009E45D5 /* Onboarding */,
1E5918462CA422A7008ED2B3 /* Navigation */,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required for WKNavigationAction, HTTPURLResponse and other navigation related extensions.

);
productName = DuckDuckGo;
productReference = 84E341921E2F7EFB00BDBA6F /* DuckDuckGo.app */;
Expand Down Expand Up @@ -7720,7 +7720,6 @@
EE01EB432AFC1E0A0096AAC9 /* NetworkProtectionVPNLocationView.swift in Sources */,
7BC571202BDBB877003B0CCE /* VPNActivationDateStore.swift in Sources */,
9820EAF522613CD30089094D /* WebProgressWorker.swift in Sources */,
B6CB93E5286445AB0090FEB4 /* Base64DownloadSession.swift in Sources */,
1EEF387D285B1A1100383393 /* TrackerImageCache.swift in Sources */,
3151F0EC27357FEE00226F58 /* VoiceSearchFeedbackViewModel.swift in Sources */,
1E53508F2C7C9A1F00818DAA /* DefaultSubscriptionManager+AccountManagerKeychainAccessDelegate.swift in Sources */,
Expand Down Expand Up @@ -11020,6 +11019,11 @@
package = F486D2FD25069744002D07D7 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */;
productName = OHHTTPStubsSwift;
};
1E5918462CA422A7008ED2B3 /* Navigation */ = {
isa = XCSwiftPackageProductDependency;
package = 98A16C2928A11BDE00A6C003 /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = Navigation;
};
1E60989C290011E600A508F9 /* ContentBlocking */ = {
isa = XCSwiftPackageProductDependency;
package = 98A16C2928A11BDE00A6C003 /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
Expand Down
63 changes: 0 additions & 63 deletions DuckDuckGo/Base64DownloadSession.swift

This file was deleted.

2 changes: 1 addition & 1 deletion DuckDuckGo/DownloadMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct DownloadMetadata {
self.filename = filename
self.expectedContentLength = response.expectedContentLength
self.mimeTypeSource = response.mimeType ?? ""
self.mimeType = MIMEType(from: response.mimeType)
self.mimeType = MIMEType(from: response.mimeType, fileExtension: filename.pathExtension)
self.url = url
}
}
12 changes: 11 additions & 1 deletion DuckDuckGo/MIMEType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ enum MIMEType: String {
init(from string: String?) {
self = MIMEType(rawValue: string ?? "") ?? .unknown
}


init(from string: String?, fileExtension: String?) {
let initialMIMEType = MIMEType(from: string)

switch (initialMIMEType, fileExtension) {
case (.octetStream, "pkpass"): self = .passbook
case (.octetStream, "pkpasses"): self = .multipass
default: self = initialMIMEType
}
}

var isHTML: Bool {
switch self {
case .html, .xhtml:
Expand Down
Loading
Loading