Skip to content

Commit

Permalink
Merge branch 'main' into graeme/sanitize-location-selection
Browse files Browse the repository at this point in the history
# By Elle Sullivan (10) and others
# Via GitHub (6) and others
* main: (42 commits)
  Update autoconsent to v10.9.0 (#2822)
  Bump version to 1.90.0 (196)
  Revert "Add PIPAgent entitlement (#2821)" (#2823)
  Bump version to 1.90.0 (195)
  Bump version to 1.90.0 (194)
  Add PIPAgent entitlement (#2821)
  Fixes some VPN uninstallation issues (#2820)
  Bump version to 1.90.0 (193)
  Remove autofill survey (#2819)
  Remove autofill survey (#2819)
  Bump version to 1.90.0 (192)
  Set marketing version to 1.90.0
  Update embedded files
  Privacy Pro survey support (#2816)
  Update PeopleWhiz Broker Files to use hash id (#2814)
  Update BSK due to iOS changes. (#2776)
  Scroll address bar to caret when using arrows (#2799)
  Privacy Pro macOS quick follow ups (#2813)
  BSK bump for iOS RMF updates (#2798)
  Autofill engagement KPIs for pixel reporting (#2806)
  ...

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
  • Loading branch information
samsymons committed Jun 1, 2024
2 parents c3e853e + 2e0956a commit c095d99
Show file tree
Hide file tree
Showing 192 changed files with 6,367 additions and 4,740 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 = 190
CURRENT_PROJECT_VERSION = 196
2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MARKETING_VERSION = 1.89.0
MARKETING_VERSION = 1.90.0
342 changes: 208 additions & 134 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "bb8e7e62104ed6506c7bfd3ef7aa4aca3686ed4f",
"version" : "5.15.0"
"revision" : "fa861c4eccb21d235e34070b208b78bdc32ece08",
"version" : "5.17.0"
}
},
{
Expand Down Expand Up @@ -131,8 +131,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "46989693916f56d1186bd59ac15124caef896560",
"version" : "1.3.1"
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b",
"version" : "1.4.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@
<Test
Identifier = "CoreDataEncryptionTests/testSavingIncorrectValueTypes()">
</Test>
<Test
Identifier = "DownloadsIntegrationTests/testWhenDownloadIsStartedInNewTab_tabIsClosed()">
</Test>
<Test
Identifier = "EncryptionKeyStoreTests">
</Test>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
version = "1.8">
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
Expand Down
159 changes: 90 additions & 69 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ import ServiceManagement
import SyncDataProviders
import UserNotifications
import Lottie

import NetworkProtection
import Subscription
import NetworkProtectionIPC
import DataBrokerProtection

@MainActor
// @MainActor
final class AppDelegate: NSObject, NSApplicationDelegate {

#if DEBUG
Expand Down Expand Up @@ -76,6 +76,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
let featureFlagger: FeatureFlagger
private var appIconChanger: AppIconChanger!
private var autoClearHandler: AutoClearHandler!
private(set) var autofillPixelReporter: AutofillPixelReporter?

private(set) var syncDataProviders: SyncDataProviders!
private(set) var syncService: DDGSyncing?
Expand All @@ -86,20 +87,21 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
let bookmarksManager = LocalBookmarkManager.shared
var privacyDashboardWindow: NSWindow?

// Needs to be lazy as indirectly depends on AppDelegate
private lazy var networkProtectionSubscriptionEventHandler: NetworkProtectionSubscriptionEventHandler = {

let ipcClient = TunnelControllerIPCClient()
let tunnelController = NetworkProtectionIPCTunnelController(ipcClient: ipcClient)
let vpnUninstaller = VPNUninstaller(ipcClient: ipcClient)
private var accountManager: AccountManaging {
subscriptionManager.accountManager
}
public let subscriptionManager: SubscriptionManaging
public let vpnSettings = VPNSettings(defaults: .netP)

return NetworkProtectionSubscriptionEventHandler(
tunnelController: tunnelController,
vpnUninstaller: vpnUninstaller)
private var networkProtectionSubscriptionEventHandler: NetworkProtectionSubscriptionEventHandler?
#if DBP
private lazy var dataBrokerProtectionSubscriptionEventHandler: DataBrokerProtectionSubscriptionEventHandler = {
let authManager = DataBrokerAuthenticationManagerBuilder.buildAuthenticationManager(subscriptionManager: subscriptionManager)
return DataBrokerProtectionSubscriptionEventHandler(featureDisabler: DataBrokerProtectionFeatureDisabler(),
authenticationManager: authManager,
pixelHandler: DataBrokerProtectionPixelsHandler())
}()

#if DBP
private let dataBrokerProtectionSubscriptionEventHandler = DataBrokerProtectionSubscriptionEventHandler()
#endif

private var didFinishLaunching = false
Expand Down Expand Up @@ -188,19 +190,14 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
privacyConfigManager: AppPrivacyFeatures.shared.contentBlocking.privacyConfigurationManager
)

#if APPSTORE || !STRIPE
SubscriptionPurchaseEnvironment.current = .appStore
#else
SubscriptionPurchaseEnvironment.current = .stripe
#endif
}
// Configure Subscription
subscriptionManager = SubscriptionManager()

static func configurePixelKit() {
#if DEBUG
Self.setUpPixelKit(dryRun: true)
#else
Self.setUpPixelKit(dryRun: false)
#endif
// Update VPN environment and match the Subscription environment
vpnSettings.alignTo(subscriptionEnvironment: subscriptionManager.currentEnvironment)

// Update DBP environment and match the Subscription environment
DataBrokerProtectionSettings().alignTo(subscriptionEnvironment: subscriptionManager.currentEnvironment)
}

func applicationWillFinishLaunching(_ notification: Notification) {
Expand All @@ -217,6 +214,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
#endif

appIconChanger = AppIconChanger(internalUserDecider: internalUserDecider)

// Configure Event handlers
let ipcClient = TunnelControllerIPCClient()
let tunnelController = NetworkProtectionIPCTunnelController(ipcClient: ipcClient)
let vpnUninstaller = VPNUninstaller(ipcClient: ipcClient)

networkProtectionSubscriptionEventHandler = NetworkProtectionSubscriptionEventHandler(subscriptionManager: subscriptionManager,
tunnelController: tunnelController,
vpnUninstaller: vpnUninstaller)
}

// swiftlint:disable:next function_body_length
Expand Down Expand Up @@ -264,19 +270,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

startupSync()

let defaultEnvironment = SubscriptionPurchaseEnvironment.ServiceEnvironment.default

let currentEnvironment = UserDefaultsWrapper(key: .subscriptionEnvironment,
defaultValue: defaultEnvironment).wrappedValue
SubscriptionPurchaseEnvironment.currentServiceEnvironment = currentEnvironment

Task {
let accountManager = AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs))
if let token = accountManager.accessToken {
_ = await SubscriptionService.getSubscription(accessToken: token, cachePolicy: .reloadIgnoringLocalCacheData)
_ = await accountManager.fetchEntitlements(cachePolicy: .reloadIgnoringLocalCacheData)
}
}
subscriptionManager.loadInitialData()

if [.normal, .uiTests].contains(NSApp.runType) {
stateRestorationManager.applicationDidFinishLaunching()
Expand Down Expand Up @@ -314,9 +308,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

UserDefaultsWrapper<Any>.clearRemovedKeys()

networkProtectionSubscriptionEventHandler.registerForSubscriptionAccountManagerEvents()
networkProtectionSubscriptionEventHandler?.registerForSubscriptionAccountManagerEvents()

NetworkProtectionAppEvents().applicationDidFinishLaunching()
NetworkProtectionAppEvents(featureVisibility: DefaultNetworkProtectionVisibility(subscriptionManager: subscriptionManager)).applicationDidFinishLaunching()
UNUserNotificationCenter.current().delegate = self

#if DBP
Expand All @@ -328,6 +322,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
#endif

setUpAutoClearHandler()

setUpAutofillPixelReporter()
}

func applicationDidBecomeActive(_ notification: Notification) {
Expand All @@ -336,15 +332,18 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
syncService?.initializeIfNeeded()
syncService?.scheduler.notifyAppLifecycleEvent()

NetworkProtectionAppEvents().applicationDidBecomeActive()

NetworkProtectionAppEvents(featureVisibility: DefaultNetworkProtectionVisibility(subscriptionManager: subscriptionManager)).applicationDidBecomeActive()
#if DBP
DataBrokerProtectionAppEvents().applicationDidBecomeActive()
#endif

AppPrivacyFeatures.shared.contentBlocking.privacyConfigurationManager.toggleProtectionsCounter.sendEventsIfNeeded()

updateSubscriptionStatus()
subscriptionManager.updateSubscriptionStatus { isActive in
if isActive {
PixelKit.fire(PrivacyProPixel.privacyProSubscriptionActive, frequency: .daily)
}
}
}

func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
Expand Down Expand Up @@ -386,9 +385,14 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
urlEventHandler.handleFiles(files)
}

private func applyPreferredTheme() {
let appearancePreferences = AppearancePreferences()
appearancePreferences.updateUserInterfaceStyle()
// MARK: - PixelKit

static func configurePixelKit() {
#if DEBUG
Self.setUpPixelKit(dryRun: true)
#else
Self.setUpPixelKit(dryRun: false)
#endif
}

private static func setUpPixelKit(dryRun: Bool) {
Expand All @@ -415,6 +419,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}
}

// MARK: - Theme

private func applyPreferredTheme() {
let appearancePreferences = AppearancePreferences()
appearancePreferences.updateUserInterfaceStyle()
}

// MARK: - Sync

private func startupSync() {
Expand Down Expand Up @@ -490,7 +501,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
switch response {
case .alertSecondButtonReturn:
alert.window.sheetParent?.endSheet(alert.window)
WindowControllersManager.shared.showPreferencesTab(withSelectedPane: .sync)
DispatchQueue.main.async {
WindowControllersManager.shared.showPreferencesTab(withSelectedPane: .sync)
}
default:
break
}
Expand Down Expand Up @@ -567,30 +580,36 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}

private func setUpAutoClearHandler() {
autoClearHandler = AutoClearHandler(preferences: .shared,
fireViewModel: FireCoordinator.fireViewModel,
stateRestorationManager: stateRestorationManager)
autoClearHandler.handleAppLaunch()
autoClearHandler.onAutoClearCompleted = {
NSApplication.shared.reply(toApplicationShouldTerminate: true)
}
}

}

func updateSubscriptionStatus() {
Task {
let accountManager = AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs))

guard let token = accountManager.accessToken else { return }

if case .success(let subscription) = await SubscriptionService.getSubscription(accessToken: token, cachePolicy: .reloadIgnoringLocalCacheData) {
if subscription.isActive {
PixelKit.fire(PrivacyProPixel.privacyProSubscriptionActive, frequency: .daily)
DispatchQueue.main.async {
self.autoClearHandler = AutoClearHandler(preferences: .shared,
fireViewModel: FireCoordinator.fireViewModel,
stateRestorationManager: self.stateRestorationManager)
self.autoClearHandler.handleAppLaunch()
self.autoClearHandler.onAutoClearCompleted = {
NSApplication.shared.reply(toApplicationShouldTerminate: true)
}
}
}

_ = await accountManager.fetchEntitlements(cachePolicy: .reloadIgnoringLocalCacheData)
private func setUpAutofillPixelReporter() {
autofillPixelReporter = AutofillPixelReporter(
userDefaults: .standard,
eventMapping: EventMapping<AutofillPixelEvent> {event, _, params, _ in
switch event {
case .autofillActiveUser:
PixelKit.fire(GeneralPixel.autofillActiveUser)
case .autofillEnabledUser:
PixelKit.fire(GeneralPixel.autofillEnabledUser)
case .autofillOnboardedUser:
PixelKit.fire(GeneralPixel.autofillOnboardedUser)
case .autofillLoginsStacked:
PixelKit.fire(GeneralPixel.autofillLoginsStacked, withAdditionalParameters: params)
case .autofillCreditCardsStacked:
PixelKit.fire(GeneralPixel.autofillCreditCardsStacked, withAdditionalParameters: params)
}
},
passwordManager: PasswordManagerCoordinator.shared,
installDate: AppDelegate.firstLaunchDate)
}
}

Expand All @@ -609,7 +628,9 @@ extension AppDelegate: UNUserNotificationCenterDelegate {

#if DBP
if response.notification.request.identifier == DataBrokerProtectionWaitlist.notificationIdentifier {
DataBrokerProtectionAppEvents().handleWaitlistInvitedNotification(source: .localPush)
DispatchQueue.main.async {
DataBrokerProtectionAppEvents().handleWaitlistInvitedNotification(source: .localPush)
}
}
#endif
}
Expand Down
12 changes: 7 additions & 5 deletions DuckDuckGo/Application/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ import Foundation
final class Application: NSApplication {

private let copyHandler = CopyHandler()
private var _delegate: AppDelegate!
// private var _delegate: AppDelegate!
public static var appDelegate: AppDelegate!

override init() {
super.init()

_delegate = AppDelegate()
self.delegate = _delegate
let delegate = AppDelegate()
self.delegate = delegate
Application.appDelegate = delegate

let mainMenu = MainMenu(featureFlagger: _delegate.featureFlagger,
bookmarkManager: _delegate.bookmarksManager,
let mainMenu = MainMenu(featureFlagger: delegate.featureFlagger,
bookmarkManager: delegate.bookmarksManager,
faviconManager: FaviconManager.shared,
copyHandler: copyHandler)
self.mainMenu = mainMenu
Expand Down
Loading

0 comments on commit c095d99

Please sign in to comment.