Skip to content

Commit

Permalink
Merge branch 'release/0.30.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Oct 13, 2022
2 parents 2feacea + 3da6ae0 commit 6a9ded0
Show file tree
Hide file tree
Showing 56 changed files with 1,508 additions and 462 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
- name: Publish unit tests report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: unittests.xml

2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MARKETING_VERSION = 0.29.1
MARKETING_VERSION = 0.30.0

16 changes: 8 additions & 8 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
3106AD76287F000600159FE5 /* CookieConsentUserPermissionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3106AD75287F000600159FE5 /* CookieConsentUserPermissionViewController.swift */; };
311B262728E73E0A00FD181A /* TabShadowConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 311B262628E73E0A00FD181A /* TabShadowConfig.swift */; };
313AEDA1287CAD1D00E1E8F4 /* CookieConsentUserPermissionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 313AEDA0287CAD1D00E1E8F4 /* CookieConsentUserPermissionView.swift */; };
315AA07028CA5CC800200030 /* YoutubePlayerNavigationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 315AA06F28CA5CC800200030 /* YoutubePlayerNavigationHandler.swift */; };
3154FD1428E6011A00909769 /* TabShadowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3154FD1328E6011A00909769 /* TabShadowView.swift */; };
315AA07028CA5CC800200030 /* YoutubePlayerNavigationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 315AA06F28CA5CC800200030 /* YoutubePlayerNavigationHandler.swift */; };
3171D6B82889849F0068632A /* CookieManagedNotificationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3171D6B72889849F0068632A /* CookieManagedNotificationView.swift */; };
3171D6BA288984D00068632A /* BadgeAnimationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3171D6B9288984D00068632A /* BadgeAnimationView.swift */; };
3171D6DB2889B64D0068632A /* CookieManagedNotificationContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3171D6DA2889B64D0068632A /* CookieManagedNotificationContainerView.swift */; };
Expand Down Expand Up @@ -410,6 +410,7 @@
9833913327AAAEEE00DAF119 /* EmbeddedTrackerDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9833913227AAAEEE00DAF119 /* EmbeddedTrackerDataTests.swift */; };
983DFB2528B67036006B7E34 /* UserContentUpdating.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983DFB2428B67036006B7E34 /* UserContentUpdating.swift */; };
98EB5D1027516A4800681FE6 /* AppPrivacyConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98EB5D0F27516A4800681FE6 /* AppPrivacyConfigurationTests.swift */; };
A1DA5CF92367799FF3637FC9 /* YoutubeOverlayUserScript+Encryption.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1DA5A20BFD17B83D72DCB7C /* YoutubeOverlayUserScript+Encryption.swift */; };
AA06B6B72672AF8100F541C5 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = AA06B6B62672AF8100F541C5 /* Sparkle */; };
AA0877B826D5160D00B05660 /* SafariVersionReaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA0877B726D5160D00B05660 /* SafariVersionReaderTests.swift */; };
AA0877BA26D5161D00B05660 /* WebKitVersionProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA0877B926D5161D00B05660 /* WebKitVersionProviderTests.swift */; };
Expand Down Expand Up @@ -626,7 +627,6 @@
B637273B26CBC8AF00C8CB02 /* AuthenticationAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = B637273A26CBC8AF00C8CB02 /* AuthenticationAlert.swift */; };
B637273D26CCF0C200C8CB02 /* OptionalExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B637273C26CCF0C200C8CB02 /* OptionalExtension.swift */; };
B63BDF7E27FDAA640072D75B /* PrivacyDashboardWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B63BDF7D27FDAA640072D75B /* PrivacyDashboardWebView.swift */; };
B63BDF80280003570072D75B /* WebKitError.swift in Sources */ = {isa = PBXBuildFile; fileRef = B63BDF7F280003570072D75B /* WebKitError.swift */; };
B63D466925BEB6C200874977 /* WKWebView+SessionState.swift in Sources */ = {isa = PBXBuildFile; fileRef = B63D466825BEB6C200874977 /* WKWebView+SessionState.swift */; };
B63D467125BFA6C100874977 /* DispatchQueueExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B63D467025BFA6C100874977 /* DispatchQueueExtensions.swift */; };
B63D467A25BFC3E100874977 /* NSCoderExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B63D467925BFC3E100874977 /* NSCoderExtensions.swift */; };
Expand Down Expand Up @@ -845,8 +845,8 @@
3106AD75287F000600159FE5 /* CookieConsentUserPermissionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieConsentUserPermissionViewController.swift; sourceTree = "<group>"; };
311B262628E73E0A00FD181A /* TabShadowConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabShadowConfig.swift; sourceTree = "<group>"; };
313AEDA0287CAD1D00E1E8F4 /* CookieConsentUserPermissionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieConsentUserPermissionView.swift; sourceTree = "<group>"; };
315AA06F28CA5CC800200030 /* YoutubePlayerNavigationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YoutubePlayerNavigationHandler.swift; sourceTree = "<group>"; };
3154FD1328E6011A00909769 /* TabShadowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabShadowView.swift; sourceTree = "<group>"; };
315AA06F28CA5CC800200030 /* YoutubePlayerNavigationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YoutubePlayerNavigationHandler.swift; sourceTree = "<group>"; };
3171D6B72889849F0068632A /* CookieManagedNotificationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieManagedNotificationView.swift; sourceTree = "<group>"; };
3171D6B9288984D00068632A /* BadgeAnimationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeAnimationView.swift; sourceTree = "<group>"; };
3171D6DA2889B64D0068632A /* CookieManagedNotificationContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieManagedNotificationContainerView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1242,6 +1242,7 @@
9833913227AAAEEE00DAF119 /* EmbeddedTrackerDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmbeddedTrackerDataTests.swift; sourceTree = "<group>"; };
983DFB2428B67036006B7E34 /* UserContentUpdating.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserContentUpdating.swift; sourceTree = "<group>"; };
98EB5D0F27516A4800681FE6 /* AppPrivacyConfigurationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppPrivacyConfigurationTests.swift; sourceTree = "<group>"; };
A1DA5A20BFD17B83D72DCB7C /* YoutubeOverlayUserScript+Encryption.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "YoutubeOverlayUserScript+Encryption.swift"; sourceTree = "<group>"; };
AA0877B726D5160D00B05660 /* SafariVersionReaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariVersionReaderTests.swift; sourceTree = "<group>"; };
AA0877B926D5161D00B05660 /* WebKitVersionProviderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebKitVersionProviderTests.swift; sourceTree = "<group>"; };
AA0F3DB6261A566C0077F2D9 /* SuggestionLoadingMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuggestionLoadingMock.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1467,7 +1468,6 @@
B63B9C502670B2B200C45B91 /* _WKDownload.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKDownload.h; sourceTree = "<group>"; };
B63B9C542670B32000C45B91 /* WKProcessPool+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WKProcessPool+Private.h"; sourceTree = "<group>"; };
B63BDF7D27FDAA640072D75B /* PrivacyDashboardWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyDashboardWebView.swift; sourceTree = "<group>"; };
B63BDF7F280003570072D75B /* WebKitError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebKitError.swift; sourceTree = "<group>"; };
B63D466725BEB6C200874977 /* WKWebView+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WKWebView+Private.h"; sourceTree = "<group>"; };
B63D466825BEB6C200874977 /* WKWebView+SessionState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "WKWebView+SessionState.swift"; sourceTree = "<group>"; };
B63D467025BFA6C100874977 /* DispatchQueueExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DispatchQueueExtensions.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1755,8 +1755,9 @@
3767190128E724B2003A2A15 /* PrivatePlayerURLExtension.swift */,
31F28C5228C8EECA00119F70 /* PrivatePlayerSchemeHandler.swift */,
315AA06F28CA5CC800200030 /* YoutubePlayerNavigationHandler.swift */,
31F28C4E28C8EEC500119F70 /* YoutubeOverlayUserScript.swift */,
31F28C4C28C8EEC500119F70 /* YoutubePlayerUserScript.swift */,
31F28C4E28C8EEC500119F70 /* YoutubeOverlayUserScript.swift */,
A1DA5A20BFD17B83D72DCB7C /* YoutubeOverlayUserScript+Encryption.swift */,
);
path = "Youtube Player";
sourceTree = "<group>";
Expand Down Expand Up @@ -2602,7 +2603,6 @@
isa = PBXGroup;
children = (
85AC3B3425DA82A600C7D2AA /* DataTaskProviding.swift */,
B63BDF7F280003570072D75B /* WebKitError.swift */,
);
path = Network;
sourceTree = "<group>";
Expand Down Expand Up @@ -4699,7 +4699,6 @@
85D438B6256E7C9E00F3BAF8 /* ContextMenuUserScript.swift in Sources */,
B693955526F04BEC0015B914 /* NSSavePanelExtension.swift in Sources */,
9826B0A22747DFEB0092F683 /* AppPrivacyConfigurationDataProvider.swift in Sources */,
B63BDF80280003570072D75B /* WebKitError.swift in Sources */,
B6B1E88B26D774090062C350 /* LinkButton.swift in Sources */,
4BBF0915282DD40100EE1418 /* TemporaryFileHandler.swift in Sources */,
CB6BCDF927C6BEFF00CC76DC /* PrivacyFeatures.swift in Sources */,
Expand Down Expand Up @@ -5027,6 +5026,7 @@
4BE53374286E39F10019DBFD /* ChromiumKeychainPrompt.swift in Sources */,
B6553692268440D700085A79 /* WKProcessPool+GeolocationProvider.swift in Sources */,
AA5C1DD1285A154E0089850C /* RecentlyClosedMenu.swift in Sources */,
A1DA5CF92367799FF3637FC9 /* YoutubeOverlayUserScript+Encryption.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -6282,7 +6282,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 32.1.0;
version = 32.4.0;
};
};
AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Autoconsent/autoconsent-bundle.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,10 @@ extension BookmarksBarViewController: BookmarksBarViewModelDelegate {
switch action {
case .openInNewTab:
tabCollectionViewModel.appendNewTab(with: .url(bookmark.url), selected: true)
case .openInBackgroundTab:
tabCollectionViewModel.appendNewTab(with: .url(bookmark.url), selected: false)
case .openInNewWindow:
WindowsManager.openNewWindow(with: bookmark.url)
case .clickItem:
WindowControllersManager.shared.show(url: bookmark.url)
WindowControllersManager.shared.open(bookmark: bookmark)
case .addToFavorites:
bookmark.isFavorite = true
bookmarkManager.update(bookmark: bookmark)
Expand Down
13 changes: 1 addition & 12 deletions DuckDuckGo/Bookmarks Bar/View/BookmarksBarViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ final class BookmarksBarViewModel: NSObject {

enum BookmarksBarItemAction {
case clickItem
case openInBackgroundTab
case openInNewTab
case openInNewWindow
case addToFavorites
Expand Down Expand Up @@ -453,17 +452,7 @@ extension BookmarksBarViewModel: BookmarksBarCollectionViewItemDelegate {
return
}

let action: BookmarksBarItemAction

if NSApplication.shared.isCommandPressed && NSApplication.shared.isShiftPressed {
action = .openInNewTab
} else if NSApplication.shared.isCommandPressed {
action = .openInBackgroundTab
} else {
action = .clickItem
}

delegate?.bookmarksBarViewModelReceived(action: action, for: item)
delegate?.bookmarksBarViewModelReceived(action: .clickItem, for: item)
}

func bookmarksBarCollectionViewItemOpenInNewTabAction(_ item: BookmarksBarCollectionViewItem) {
Expand Down
71 changes: 52 additions & 19 deletions DuckDuckGo/Browser Tab/Model/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ final class Tab: NSObject, Identifiable, ObservableObject {
autofillScript?.currentOverlayTab = delegate
}
}

var isPinned: Bool {
return pinnedTabsManager.isTabPinned(self)
}

private let cbaTimeReporter: ContentBlockingAssetsCompilationTimeReporter?
private let pinnedTabsManager: PinnedTabsManager
private let privatePlayer: PrivatePlayer
Expand Down Expand Up @@ -208,6 +213,9 @@ final class Tab: NSObject, Identifiable, ObservableObject {

initAttributionLogic(state: attributionState ?? parentTab?.adClickAttributionLogic.state)
setupWebView(shouldLoadInBackground: shouldLoadInBackground)
if favicon == nil {
handleFavicon()
}

NotificationCenter.default.addObserver(self,
selector: #selector(onDuckDuckGoEmailSignOut),
Expand All @@ -228,6 +236,7 @@ final class Tab: NSObject, Identifiable, ObservableObject {
}
webView.stopLoading()
webView.stopMediaCapture()
webView.stopAllMediaPlayback()
webView.fullscreenWindowController?.close()
userContentController.removeAllUserScripts()

Expand Down Expand Up @@ -266,7 +275,7 @@ final class Tab: NSObject, Identifiable, ObservableObject {

@Published private(set) var content: TabContent {
didSet {
handleFavicon(oldContent: oldValue)
handleFavicon()
invalidateSessionStateData()
if let oldUrl = oldValue.url {
historyCoordinating.commitChanges(url: oldUrl)
Expand Down Expand Up @@ -710,14 +719,14 @@ final class Tab: NSObject, Identifiable, ObservableObject {
@Published var favicon: NSImage?
let faviconManagement: FaviconManagement

private func handleFavicon(oldContent: TabContent) {
guard faviconManagement.areFaviconsLoaded else { return }

private func handleFavicon() {
if content.isPrivatePlayer {
favicon = .privatePlayer
return
}

guard faviconManagement.areFaviconsLoaded else { return }

guard content.isUrl, let url = content.url else {
favicon = nil
return
Expand Down Expand Up @@ -776,8 +785,6 @@ final class Tab: NSObject, Identifiable, ObservableObject {
return
}

guard url != .homePage else { return }

// Add to global history
historyCoordinating.addVisit(of: url)

Expand All @@ -798,22 +805,31 @@ final class Tab: NSObject, Identifiable, ObservableObject {
private var youtubePlayerCancellables: Set<AnyCancellable> = []

func setUpYoutubeScriptsIfNeeded() {
guard PrivatePlayer.isAvailable else {
guard PrivatePlayer.shared.isAvailable else {
return
}

youtubePlayerCancellables.removeAll()

if webView.url?.host?.droppingWwwPrefix() == "youtube.com" {
// only send push updates on macOS 11+ where it's safe to call window.* messages in the browser
let canPushMessagesToJS: Bool = {
if #available(macOS 11, *) {
return true
} else {
return false
}
}()

if webView.url?.host?.droppingWwwPrefix() == "youtube.com" && canPushMessagesToJS {
privatePlayer.$mode
.dropFirst()
.sink { [weak self] playerMode in
guard let self = self else {
return
}
let userValues = YoutubeOverlayUserScript.UserValues(
privatePlayerMode: playerMode,
overlayInteracted: self.privatePlayer.overlayInteracted
privatePlayerMode: playerMode,
overlayInteracted: self.privatePlayer.overlayInteracted
)
self.youtubeOverlayScript?.userValuesUpdated(userValues: userValues, inWebView: self.webView)
}
Expand All @@ -822,15 +838,18 @@ final class Tab: NSObject, Identifiable, ObservableObject {

if url?.isPrivatePlayerScheme == true {
youtubePlayerScript?.isEnabled = true
privatePlayer.$mode
.map { $0 == .enabled }
.sink { [weak self] shouldAlwaysOpenPrivatePlayer in
guard let self = self else {
return

if canPushMessagesToJS {
privatePlayer.$mode
.map { $0 == .enabled }
.sink { [weak self] shouldAlwaysOpenPrivatePlayer in
guard let self = self else {
return
}
self.youtubePlayerScript?.setAlwaysOpenInPrivatePlayer(shouldAlwaysOpenPrivatePlayer, inWebView: self.webView)
}
self.youtubePlayerScript?.setAlwaysOpenInPrivatePlayer(shouldAlwaysOpenPrivatePlayer, inWebView: self.webView)
}
.store(in: &youtubePlayerCancellables)
.store(in: &youtubePlayerCancellables)
}
} else {
youtubePlayerScript?.isEnabled = false
}
Expand Down Expand Up @@ -892,6 +911,7 @@ extension Tab: UserContentControllerDelegate {
userScripts.hoverUserScript.delegate = self
userScripts.autoconsentUserScript?.delegate = self
youtubeOverlayScript = userScripts.youtubeOverlayScript
youtubeOverlayScript?.delegate = self
youtubePlayerScript = userScripts.youtubePlayerUserScript
setUpYoutubeScriptsIfNeeded()

Expand Down Expand Up @@ -1180,7 +1200,7 @@ extension Tab: WKNavigationDelegate {

func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
isBeingRedirected = false
if let url = webView.url {
if content.isUrl, let url = webView.url {
addVisit(of: url)
}
webViewDidCommitNavigationPublisher.send()
Expand Down Expand Up @@ -1608,6 +1628,19 @@ extension Tab: AutoconsentUserScriptDelegate {
}
}

extension Tab: YoutubeOverlayUserScriptDelegate {
func youtubeOverlayUserScriptDidRequestDuckPlayer(with url: URL) {
let content = Tab.TabContent.contentFromURL(url)
let isRequestingNewTab = NSApp.isCommandPressed
if isRequestingNewTab {
let shouldSelectNewTab = NSApp.isShiftPressed
self.delegate?.tab(self, requestedNewTabWith: content, selected: shouldSelectNewTab)
} else {
setContent(content)
}
}
}

extension Tab: TabDataClearing {
func prepareForDataClearing(caller: TabDataCleaner) {
webView.stopLoading()
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Browser Tab/Model/UserScripts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class UserScripts {
autoconsentUserScript = nil
}

if PrivatePlayer.isAvailable {
if PrivatePlayer.shared.isAvailable {
youtubeOverlayScript = YoutubeOverlayUserScript()
youtubePlayerUserScript = YoutubePlayerUserScript()
} else {
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Browser Tab/View/BrowserTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ extension BrowserTabViewController: TabDelegate {
}
completionHandler(.useCredential, URLCredential(user: alert.usernameTextField.stringValue,
password: alert.passwordTextField.stringValue,
persistence: .none))
persistence: .forSession))

}
}
Expand Down
Loading

0 comments on commit 6a9ded0

Please sign in to comment.