Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into autofill/anya-never-s…
Browse files Browse the repository at this point in the history
…ave-site

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
  • Loading branch information
amddg44 committed Dec 28, 2023
2 parents 5dc6318 + 3e020ba commit fc021b8
Show file tree
Hide file tree
Showing 285 changed files with 23,396 additions and 7,126 deletions.
3 changes: 2 additions & 1 deletion Configuration/App/DuckDuckGoPrivacyPro.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@

#include "DuckDuckGo.xcconfig"

FEATURE_FLAGS = FEEDBACK NETWORK_PROTECTION SPARKLE SUBSCRIPTION DBP
FEATURE_FLAGS = FEEDBACK NETWORK_PROTECTION SPARKLE SUBSCRIPTION DBP STRIPE
PRODUCT_NAME = $(PRODUCT_NAME_PREFIX) Privacy Pro
PRODUCT_MODULE_NAME = DuckDuckGo_Privacy_Browser
2 changes: 1 addition & 1 deletion Configuration/BuildNumber.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 95
CURRENT_PROJECT_VERSION = 97
7 changes: 7 additions & 0 deletions Configuration/Global.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,10 @@ DDG_SLOW_COMPILE_CHECK_THRESHOLD[config=CI] = 250
DDG_SLOW_COMPILE_CHECK = -Xfrontend -warn-long-expression-type-checking=$(DDG_SLOW_COMPILE_CHECK_THRESHOLD) -Xfrontend -warn-long-function-bodies=$(DDG_SLOW_COMPILE_CHECK_THRESHOLD)
OTHER_SWIFT_FLAGS[config=Debug][arch=*][sdk=*] = $(inherited) $(DDG_SLOW_COMPILE_CHECK)
OTHER_SWIFT_FLAGS[config=CI][arch=*][sdk=*] = $(inherited) $(DDG_SLOW_COMPILE_CHECK)

// Automatically generate Color and Image asset accessor extensions
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES

// Automatically generate localization string catalogs
LOCALIZATION_PREFERS_STRING_CATALOGS = YES
SWIFT_EMIT_LOC_STRINGS = YES
611 changes: 386 additions & 225 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
Expand Down
76 changes: 73 additions & 3 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import UserNotifications
import NetworkProtection
#endif

#if SUBSCRIPTION
import Subscription
#endif

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

Expand Down Expand Up @@ -69,10 +73,19 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
private(set) var syncDataProviders: SyncDataProviders!
private(set) var syncService: DDGSyncing?
private var isSyncInProgressCancellable: AnyCancellable?
private var syncFeatureFlagsCancellable: AnyCancellable?
private var screenLockedCancellable: AnyCancellable?
private var emailCancellables = Set<AnyCancellable>()
let bookmarksManager = LocalBookmarkManager.shared

#if NETWORK_PROTECTION && SUBSCRIPTION
private let networkProtectionSubscriptionEventHandler = NetworkProtectionSubscriptionEventHandler()
#endif

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

private var didFinishLaunching = false

#if SPARKLE
Expand Down Expand Up @@ -179,6 +192,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
appIconChanger = AppIconChanger(internalUserDecider: internalUserDecider)
}

// swiftlint:disable:next function_body_length
func applicationDidFinishLaunching(_ notification: Notification) {
guard NSApp.runType.requiresEnvironment else { return }
defer {
Expand Down Expand Up @@ -237,14 +251,33 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel

UserDefaultsWrapper<Any>.clearRemovedKeys()

#if NETWORK_PROTECTION && SUBSCRIPTION
networkProtectionSubscriptionEventHandler.registerForSubscriptionAccountManagerEvents()
#endif

#if NETWORK_PROTECTION
NetworkProtectionAppEvents().applicationDidFinishLaunching()
UNUserNotificationCenter.current().delegate = self
#endif

#if DBP && SUBSCRIPTION
dataBrokerProtectionSubscriptionEventHandler.registerForSubscriptionAccountManagerEvents()
#endif

#if DBP
DataBrokerProtectionAppEvents().applicationDidFinishLaunching()
#endif

#if SUBSCRIPTION
Task {
#if STRIPE
SubscriptionPurchaseEnvironment.current = .stripe
#else
SubscriptionPurchaseEnvironment.current = .appStore
#endif
await AccountManager().checkSubscriptionState()
}
#endif
}

func applicationDidBecomeActive(_ notification: Notification) {
Expand Down Expand Up @@ -339,7 +372,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
let environment = defaultEnvironment
#endif
let syncDataProviders = SyncDataProviders(bookmarksDatabase: BookmarkDatabase.shared.db)
let syncService = DDGSync(dataProvidersSource: syncDataProviders, errorEvents: SyncErrorHandler(), log: OSLog.sync, environment: environment)
let syncService = DDGSync(
dataProvidersSource: syncDataProviders,
errorEvents: SyncErrorHandler(),
privacyConfigurationManager: ContentBlocking.shared.privacyConfigurationManager,
log: OSLog.sync,
environment: environment
)
syncService.initializeIfNeeded()
syncDataProviders.setUpDatabaseCleaners(syncService: syncService)

Expand All @@ -356,12 +395,43 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
isSyncInProgressCancellable = syncService.isSyncInProgressPublisher
.filter { $0 }
.asVoid()
.prefix(1)
.sink {
.sink { [weak syncService] in
Pixel.fire(.syncDaily, limitTo: .dailyFirst)
syncService?.syncDailyStats.sendStatsIfNeeded(handler: { params in
Pixel.fire(.syncSuccessRateDaily, withAdditionalParameters: params)
})
}

subscribeSyncQueueToScreenLockedNotifications()
subscribeToSyncFeatureFlags(syncService)
}

@UserDefaultsWrapper(key: .syncDidShowSyncPausedByFeatureFlagAlert, defaultValue: false)
private var syncDidShowSyncPausedByFeatureFlagAlert: Bool

private func subscribeToSyncFeatureFlags(_ syncService: DDGSync) {
syncFeatureFlagsCancellable = syncService.featureFlagsPublisher
.dropFirst()
.map { $0.contains(.dataSyncing) }
.receive(on: DispatchQueue.main)
.sink { [weak self, weak syncService] isDataSyncingAvailable in
if isDataSyncingAvailable {
self?.syncDidShowSyncPausedByFeatureFlagAlert = false
} else if syncService?.authState == .active, self?.syncDidShowSyncPausedByFeatureFlagAlert == false {
let isSyncUIVisible = syncService?.featureFlags.contains(.userInterface) == true
let alert = NSAlert.dataSyncingDisabledByFeatureFlag(showLearnMore: isSyncUIVisible)
let response = alert.runModal()
self?.syncDidShowSyncPausedByFeatureFlagAlert = true

switch response {
case .alertSecondButtonReturn:
alert.window.sheetParent?.endSheet(alert.window)
WindowControllersManager.shared.showPreferencesTab(withSelectedPane: .sync)
default:
break
}
}
}
}

private func subscribeSyncQueueToScreenLockedNotifications() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Import-Export-16D.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Menu-Hamburger-16.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Loading

0 comments on commit fc021b8

Please sign in to comment.