Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into max/cpm-ad-experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
muodov committed Aug 9, 2024
2 parents 6382684 + c021275 commit 4c7e831
Show file tree
Hide file tree
Showing 137 changed files with 13,579 additions and 4,021 deletions.
2 changes: 1 addition & 1 deletion Configuration/App/DBP/DuckDuckGoDBPAgent.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*] =
PROVISIONING_PROFILE_SPECIFIER[config=Review][sdk=macosx*] = macOS DBP Agent - Review
PROVISIONING_PROFILE_SPECIFIER[config=Release][sdk=macosx*] = macOS DBP Agent - Release

FEATURE_FLAGS = FEEDBACK DBP
FEATURE_FLAGS = FEEDBACK

GCC_PREPROCESSOR_DEFINITIONS[arch=*][sdk=*] = DBP=1 NETP_SYSTEM_EXTENSION=1
GCC_PREPROCESSOR_DEFINITIONS[config=CI][arch=*][sdk=*] = DBP=1 NETP_SYSTEM_EXTENSION=1 DEBUG=1 CI=1 $(inherited)
Expand Down
2 changes: 1 addition & 1 deletion Configuration/App/DBP/DuckDuckGoDBPAgentAppStore.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*] =
PROVISIONING_PROFILE_SPECIFIER[config=Review][sdk=macosx*] = match AppStore com.duckduckgo.mobile.ios.DBP.backgroundAgent.review macos
PROVISIONING_PROFILE_SPECIFIER[config=Release][sdk=macosx*] = match AppStore com.duckduckgo.mobile.ios.DBP.backgroundAgent macos

FEATURE_FLAGS = FEEDBACK DBP
FEATURE_FLAGS = FEEDBACK

GCC_PREPROCESSOR_DEFINITIONS[arch=*][sdk=*] = DBP=1 NETP_SYSTEM_EXTENSION=1
GCC_PREPROCESSOR_DEFINITIONS[config=CI][arch=*][sdk=*] = DBP=1 NETP_SYSTEM_EXTENSION=1 DEBUG=1 CI=1 $(inherited)
Expand Down
2 changes: 1 addition & 1 deletion Configuration/App/DuckDuckGo.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CODE_SIGN_IDENTITY[sdk=macosx*] = Developer ID Application
CODE_SIGN_IDENTITY[config=Debug][sdk=macosx*] = Apple Development
CODE_SIGN_IDENTITY[config=CI][sdk=macosx*] =

FEATURE_FLAGS = FEEDBACK SPARKLE DBP STRIPE
FEATURE_FLAGS = FEEDBACK SPARKLE STRIPE

PRODUCT_NAME_PREFIX = DuckDuckGo

Expand Down
2 changes: 1 addition & 1 deletion Configuration/BuildNumber.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 236
CURRENT_PROJECT_VERSION = 243
2 changes: 1 addition & 1 deletion Configuration/Common.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COMBINE_HIDPI_IMAGES = YES
DEVELOPMENT_TEAM = HKE973VLUW
DEVELOPMENT_TEAM[config=CI][sdk=*] =

FEATURE_FLAGS = FEEDBACK DBP
FEATURE_FLAGS = FEEDBACK

GCC_PREPROCESSOR_DEFINITIONS[config=CI][arch=*][sdk=*] = DEBUG=1 CI=1 $(inherited)
GCC_PREPROCESSOR_DEFINITIONS[config=Debug][arch=*][sdk=*] = DEBUG=1 $(inherited)
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Tests/IntegrationTests.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

MACOSX_DEPLOYMENT_TARGET = 11.4

FEATURE_FLAGS = FEEDBACK DBP
FEATURE_FLAGS = FEEDBACK

INFOPLIST_FILE = IntegrationTests/Info.plist
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.Integration-Tests
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Tests/UnitTests.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES

FEATURE_FLAGS = FEEDBACK DBP
FEATURE_FLAGS = FEEDBACK

INFOPLIST_FILE = UnitTests/Info.plist
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser.DuckDuckGoTests
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Tests/UnitTestsAppStore.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "UnitTests.xcconfig"
#include "../AppStore.xcconfig"

FEATURE_FLAGS = FEEDBACK DBP
FEATURE_FLAGS = FEEDBACK

PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.mobile.ios.DuckDuckGoTests

Expand Down
2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MARKETING_VERSION = 1.100.0
MARKETING_VERSION = 1.101.0
120 changes: 90 additions & 30 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@
<Test
Identifier = "NavigationProtectionIntegrationTests/testReferrerTrimming()">
</Test>
<Test
Identifier = "TabContentTests/testWhenPDFContextMenuPrintChosen_printDialogOpens()">
</Test>
<Test
Identifier = "TabContentTests/testWhenPDFMainMenuPrintChosen_printDialogOpens()">
</Test>
</SkippedTests>
</TestableReference>
<TestableReference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@
<Test
Identifier = "NavigationProtectionIntegrationTests/testReferrerTrimming()">
</Test>
<Test
Identifier = "TabContentTests/testWhenPDFContextMenuPrintChosen_printDialogOpens()">
</Test>
<Test
Identifier = "TabContentTests/testWhenPDFContextMenuSaveAsChosen_saveDialogOpens()">
</Test>
<Test
Identifier = "TabContentTests/testWhenPDFMainMenuPrintChosen_printDialogOpens()">
</Test>
</SkippedTests>
</TestableReference>
<TestableReference
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.7">
version = "1.8">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
Expand Down
26 changes: 7 additions & 19 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

// MARK: - DBP

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

#endif

private lazy var vpnRedditSessionWorkaround: VPNRedditSessionWorkaround = {
let ipcClient = VPNControllerXPCClient.shared
let statusReporter = DefaultNetworkProtectionStatusReporter(
Expand Down Expand Up @@ -192,19 +189,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
fatalError("Could not load DB: \(error.localizedDescription)")
}

let preMigrationErrorHandling = EventMapping<BookmarkFormFactorFavoritesMigration.MigrationErrors> { _, error, _, _ in
do {
let formFactorFavMigration = BookmarkFormFactorFavoritesMigration()
let favoritesOrder = try formFactorFavMigration.getFavoritesOrderFromPreV4Model(dbContainerLocation: BookmarkDatabase.defaultDBLocation,
dbFileURL: BookmarkDatabase.defaultDBFileURL)
BookmarkDatabase.shared.preFormFactorSpecificFavoritesFolderOrder = favoritesOrder
} catch {
PixelKit.fire(DebugEvent(GeneralPixel.bookmarksCouldNotLoadDatabase(error: error)))
Thread.sleep(forTimeInterval: 1)
fatalError("Could not create Bookmarks database stack: \(error?.localizedDescription ?? "err")")
fatalError("Could not create Bookmarks database stack: \(error.localizedDescription)")
}

BookmarkDatabase.shared.preFormFactorSpecificFavoritesFolderOrder = BookmarkFormFactorFavoritesMigration
.getFavoritesOrderFromPreV4Model(
dbContainerLocation: BookmarkDatabase.defaultDBLocation,
dbFileURL: BookmarkDatabase.defaultDBFileURL,
errorEvents: preMigrationErrorHandling
)

BookmarkDatabase.shared.db.loadStore { context, error in
guard let context = context else {
PixelKit.fire(DebugEvent(GeneralPixel.bookmarksCouldNotLoadDatabase(error: error)))
Expand Down Expand Up @@ -376,13 +371,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
NetworkProtectionAppEvents(featureGatekeeper: DefaultVPNFeatureGatekeeper(subscriptionManager: subscriptionManager)).applicationDidFinishLaunching()
UNUserNotificationCenter.current().delegate = self

#if DBP
dataBrokerProtectionSubscriptionEventHandler.registerForSubscriptionAccountManagerEvents()
#endif

#if DBP
DataBrokerProtectionAppEvents(featureGatekeeper: DefaultDataBrokerProtectionFeatureGatekeeper(accountManager: subscriptionManager.accountManager)).applicationDidFinishLaunching()
#endif

setUpAutoClearHandler()

Expand Down Expand Up @@ -429,11 +419,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

NetworkProtectionAppEvents(featureGatekeeper: DefaultVPNFeatureGatekeeper(subscriptionManager: subscriptionManager)).applicationDidBecomeActive()

#if DBP
DataBrokerProtectionAppEvents(featureGatekeeper:
DefaultDataBrokerProtectionFeatureGatekeeper(accountManager:
subscriptionManager.accountManager)).applicationDidBecomeActive()
#endif

subscriptionManager.refreshCachedSubscriptionAndEntitlements { isSubscriptionActive in
if isSubscriptionActive {
Expand Down
46 changes: 6 additions & 40 deletions DuckDuckGo/Application/URLEventHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import PixelKit
import Subscription
import NetworkProtectionUI
import VPNAppLauncher

#if DBP
import DataBrokerProtection
#endif

// @MainActor
final class URLEventHandler {

@MainActor
private static let vpnURLEventHandler = VPNURLEventHandler()

private let handler: (URL) -> Void

private var didFinishLaunching = false
Expand Down Expand Up @@ -109,14 +109,14 @@ final class URLEventHandler {

private static func openURL(_ url: URL) {
if url.scheme?.isNetworkProtectionScheme == true {
handleNetworkProtectionURL(url)
Task { @MainActor in
await vpnURLEventHandler.handle(url)
}
}

#if DBP
if url.scheme?.isDataBrokerProtectionScheme == true {
handleDataBrokerProtectionURL(url)
}
#endif

DispatchQueue.main.async {
if url.isFileURL && url.pathExtension == WebKitDownloadTask.downloadExtension {
Expand All @@ -141,39 +141,6 @@ final class URLEventHandler {
}
}

/// Handles NetP URLs
private static func handleNetworkProtectionURL(_ url: URL) {
DispatchQueue.main.async {
switch url {
case VPNAppLaunchCommand.showStatus.launchURL:
Task {
await WindowControllersManager.shared.showNetworkProtectionStatus()
}
case VPNAppLaunchCommand.showSettings.launchURL:
WindowControllersManager.shared.showPreferencesTab(withSelectedPane: .vpn)
case VPNAppLaunchCommand.shareFeedback.launchURL:
WindowControllersManager.shared.showShareFeedbackModal()
case VPNAppLaunchCommand.justOpen.launchURL:
WindowControllersManager.shared.showMainWindow()
case VPNAppLaunchCommand.showVPNLocations.launchURL:
WindowControllersManager.shared.showPreferencesTab(withSelectedPane: .vpn)
WindowControllersManager.shared.showLocationPickerSheet()
case VPNAppLaunchCommand.showPrivacyPro.launchURL:
let url = Application.appDelegate.subscriptionManager.url(for: .purchase)
WindowControllersManager.shared.showTab(with: .subscription(url))
PixelKit.fire(PrivacyProPixel.privacyProOfferScreenImpression)
#if !APPSTORE && !DEBUG
case VPNAppLaunchCommand.moveAppToApplications.launchURL:
// this should be run after NSApplication.shared is set
PFMoveToApplicationsFolderIfNecessary(false)
#endif
default:
return
}
}
}

#if DBP
/// Handles DBP URLs
///
private static func handleDataBrokerProtectionURL(_ url: URL) {
Expand All @@ -187,7 +154,6 @@ final class URLEventHandler {
return
}
}
#endif
}

private extension String {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Document-Color-16.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "WarningYoutube.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class LegacyBookmarksStoreMigration {
_ = LegacyBookmarkStore(context: source)

// Prepare destination
BookmarkUtils.prepareLegacyFoldersStructure(in: destination)
try? BookmarkUtils.prepareLegacyFoldersStructure(in: destination)

guard let newRoot = BookmarkUtils.fetchRootFolder(destination),
let newFavoritesRoot = BookmarkUtils.fetchLegacyFavoritesFolder(destination) else {
Expand Down Expand Up @@ -163,7 +163,7 @@ public class LegacyBookmarksStoreMigration {
} catch {
destination.reset()

BookmarkUtils.prepareLegacyFoldersStructure(in: destination)
try? BookmarkUtils.prepareLegacyFoldersStructure(in: destination)
do {
try destination.save(onErrorFire: GeneralPixel.bookmarksMigrationCouldNotPrepareDatabaseOnFailedMigration)
} catch {
Expand Down
4 changes: 0 additions & 4 deletions DuckDuckGo/Common/Extensions/BundleExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ extension Bundle {

static let ipcAppGroup = "IPC_APP_GROUP"

#if DBP
static let dbpBackgroundAgentBundleId = "DBP_BACKGROUND_AGENT_BUNDLE_ID"
static let dbpBackgroundAgentProductName = "DBP_BACKGROUND_AGENT_PRODUCT_NAME"
#endif
}

var buildNumber: String {
Expand Down Expand Up @@ -87,7 +85,6 @@ extension Bundle {
}
#endif

#if DBP
var dbpBackgroundAgentBundleId: String {
guard let bundleID = object(forInfoDictionaryKey: Keys.dbpBackgroundAgentBundleId) as? String else {
fatalError("Info.plist is missing \(Keys.dbpBackgroundAgentBundleId)")
Expand All @@ -101,7 +98,6 @@ extension Bundle {
}
return loginItemsURL.appendingPathComponent(productName + ".app")
}
#endif

func appGroup(bundle: BundleGroup) -> String {
let appGroupName = bundle.appGroupKey
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/Common/Extensions/URLExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import Foundation

extension URL.NavigationalScheme {

static let duck = URL.NavigationalScheme(rawValue: "duck")
static let javascript = URL.NavigationalScheme(rawValue: "javascript")

static var validSchemes: [URL.NavigationalScheme] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import BrowserServicesKit
import Combine
import Common
import WebKit
import UserScript

extension WKWebViewConfiguration {

@MainActor
func applyStandardConfiguration(contentBlocking: some ContentBlockingProtocol, burnerMode: BurnerMode) {
func applyStandardConfiguration(contentBlocking: some ContentBlockingProtocol, burnerMode: BurnerMode, earlyAccessHandlers: [UserScript] = []) {
if case .burner(let websiteDataStore) = burnerMode {
self.websiteDataStore = websiteDataStore
// Fire Window: disable audio/video item info reporting to macOS Control Center / Lock Screen
Expand Down Expand Up @@ -53,7 +54,8 @@ extension WKWebViewConfiguration {
}

let userContentController = UserContentController(assetsPublisher: contentBlocking.contentBlockingAssetsPublisher,
privacyConfigurationManager: contentBlocking.privacyConfigurationManager)
privacyConfigurationManager: contentBlocking.privacyConfigurationManager,
earlyAccessHandlers: earlyAccessHandlers)

self.userContentController = userContentController
self.processPool.geolocationProvider = GeolocationProvider(processPool: self.processPool)
Expand Down
Loading

0 comments on commit 4c7e831

Please sign in to comment.