Skip to content

Commit

Permalink
Merge branch 'main' into tom/bookmarks-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstrba committed Dec 9, 2024
2 parents 0140543 + dc12bff commit 2f5332b
Show file tree
Hide file tree
Showing 154 changed files with 3,840 additions and 2,346 deletions.
498 changes: 219 additions & 279 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,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "3517357ecd9d5e9ef7ef2f229c0ebc6460f309e6",
"version" : "216.0.1-1"
"revision" : "a82c14b991f8cbef46d4b7d8e613762f1592fcd2",
"version" : "218.1.0"
}
},
{
Expand All @@ -50,8 +50,8 @@
"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
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 Expand Up @@ -299,6 +309,10 @@
argument = "-NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints YES"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "-SUEnableAutomaticChecks NO"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "-com.apple.CoreData.ConcurrencyDebug 1"
isEnabled = "YES">
Expand Down
22 changes: 13 additions & 9 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ import FeatureFlags
import History
import MetricKit
import Networking
import NewTabPage
import Persistence
import PixelKit
import PixelExperimentKit
import ServiceManagement
import SyncDataProviders
import UserNotifications
Expand Down Expand Up @@ -96,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 @@ -266,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 All @@ -282,7 +285,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
keyValueStore: UserDefaults.appConfiguration,
actionHandler: FeatureFlagOverridesPublishingHandler<FeatureFlag>()
),
experimentManager: ExperimentCohortsManager(store: ExperimentsDataStore()),
experimentManager: ExperimentCohortsManager(store: ExperimentsDataStore(), fireCohortAssigned: PixelKit.fireExperimentEnrollmentPixel(subfeatureID:experiment:)),
for: FeatureFlag.self
)

Expand Down Expand Up @@ -331,6 +334,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
#else
privacyStats = PrivacyStats(databaseProvider: PrivacyStatsDatabase())
#endif
PixelKit.configureExperimentKit(featureFlagger: featureFlagger, eventTracker: ExperimentEventTracker(store: UserDefaults.appConfiguration))
}

func applicationWillFinishLaunching(_ notification: Notification) {
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Autoconsent/autoconsent-bundle.js

Large diffs are not rendered by default.

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
25 changes: 25 additions & 0 deletions DuckDuckGo/Common/Extensions/FileManagerExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@ import os.log

extension FileManager {

#if !SANDBOX_TEST_TOOL
func configurationDirectory() -> URL {
let fm = FileManager.default

guard let dir = fm.containerURL(forSecurityApplicationGroupIdentifier: Bundle.main.appGroup(bundle: .appConfiguration)) else {
fatalError("Failed to get application group URL")
}
let subDir = dir.appendingPathComponent("Configuration")

var isDir: ObjCBool = false
if !fm.fileExists(atPath: subDir.path, isDirectory: &isDir) || !isDir.boolValue {
if !isDir.boolValue {
try? fm.removeItem(at: subDir)
}
do {
try fm.createDirectory(at: subDir, withIntermediateDirectories: true, attributes: nil)
isDir = true
} catch {
fatalError("Failed to create directory at \(subDir.path)")
}
}
return subDir
}
#endif

@discardableResult
func moveItem(at srcURL: URL, to destURL: URL, incrementingIndexIfExists flag: Bool, pathExtension: String? = nil) throws -> URL {
guard srcURL != destURL else { return destURL }
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
}

}
10 changes: 5 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 All @@ -159,6 +154,11 @@ extension URL {
var isSettingsURL: Bool {
isChild(of: .settings) && (pathComponents.isEmpty || PreferencePaneIdentifier(url: self) != nil)
}

var isErrorURL: Bool {
return navigationalScheme == .duck && host == URL.error.host
}

#endif

enum Invalid {
Expand Down
9 changes: 4 additions & 5 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ struct UserText {
static let webProcessCrashPageHeader = NSLocalizedString("page.crash.header", value: "This webpage has crashed.", comment: "Error page heading text shown when a Web Page process had crashed")
static let webProcessCrashPageMessage = NSLocalizedString("page.crash.message", value: "Try reloading the page or come back later.", comment: "Error page message text shown when a Web Page process had crashed")
static let sslErrorPageTabTitle = NSLocalizedString("ssl.error.page.tab.title", value: "Warning: Site May Be Insecure", comment: "Title shown in an error page tab that warn users of security risks on a website due to SSL issues")
static let phishingErrorPageTabTitle = NSLocalizedString("phishing.error.page.tab.title", value: "Warning: Site May Be Deceptive", comment: "Title shown in an error page tab that warn users of security risks on a website that has been flagged as malicious.")

static let phishingErrorPageTabTitle = NSLocalizedString("phishing.error.page.tab.title", value: "Warning: Site May Be Deceptive", comment: "Title shown in an error page tab that warn users of security risks on a website that has been flagged as Phishing.")

static let openSystemPreferences = NSLocalizedString("open.preferences", value: "Open System Preferences", comment: "Open System Preferences (to re-enable permission for the App) (up to and including macOS 12")
static let openSystemSettings = NSLocalizedString("open.settings", value: "Open System Settings…", comment: "This string represents a prompt or button label prompting the user to open system settings")
Expand Down Expand Up @@ -446,9 +445,9 @@ struct UserText {

static let downloadsOpenPopupOnCompletion = NSLocalizedString("downloads.open.on.completion", value: "Automatically open the Downloads panel when downloads complete", comment: "Checkbox to open a Download Manager popover when downloads are completed")

static let phishingDetectionHeader = NSLocalizedString("phishing-detection.enabled.header", value: "Malicious Site Protection", comment: "Header for phishing site protection section in the settings page")
static let phishingDetectionIsEnabled = NSLocalizedString("phishing-detection.enabled.checkbox", value: "Allow DuckDuckGo to warn you before loading a webpage that has been flagged as malicious or fraudulent.", comment: "Checkbox that enables or disables the phishing detection feature in the browser")
static let phishingDetectionEnabledWarning = NSLocalizedString("phishing-detection.enabled.warning", value: "Disabling this feature can put your personal information at risk. Only do so if you fully understand the risk involved.", comment: "A description box to warn users away from disabling phishing protection")
static let maliciousSiteDetectionHeader = NSLocalizedString("phishing-detection.enabled.header", value: "Malicious Site Protection", comment: "Header for phishing site protection section in the settings page")
static let maliciousSiteDetectionIsEnabled = NSLocalizedString("phishing-detection.enabled.checkbox", value: "Allow DuckDuckGo to warn you before loading a webpage that has been flagged as malicious or fraudulent.", comment: "Checkbox that enables or disables the phishing detection feature in the browser")
static let maliciousDetectionEnabledWarning = NSLocalizedString("phishing-detection.enabled.warning", value: "Disabling this feature can put your personal information at risk. Only do so if you fully understand the risk involved.", comment: "A description box to warn users away from disabling malicious site protection")

// MARK: Password Manager
static let passwordManagementAllItems = NSLocalizedString("passsword.management.all-items", value: "All Items", comment: "Used as title for the Autofill All Items option")
Expand Down
Loading

0 comments on commit 2f5332b

Please sign in to comment.