Skip to content

Commit

Permalink
support marketplace kit
Browse files Browse the repository at this point in the history
  • Loading branch information
brindy committed Apr 25, 2024
1 parent af59b26 commit 6808f94
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Core/SchemeHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ public class SchemeHandler {
case cancel
}

public enum LinkActivated: Equatable {
case required
case notRequired
}

public enum SchemeType: Equatable {
case navigational
case system(linkActivated: LinkActivated)
case unsupported
case external(Action)
case blob
case unknown
Expand All @@ -50,6 +57,7 @@ public class SchemeHandler {
case shortcuts
case shortcutsProduction = "shortcuts-production"
case workflow
case marketplaceKit = "marketplace-kit"
}

private enum BlockedScheme: String {
Expand All @@ -73,6 +81,12 @@ public class SchemeHandler {
switch PlatformScheme(rawValue: schemeString) {
case .sms, .mailto, .itms, .itmss, .itunes, .itmsApps, .itmsAppss, .shortcuts, .shortcutsProduction, .workflow:
return .external(.askForConfirmation)
case .marketplaceKit:
if #available(iOS 17.4, *) {
return .system(linkActivated: .required)
} else {
return .unsupported
}
case .none:
return .unknown
default:
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/DuckDuckGo.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
</array>
<key>com.apple.developer.web-browser</key>
<true/>
<key>com.apple.developer.browser.app-installation</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>$(GROUP_ID_PREFIX).bookmarks</string>
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/DuckDuckGoAlpha.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
</array>
<key>com.apple.developer.web-browser</key>
<true/>
<key>com.apple.developer.browser.app-installation</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.duckduckgo.alpha.apptp</string>
Expand Down
10 changes: 10 additions & 0 deletions DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,13 @@ extension TabViewController: WKNavigationDelegate {
allowPolicy: allowPolicy,
completion: completion)

case .system(let linkRequired):
if linkRequired == .notRequired || navigationAction.navigationType == .linkActivated {
completion(allowPolicy)
} else {
completion(.cancel)
}

case .external(let action):
performExternalNavigationFor(url: url, action: action)
completion(.cancel)
Expand All @@ -1576,6 +1583,9 @@ extension TabViewController: WKNavigationDelegate {
presentOpenInExternalAppAlert(url: url)
}
completion(.cancel)

case .unsupported:
completion(.cancel)
}
}

Expand Down

0 comments on commit 6808f94

Please sign in to comment.