Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into max/support-filterlis…
Browse files Browse the repository at this point in the history
…t-exceptions
  • Loading branch information
muodov committed Dec 19, 2024
2 parents f576daf + 246c6d5 commit f45d219
Show file tree
Hide file tree
Showing 157 changed files with 26,274 additions and 7,492 deletions.
2 changes: 1 addition & 1 deletion Configuration/BuildNumber.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 324
CURRENT_PROJECT_VERSION = 330
2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MARKETING_VERSION = 1.117.0
MARKETING_VERSION = 1.119.0
420 changes: 194 additions & 226 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "e5d390c8559fbe7b1ca67fd3982c91bcc0437d60",
"version" : "218.0.0"
"revision" : "b71ed70ce9b0ef3ce51d4f96da0193ab70493944",
"version" : "221.3.0"
}
},
{
"identity" : "content-scope-scripts",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "c4bb146afdf0c7a93fb9a7d95b1cb255708a470d",
"version" : "6.41.0"
"revision" : "93ea6c3e771bc0b743b38cefbff548c10add9898",
"version" : "6.42.0"
}
},
{
"identity" : "duckduckgo-autofill",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/duckduckgo-autofill.git",
"state" : {
"revision" : "c992041d16ec10d790e6204dce9abf9966d1363c",
"version" : "15.1.0"
"revision" : "88982a3802ac504e2f1a118a73bfdf2d8f4a7735",
"version" : "16.0.0"
}
},
{
Expand Down Expand Up @@ -104,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/privacy-dashboard",
"state" : {
"revision" : "49db79829dcb166b3524afdbc1c680890452ce1c",
"version" : "7.2.1"
"revision" : "022c845b06ace6a4aa712a4fa3e79da32193d5c6",
"version" : "7.4.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@
ReferencedContainer = "container:LocalPackages/AppKitExtensions">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "NewTabPageTests"
BuildableName = "NewTabPageTests"
BlueprintName = "NewTabPageTests"
ReferencedContainer = "container:LocalPackages/NewTabPage">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
20 changes: 11 additions & 9 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import FeatureFlags
import History
import MetricKit
import Networking
import NewTabPage
import Persistence
import PixelKit
import PixelExperimentKit
Expand Down Expand Up @@ -97,12 +98,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
private(set) lazy var newTabPageActionsManager: NewTabPageActionsManaging = NewTabPageActionsManager(
appearancePreferences: .shared,
activeRemoteMessageModel: activeRemoteMessageModel,
privacyStats: privacyStats,
openURLHandler: { url in
Task { @MainActor in
WindowControllersManager.shared.showTab(with: .contentFromURL(url, source: .appOpenUrl))
}
}
privacyStats: privacyStats
)
let privacyStats: PrivacyStatsCollecting
let activeRemoteMessageModel: ActiveRemoteMessageModel
Expand Down Expand Up @@ -267,13 +263,19 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
privacyConfigurationManager: ContentBlocking.shared.privacyConfigurationManager
)
)
activeRemoteMessageModel = ActiveRemoteMessageModel(remoteMessagingClient: remoteMessagingClient)
activeRemoteMessageModel = ActiveRemoteMessageModel(remoteMessagingClient: remoteMessagingClient, openURLHandler: { url in
WindowControllersManager.shared.showTab(with: .contentFromURL(url, source: .appOpenUrl))
})
} else {
// As long as remoteMessagingClient is private to App Delegate and activeRemoteMessageModel
// is used only by HomePage RootView as environment object,
// it's safe to not initialize the client for unit tests to avoid side effects.
remoteMessagingClient = nil
activeRemoteMessageModel = ActiveRemoteMessageModel(remoteMessagingStore: nil, remoteMessagingAvailabilityProvider: nil)
activeRemoteMessageModel = ActiveRemoteMessageModel(
remoteMessagingStore: nil,
remoteMessagingAvailabilityProvider: nil,
openURLHandler: { _ in }
)
}

featureFlagger = DefaultFeatureFlagger(
Expand Down Expand Up @@ -325,7 +327,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

#if DEBUG
if NSApplication.runType.requiresEnvironment {
privacyStats = PrivacyStats(databaseProvider: PrivacyStatsDatabase())
privacyStats = PrivacyStats(databaseProvider: PrivacyStatsDatabase(), errorEvents: PrivacyStatsErrorHandler())
} else {
privacyStats = MockPrivacyStats()
}
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/Autoconsent/autoconsent-bundle.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions DuckDuckGo/Autofill/ContentOverlayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ public final class ContentOverlayViewController: NSViewController, EmailManagerR
return emailManager
}()

lazy var featureFlagger = NSApp.delegateTyped.featureFlagger

lazy var vaultManager: SecureVaultManager = {
let manager = SecureVaultManager(passwordManager: PasswordManagerCoordinator.shared,
includePartialAccountMatches: true,
shouldAllowPartialFormSaves: featureFlagger.isFeatureOn(.autofillPartialFormSaves),
tld: ContentBlocking.shared.tld)
manager.delegate = self
return manager
Expand Down
19 changes: 18 additions & 1 deletion DuckDuckGo/Bookmarks/Model/BookmarkList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ struct BookmarkList {

private(set) var allBookmarkURLsOrdered: [IdentifiableBookmark]
private var favoriteBookmarksOrdered: [IdentifiableBookmark]
private var itemsDict: [String: [Bookmark]]
private var itemsDict: [String: [Bookmark]] {
didSet {
updateLowercasedItemsDict()
}
}

// Copy of itemsDict used for efficient lookups of variant URLs
private(set) var lowercasedItemsDict: [String: [Bookmark]] = [:]

var totalBookmarks: Int {
return allBookmarkURLsOrdered.count
Expand Down Expand Up @@ -76,6 +83,7 @@ struct BookmarkList {
self.allBookmarkURLsOrdered = keysOrdered
self.itemsDict = itemsDict
self.topLevelEntities = topLevelEntities
updateLowercasedItemsDict()
}

mutating func insert(_ bookmark: Bookmark) {
Expand Down Expand Up @@ -149,6 +157,15 @@ struct BookmarkList {
return allBookmarkURLsOrdered
}

private mutating func updateLowercasedItemsDict() {
lowercasedItemsDict = itemsDict.reduce(into: [:]) { result, entry in
let lowercasedKey = entry.key.lowercased()
if result[lowercasedKey] == nil {
result[lowercasedKey] = entry.value
}
}
}

}

private extension BookmarkList {
Expand Down
12 changes: 6 additions & 6 deletions DuckDuckGo/Bookmarks/Model/BookmarkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,16 @@ final class LocalBookmarkManager: BookmarkManager {

/// Finds a bookmark by checking all possible URL variants (http/https, trailing slash).
private func findBookmark(forVariantUrl url: URL) -> Bookmark? {
let urlVariants = url.bookmarkButtonUrlVariants()
guard let list = list else {
return nil
}

for variant in urlVariants {
if let bookmark = getBookmark(for: variant) {
for variant in url.bookmarkButtonUrlVariants() {
let variantString = variant.absoluteString.lowercased()
if let bookmark = list.lowercasedItemsDict[variantString]?.first {
return bookmark
}
}

return nil
}

Expand All @@ -202,8 +204,6 @@ final class LocalBookmarkManager: BookmarkManager {
}

@discardableResult func makeBookmark(for url: URL, title: String, isFavorite: Bool, index: Int? = nil, parent: BookmarkFolder? = nil) -> Bookmark? {
assert(url.absoluteString.lowercased() == url.absoluteString)

guard list != nil else { return nil }

guard !isUrlBookmarked(url: url) else {
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/Bookmarks/Services/BookmarkStoreMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ final class BookmarkStoreMock: BookmarkStore, CustomDebugStringConvertible {
queue.append(contentsOf: folder.children)
}
}
var indexInFavoritesArray = 0
store?.save(entitiesAtIndices: entities.map { ($0, nil, nil) }, completion: { _ in })
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ final class AddEditBookmarkDialogViewModel: BookmarkDialogEditing {
}

func addOrSave(dismiss: () -> Void) {
guard let url = bookmarkURLPath.lowercased().url else {
guard let url = bookmarkURLPath.url else {
assertionFailure("Invalid URL, default action button should be disabled.")
return
}
Expand Down
6 changes: 3 additions & 3 deletions DuckDuckGo/BookmarksBar/View/BookmarksBarMenuPopover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ extension BookmarksBarMenuPopover: BookmarksBarMenuViewControllerDelegate {
}

func popover(shouldPreventClosure: Bool) {
var popover: BookmarksBarMenuPopover! = self
while popover != nil {
var window = contentViewController?.view.window
while let popover = window?.contentViewController?.nextResponder as? Self {
popover.behavior = shouldPreventClosure ? .applicationDefined : .transient
popover = mainWindow?.contentViewController?.nextResponder as? BookmarksBarMenuPopover
window = window?.parent
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//

import AppKit
import Utilities

typealias NSAttributedStringBuilder = ArrayBuilder<NSAttributedString>
extension NSAttributedString {
Expand Down
86 changes: 0 additions & 86 deletions DuckDuckGo/Common/Extensions/NSMenuItemExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,6 @@ extension NSMenuItem {
return item
}

convenience init(title string: String, action selector: Selector? = nil, target: AnyObject? = nil, keyEquivalent: NSEvent.KeyEquivalent = [], representedObject: Any? = nil, state: NSControl.StateValue = .off, items: [NSMenuItem]? = nil) {
self.init(title: string, action: selector, keyEquivalent: keyEquivalent.charCode)
if !keyEquivalent.modifierMask.isEmpty {
self.keyEquivalentModifierMask = keyEquivalent.modifierMask
}
self.target = target
self.representedObject = representedObject
self.state = state

if let items {
self.submenu = NSMenu(title: title, items: items)
}
}

convenience init(title string: String, action selector: Selector? = nil, target: AnyObject? = nil, keyEquivalent: NSEvent.KeyEquivalent = [], representedObject: Any? = nil, state: NSControl.StateValue = .off, @MenuBuilder items: () -> [NSMenuItem]) {
self.init(title: string, action: selector, target: target, keyEquivalent: keyEquivalent, representedObject: representedObject, state: state, items: items())
}

convenience init(action selector: Selector?) {
self.init()
self.action = selector
}

convenience init(bookmarkViewModel: BookmarkViewModel) {
self.init()

Expand All @@ -65,67 +42,4 @@ extension NSMenuItem {
representedObject = bookmarkViewModels
action = #selector(MainViewController.openAllInTabs(_:))
}

convenience init(title: String) {
self.init(title: title, action: nil, keyEquivalent: "")
}

var topMenu: NSMenu? {
var menuItem = self
while let parent = menuItem.parent {
menuItem = parent
}

return menuItem.menu
}

func removeFromParent() {
parent?.submenu?.removeItem(self)
}

@discardableResult
func alternate() -> NSMenuItem {
self.isAlternate = true
return self
}

@discardableResult
func hidden() -> NSMenuItem {
self.isHidden = true
if !keyEquivalent.isEmpty {
self.allowsKeyEquivalentWhenHidden = true
}
return self
}

@discardableResult
func submenu(_ submenu: NSMenu) -> NSMenuItem {
self.submenu = submenu
return self
}

@discardableResult
func withImage(_ image: NSImage?) -> NSMenuItem {
self.image = image
return self
}

@discardableResult
func targetting(_ target: AnyObject) -> NSMenuItem {
self.target = target
return self
}

@discardableResult
func withSubmenu(_ submenu: NSMenu) -> NSMenuItem {
self.submenu = submenu
return self
}

@discardableResult
func withModifierMask(_ mask: NSEvent.ModifierFlags) -> NSMenuItem {
self.keyEquivalentModifierMask = mask
return self
}

}
7 changes: 2 additions & 5 deletions DuckDuckGo/Common/Extensions/URLExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@ extension URL {
// base url for Error Page Alternate HTML loaded into Web View
static let error = URL(string: "duck://error")!

static func duckFavicon(for faviconURL: URL) -> URL? {
let encodedURL = faviconURL.absoluteString.percentEncoded(withAllowedCharacters: .urlPathAllowed)
return URL(string: "duck://favicon/\(encodedURL)")
}

static let dataBrokerProtection = URL(string: "duck://personal-information-removal")!

#if !SANDBOX_TEST_TOOL
Expand Down Expand Up @@ -396,6 +391,8 @@ extension URL {
return URL(string: "https://duckduckgo.com/duckduckgo-help-pages/sync-and-backup/password-manager-security/")!
}

static var maliciousSiteProtectionLearnMore = URL(string: "https://duckduckgo.com/duckduckgo-help-pages/privacy/phishing-and-malware-protection/")!

static var searchSettings: URL {
return URL(string: "https://duckduckgo.com/settings/")!
}
Expand Down
12 changes: 6 additions & 6 deletions DuckDuckGo/Common/Localizables/UserText+DBP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import Common

// MARK: - DBP Error pages
extension UserText {
static let dbpErrorPageBadPathTitle = NotLocalizedString("dbp.errorpage.bad.path.title", value: "Move DuckDuckGo App to Applications", comment: "Title for Personal Information Removal bad path error screen")
static let dbpErrorPageBadPathMessage = NotLocalizedString("dbp.errorpage.bad.path.message", value: "To use Personal Information Removal, the DuckDuckGo app needs to be in the Applications folder on your Mac. You can move the app yourself and restart the browser, or we can do it for you.", comment: "Message for Personal Information Removal bad path error screen")
static let dbpErrorPageBadPathCTA = NotLocalizedString("dbp.errorpage.bad.path.cta", value: "Move App for Me...", comment: "Call to action for moving the app to the Applications folder")
static let dbpErrorPageBadPathTitle = NSLocalizedString("dbp.errorpage.bad.path.title", value: "Move DuckDuckGo App to Applications", comment: "Title for Personal Information Removal bad path error screen")
static let dbpErrorPageBadPathMessage = NSLocalizedString("dbp.errorpage.bad.path.message", value: "To use Personal Information Removal, the DuckDuckGo app needs to be in the Applications folder on your Mac. You can move the app yourself and restart the browser, or we can do it for you.", comment: "Message for Personal Information Removal bad path error screen")
static let dbpErrorPageBadPathCTA = NSLocalizedString("dbp.errorpage.bad.path.cta", value: "Move App for Me...", comment: "Call to action for moving the app to the Applications folder")

static let dbpErrorPageNoPermissionTitle = NotLocalizedString("dbp.errorpage.no.permission.title", value: "Change System Setting", comment: "Title for error screen when there is no permission")
static let dbpErrorPageNoPermissionMessage = NotLocalizedString("dbp.errorpage.no.permission.message", value: "Open System Settings and allow DuckDuckGo Personal Information Removal to run in the background.", comment: "Message for error screen when there is no permission")
static let dbpErrorPageNoPermissionCTA = NotLocalizedString("dbp.errorpage.no.permission.cta", value: "Open System Settings...", comment: "Call to action for opening system settings")
static let dbpErrorPageNoPermissionTitle = NSLocalizedString("dbp.errorpage.no.permission.title", value: "Change System Setting", comment: "Title for error screen when there is no permission")
static let dbpErrorPageNoPermissionMessage = NSLocalizedString("dbp.errorpage.no.permission.message", value: "Open System Settings and allow DuckDuckGo Personal Information Removal to run in the background.", comment: "Message for error screen when there is no permission")
static let dbpErrorPageNoPermissionCTA = NSLocalizedString("dbp.errorpage.no.permission.cta", value: "Open System Settings...", comment: "Call to action for opening system settings")
}
Loading

0 comments on commit f45d219

Please sign in to comment.