Skip to content

Commit

Permalink
Merge branch 'release/1.34.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Mar 3, 2023
2 parents fbf9525 + 19f5a68 commit 7bdf5e2
Show file tree
Hide file tree
Showing 31 changed files with 340 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .xcode-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.1
14.2
2 changes: 1 addition & 1 deletion Configuration/AppStoreBuildNumber.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 9
CURRENT_PROJECT_VERSION = 10
2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MARKETING_VERSION = 1.34.6
MARKETING_VERSION = 1.34.7
6 changes: 6 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,8 @@
B6C0B23C26E87D900031CB7F /* NSAlert+ActiveDownloadsTermination.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C0B23B26E87D900031CB7F /* NSAlert+ActiveDownloadsTermination.swift */; };
B6C0B23E26E8BF1F0031CB7F /* DownloadListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C0B23D26E8BF1F0031CB7F /* DownloadListViewModel.swift */; };
B6C0B24626E9CB190031CB7F /* RunLoopExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C0B24526E9CB190031CB7F /* RunLoopExtensionTests.swift */; };
B6C0BB6729AEFF8100AE8E3C /* BookmarkExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C0BB6629AEFF8100AE8E3C /* BookmarkExtension.swift */; };
B6C0BB6829AEFF8100AE8E3C /* BookmarkExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C0BB6629AEFF8100AE8E3C /* BookmarkExtension.swift */; };
B6C2C9EF276081AB005B7F0A /* DeallocationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C2C9EE276081AB005B7F0A /* DeallocationTests.swift */; };
B6C2C9F62760B659005B7F0A /* TestDataModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = B6C2C9F42760B659005B7F0A /* TestDataModel.xcdatamodeld */; };
B6CA4824298CDC2E0067ECCE /* AdClickAttributionTabExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6CA4823298CDC2E0067ECCE /* AdClickAttributionTabExtensionTests.swift */; };
Expand Down Expand Up @@ -2651,6 +2653,7 @@
B6C0B23B26E87D900031CB7F /* NSAlert+ActiveDownloadsTermination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSAlert+ActiveDownloadsTermination.swift"; sourceTree = "<group>"; };
B6C0B23D26E8BF1F0031CB7F /* DownloadListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadListViewModel.swift; sourceTree = "<group>"; };
B6C0B24526E9CB190031CB7F /* RunLoopExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RunLoopExtensionTests.swift; sourceTree = "<group>"; };
B6C0BB6629AEFF8100AE8E3C /* BookmarkExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkExtension.swift; sourceTree = "<group>"; };
B6C2C9EE276081AB005B7F0A /* DeallocationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeallocationTests.swift; sourceTree = "<group>"; };
B6C2C9F52760B659005B7F0A /* Permissions.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Permissions.xcdatamodel; sourceTree = "<group>"; };
B6CA4823298CDC2E0067ECCE /* AdClickAttributionTabExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdClickAttributionTabExtensionTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3551,6 +3554,7 @@
children = (
4B9292D62667124000AD2C21 /* NSPopUpButtonExtension.swift */,
4B9292AE26670F5300AD2C21 /* NSOutlineViewExtensions.swift */,
B6C0BB6629AEFF8100AE8E3C /* BookmarkExtension.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -6690,6 +6694,7 @@
3706FC68293F65D500E42796 /* ToggleableScrollView.swift in Sources */,
3706FC69293F65D500E42796 /* UserScripts.swift in Sources */,
3706FC6A293F65D500E42796 /* NSWorkspaceExtension.swift in Sources */,
B6C0BB6829AEFF8100AE8E3C /* BookmarkExtension.swift in Sources */,
3706FC6B293F65D500E42796 /* AppHTTPSUpgradeStore.swift in Sources */,
3706FC6C293F65D500E42796 /* BookmarkViewModel.swift in Sources */,
3706FC6D293F65D500E42796 /* DaxSpeech.swift in Sources */,
Expand Down Expand Up @@ -7129,6 +7134,7 @@
B6B1E87E26D5DA0E0062C350 /* DownloadsPopover.swift in Sources */,
4B9292A026670D2A00AD2C21 /* SpacerNode.swift in Sources */,
B6E61EE8263ACE16004E11AB /* UTType.swift in Sources */,
B6C0BB6729AEFF8100AE8E3C /* BookmarkExtension.swift in Sources */,
4BE6547F271FCD4D008D1D63 /* PasswordManagementCreditCardModel.swift in Sources */,
31B4AF532901A4F20013585E /* NSEventExtension.swift in Sources */,
85707F26276A335700DC0649 /* Onboarding.swift in Sources */,
Expand Down
9 changes: 6 additions & 3 deletions DuckDuckGo/App Delegate/CopyHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ final class CopyHandler: NSObject {
}

let selectedText = editor.selectedText

NSPasteboard.general.clearContents()
NSPasteboard.general.setString(selectedText, forType: .string)

if let urlString = URL(trimmedAddressBarString: selectedText.trimmingWhitespace())?.absoluteString,
urlString == selectedText {
NSPasteboard.general.setString(urlString, forType: .URL)
if let url = URL(trimmedAddressBarString: selectedText.trimmingWhitespace()) {
NSPasteboard.general.copy(url, withString: selectedText)
} else {
NSPasteboard.general.copy(selectedText)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ extension BookmarksBarViewController: BookmarksBarViewModelDelegate {
bookmarksBarCollectionView.reloadData()
}

// swiftlint:disable:next cyclomatic_complexity
private func handle(_ action: BookmarksBarViewModel.BookmarksBarItemAction, for bookmark: Bookmark) {
switch action {
case .openInNewTab:
Expand All @@ -222,8 +221,7 @@ extension BookmarksBarViewController: BookmarksBarViewModelDelegate {
case .moveToEnd:
bookmarkManager.move(objectUUIDs: [bookmark.id], toIndex: nil, withinParentFolder: .root) { _ in }
case .copyURL:
guard let url = bookmark.urlObject else { return }
NSPasteboard.general.copy(url: url)
bookmark.copyUrlToPasteboard()
case .deleteEntity:
bookmarkManager.remove(bookmark: bookmark)
}
Expand Down
31 changes: 31 additions & 0 deletions DuckDuckGo/Bookmarks/Extensions/BookmarkExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// BookmarkExtension.swift
//
// Copyright © 2023 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

extension Bookmark {

func copyUrlToPasteboard(_ pasteboard: NSPasteboard = .general) {
if let url = self.urlObject {
pasteboard.copy(url, withString: self.url)
} else {
pasteboard.copy(self.url)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class LegacyBookmarksStoreMigration {
// There should be no data left as migration has been done already
if !bookmarkRoots.isEmpty {
Pixel.fire(.debug(event: .bookmarksMigrationAlreadyPerformed))

cleanupOldData(in: source)
}
return
}
Expand Down
7 changes: 6 additions & 1 deletion DuckDuckGo/Bookmarks/Model/Bookmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ final class Bookmark: BaseBookmarkEntity {
if let privatePlayerFavicon = PrivatePlayer.shared.image(for: self) {
return privatePlayerFavicon
}
return faviconManagement.getCachedFavicon(for: url, sizeCategory: sizeCategory)?.image

if let url = urlObject {
return faviconManagement.getCachedFavicon(for: url, sizeCategory: sizeCategory)?.image
} else {
return faviconManagement.getCachedFavicon(for: url, sizeCategory: sizeCategory)?.image
}
}

init(id: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ final class AddBookmarkModalViewController: NSViewController {
if originalBookmark != nil {
return !bookmarkTitleTextField.stringValue.isEmpty && url.isValid
} else {
let isBookmarked = LocalBookmarkManager.shared.isUrlBookmarked(url: url)
let isInputValid = !bookmarkTitleTextField.stringValue.isEmpty && url.isValid && !isBookmarked
let isInputValid = !bookmarkTitleTextField.stringValue.isEmpty && url.isValid

return isInputValid
}
Expand Down
6 changes: 1 addition & 5 deletions DuckDuckGo/Bookmarks/View/BookmarkListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,7 @@ extension BookmarkListViewController: BookmarkMenuItemSelectors {
assertionFailure("Failed to cast menu represented object to Bookmark")
return
}

let pasteboard = NSPasteboard.general
pasteboard.declareTypes([.URL], owner: nil)
(bookmark.urlObject as NSURL?)?.write(to: pasteboard)
pasteboard.setString(bookmark.url, forType: .string)
bookmark.copyUrlToPasteboard()
}

func deleteBookmark(_ sender: NSMenuItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,15 +671,12 @@ extension BookmarkManagementDetailViewController: BookmarkMenuItemSelectors {
}

func copyBookmark(_ sender: NSMenuItem) {
guard let bookmark = sender.representedObject as? Bookmark, let bookmarkURL = bookmark.urlObject as NSURL? else {
guard let bookmark = sender.representedObject as? Bookmark else {
assertionFailure("Failed to cast menu represented object to Bookmark")
return
}

let pasteboard = NSPasteboard.general
pasteboard.declareTypes([.URL], owner: nil)
bookmarkURL.write(to: pasteboard)
pasteboard.setString(bookmarkURL.absoluteString ?? "", forType: .string)
bookmark.copyUrlToPasteboard()
}

func deleteBookmark(_ sender: NSMenuItem) {
Expand Down
32 changes: 24 additions & 8 deletions DuckDuckGo/Browser Tab/Extensions/ContextMenuManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@ extension ContextMenuManager {
assertionFailure("WKMenuItemIdentifierOpenLinkInNewWindow item not found")
return
}
// insert Add Link to Bookmarks
menu.insertItem(self.addLinkToBookmarksMenuItem(from: openLinkInNewWindowItem), at: index)
menu.replaceItem(at: index + 1, with: self.copyLinkMenuItem(withTitle: copyLinkItem.title, from: openLinkInNewWindowItem))

// insert Separator and Copy (selection) items
if selectedText?.isEmpty == false {
menu.insertItem(.separator(), at: index + 2)
menu.insertItem(self.copySelectionMenuItem(), at: index + 3)
}
}

private func handleCopyImageItem(_ item: NSMenuItem, at index: Int, in menu: NSMenu) {
Expand Down Expand Up @@ -202,6 +209,10 @@ private extension ContextMenuManager {
makeMenuItem(withTitle: title, action: #selector(copyLink), from: openLinkItem, with: .openLinkInNewWindow)
}

func copySelectionMenuItem() -> NSMenuItem {
NSMenuItem(title: UserText.copySelection, action: #selector(copySelection), target: self)
}

func copyImageAddressMenuItem(from item: NSMenuItem) -> NSMenuItem {
makeMenuItem(withTitle: UserText.copyImageAddress, action: #selector(copyImageAddress), from: item, with: .openImageInNewWindow, keyEquivalent: "")
}
Expand Down Expand Up @@ -256,6 +267,15 @@ private extension ContextMenuManager {
webView.loadInNewWindow(url)
}

func copySelection(_ sender: NSMenuItem) {
guard let selectedText else {
assertionFailure("Failed to get selected text")
return
}

NSPasteboard.general.copy(selectedText)
}

func openLinkInNewTab(_ sender: NSMenuItem) {
guard let originalItem = sender.representedObject as? NSMenuItem,
let identifier = originalItem.identifier.map(WKMenuItemIdentifier.init),
Expand Down Expand Up @@ -344,12 +364,9 @@ private extension ContextMenuManager {
}

onNewWindow = { navigationAction in
guard let url = navigationAction?.request.url as NSURL? else { return .cancel }
guard let url = navigationAction?.request.url else { return .cancel }

let pasteboard = NSPasteboard.general
pasteboard.declareTypes([.URL], owner: nil)
url.write(to: pasteboard)
pasteboard.setString(url.absoluteString ?? "", forType: .string)
NSPasteboard.general.copy(url)

return .cancel
}
Expand Down Expand Up @@ -410,9 +427,8 @@ private extension ContextMenuManager {

onNewWindow = { navigationAction in
guard let url = navigationAction?.request.url else { return .cancel }
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(url.absoluteString, forType: .string)
NSPasteboard.general.setString(url.absoluteString, forType: .URL)

NSPasteboard.general.copy(url)

return .cancel
}
Expand Down
15 changes: 7 additions & 8 deletions DuckDuckGo/Common/Extensions/NSPasteboardExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ import Foundation

extension NSPasteboard {

static func copy(_ string: String) {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(string, forType: .string)
func copy(_ string: String) {
clearContents()
setString(string, forType: .string)
}

func copy(url: URL) {
let url = url as NSURL

func copy(_ url: URL, withString string: String? = nil) {
clearContents()
declareTypes([.URL], owner: nil)
url.write(to: self)
setString(url.absoluteString ?? "", forType: .string)
(url as NSURL).write(to: self)
setString(string ?? url.absoluteString, forType: .string)
}

}
4 changes: 3 additions & 1 deletion DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct UserText {
static let open = NSLocalizedString("open", value: "Open", comment: "Open button")
static let save = NSLocalizedString("save", value: "Save", comment: "Save button")
static let edit = NSLocalizedString("edit", value: "Edit", comment: "Edit button")
static let copySelection = NSLocalizedString("copy-selection", value: "Copy", comment: "Copy selection menu item")
static let deleteBookmark = NSLocalizedString("delete-bookmark", value: "Delete Bookmark", comment: "Delete Bookmark button")
static let removeFavorite = NSLocalizedString("remove-favorite", value: "Remove Favorite", comment: "Remove Favorite button")
static let quit = NSLocalizedString("quit", value: "Quit", comment: "Quit button")
Expand Down Expand Up @@ -596,7 +597,8 @@ struct UserText {
static let lookingForBitwarden = NSLocalizedString("looking.for.bitwarden", value: "Bitwarden not installed...", comment: "Setup of the integration with Bitwarden app")
static let allowIntegration = NSLocalizedString("allow.integration", value: "Allow Integration with DuckDuckGo", comment: "Setup of the integration with Bitwarden app")
static let openBitwardenAndLogInOrUnlock = NSLocalizedString("open.bitwarden.and.log.in.or.unlock", value: "Open Bitwarden and Log in or Unlock your vault.", comment: "Setup of the integration with Bitwarden app")
static let selectBitwardenPreferences = NSLocalizedString("select.bitwarden.preferences", value: "Select Bitwarden → Preferences from the Mac menu bar.", comment: "Setup of the integration with Bitwarden app")
static let selectBitwardenPreferences = NSLocalizedString("select.bitwarden.preferences", value: "Select Bitwarden → Preferences from the Mac menu bar.", comment: "Setup of the integration with Bitwarden app (up to and including macOS 12)")
static let selectBitwardenSettings = NSLocalizedString("select.bitwarden.settings", value: "Select Bitwarden → Settings from the Mac menu bar.", comment: "Setup of the integration with Bitwarden app (macOS 13 and above)")
static let scrollToFindAppSettings = NSLocalizedString("scroll.to.find.app.settings", value: "Scroll to find the App Settings (All Accounts) section.", comment: "Setup of the integration with Bitwarden app")
static let checkAllowIntegration = NSLocalizedString("check.allow.integration", value: "Check Allow integration with DuckDuckGo.", comment: "Setup of the integration with Bitwarden app")
static let openBitwarden = NSLocalizedString("open.bitwarden", value: "Open Bitwarden", comment: "Button to open Bitwarden app")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import BrowserServicesKit
final class AppPrivacyConfigurationDataProvider: EmbeddedDataProvider {

public struct Constants {
public static let embeddedDataETag = "\"80cb8938669fa313237df1804bb19db5\""
public static let embeddedDataSHA = "744ff3f73dd77b0fe4f274291ec961de800deef7f2c95943f285e24df4f495bd"
public static let embeddedDataETag = "\"6dec821b8b56702fcbedef50c83103cf\""
public static let embeddedDataSHA = "c3948b583374e053c32b96cc526643c477f92028b91779dc06c55dddb9943602"
}

var embeddedDataEtag: String {
Expand Down
Loading

0 comments on commit 7bdf5e2

Please sign in to comment.