Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBP: macOS - Scheduler Progress Notifications #2023

Merged
merged 25 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Configuration/App/DBP/DuckDuckGoDBPAgent.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#include "../../DeveloperID.xcconfig"

// Override AppTargetsBase.xcconfig until we resolve bundle IDs.
PRODUCT_BUNDLE_IDENTIFIER[sdk=*] = $(DBP_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[config=Debug][sdk=*] = $(DBP_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[config=CI][sdk=*] = $(DBP_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[config=Review][sdk=*] = $(DBP_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[sdk=*] = $(DBP_BACKGROUND_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[config=Debug][sdk=*] = $(DBP_BACKGROUND_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[config=CI][sdk=*] = $(DBP_BACKGROUND_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[config=Review][sdk=*] = $(DBP_BACKGROUND_AGENT_BUNDLE_ID)

INFOPLIST_FILE = DuckDuckGoDBPBackgroundAgent/Info.plist
GENERATE_INFOPLIST_FILE = YES
Expand All @@ -40,7 +40,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*] =

PRODUCT_NAME = $(DBP_AGENT_PRODUCT_NAME)
PRODUCT_NAME = $(DBP_BACKGROUND_AGENT_PRODUCT_NAME)

PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*] =
PROVISIONING_PROFILE_SPECIFIER[config=Review][sdk=macosx*] = macOS DBP Agent - Review
Expand Down
10 changes: 5 additions & 5 deletions Configuration/App/DBP/DuckDuckGoDBPAgentAppStore.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#include "../../AppStore.xcconfig"

// Override AppTargetsBase.xcconfig until we resolve bundle IDs.
PRODUCT_BUNDLE_IDENTIFIER[sdk=*] = $(DBP_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[config=Debug][sdk=*] = $(DBP_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[config=CI][sdk=*] = $(DBP_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[config=Review][sdk=*] = $(DBP_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[sdk=*] = $(DBP_BACKGROUND_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[config=Debug][sdk=*] = $(DBP_BACKGROUND_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[config=CI][sdk=*] = $(DBP_BACKGROUND_AGENT_BUNDLE_ID)
PRODUCT_BUNDLE_IDENTIFIER[config=Review][sdk=*] = $(DBP_BACKGROUND_AGENT_BUNDLE_ID)

INFOPLIST_FILE = DuckDuckGoDBPBackgroundAgent/Info.plist
GENERATE_INFOPLIST_FILE = YES
Expand All @@ -40,7 +40,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*] =

PRODUCT_NAME = $(DBP_AGENT_PRODUCT_NAME)
PRODUCT_NAME = $(DBP_BACKGROUND_AGENT_PRODUCT_NAME)

PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*] =
PROVISIONING_PROFILE_SPECIFIER[config=Review][sdk=macosx*] = macOS DBP Agent - Review
Expand Down
14 changes: 4 additions & 10 deletions Configuration/DeveloperID.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ NOTIFICATIONS_AGENT_PRODUCT_NAME = DuckDuckGo Notifications

AGENT_BUNDLE_ID_BASE[sdk=*] = com.duckduckgo.macos.vpn

DBP_AGENT_BUNDLE_ID[sdk=*] = com.duckduckgo.macos.DBP.backgroundAgent
DBP_AGENT_BUNDLE_ID[config=Debug][sdk=*] = com.duckduckgo.macos.DBP.backgroundAgent.debug
DBP_AGENT_BUNDLE_ID[config=CI][sdk=*] = com.duckduckgo.macos.DBP.backgroundAgent.debug
DBP_AGENT_BUNDLE_ID[config=Review][sdk=*] = com.duckduckgo.macos.DBP.backgroundAgent.review
DBP_AGENT_PRODUCT_NAME = DuckDuckGoDBPBackgroundAgent

DBP_BASE_APP_GROUP = $(DEVELOPMENT_TEAM).com.duckduckgo.macos.browser.dbp
DBP_APP_GROUP[config=CI][sdk=*] = $(DBP_BASE_APP_GROUP).debug
DBP_APP_GROUP[config=Review][sdk=*] = $(DBP_BASE_APP_GROUP).review
Expand All @@ -78,8 +72,8 @@ AGENT_BUNDLE_ID[config=Review][sdk=*] = $(AGENT_BUNDLE_ID_BASE).review
AGENT_PRODUCT_NAME = DuckDuckGo VPN

DBP_BACKGROUND_AGENT_BUNDLE_ID[sdk=*] = com.duckduckgo.macos.DBP.backgroundAgent
DBP_BACKGROUND_AGENT_BUNDLE_ID[config=Debug][sdk=*] = com.duckduckgo.macos.DBP.backgroundAgent.debug
DBP_BACKGROUND_AGENT_BUNDLE_ID[config=CI][sdk=*] = com.duckduckgo.macos.DBP.backgroundAgent.debug
DBP_BACKGROUND_AGENT_BUNDLE_ID[config=Review][sdk=*] = com.duckduckgo.macos.DBP.backgroundAgent.review
DBP_BACKGROUND_AGENT_BUNDLE_ID[config=Debug][sdk=*] = $(DBP_BACKGROUND_AGENT_BUNDLE_ID).debug
DBP_BACKGROUND_AGENT_BUNDLE_ID[config=CI][sdk=*] = $(DBP_BACKGROUND_AGENT_BUNDLE_ID).debug
DBP_BACKGROUND_AGENT_BUNDLE_ID[config=Review][sdk=*] = $(DBP_BACKGROUND_AGENT_BUNDLE_ID).review

DBP_BACKGROUND_AGENT_PRODUCT_NAME = DuckDuckGoDBPBackgroundAgent
DBP_BACKGROUND_AGENT_PRODUCT_NAME = DuckDuckGo Personal Information Removal
14 changes: 7 additions & 7 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2219,8 +2219,8 @@
7BFE95562A9DF29B0081ABE9 /* UserDefaults+NetworkProtectionWaitlist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BFE95532A9DF2930081ABE9 /* UserDefaults+NetworkProtectionWaitlist.swift */; };
7BFE95592A9DF2AF0081ABE9 /* UserDefaults+NetworkProtectionWaitlist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BFE95532A9DF2930081ABE9 /* UserDefaults+NetworkProtectionWaitlist.swift */; };
7BFE955A2A9DF4550081ABE9 /* NetworkProtectionWaitlistFeatureFlagOverridesMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BFE95512A9DF1CE0081ABE9 /* NetworkProtectionWaitlistFeatureFlagOverridesMenu.swift */; };
7BFF850F2B0C09DA00ECACA2 /* DuckDuckGoDBPBackgroundAgent.app in Embed Login Items */ = {isa = PBXBuildFile; fileRef = 9D9AE8D12AAA39A70026E7DC /* DuckDuckGoDBPBackgroundAgent.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
7BFF85102B0C09E300ECACA2 /* DuckDuckGoDBPBackgroundAgent.app in Embed Login Items */ = {isa = PBXBuildFile; fileRef = 9D9AE8D12AAA39A70026E7DC /* DuckDuckGoDBPBackgroundAgent.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
7BFF850F2B0C09DA00ECACA2 /* DuckDuckGo Personal Information Removal.app in Embed Login Items */ = {isa = PBXBuildFile; fileRef = 9D9AE8D12AAA39A70026E7DC /* DuckDuckGo Personal Information Removal.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
7BFF85102B0C09E300ECACA2 /* DuckDuckGo Personal Information Removal.app in Embed Login Items */ = {isa = PBXBuildFile; fileRef = 9D9AE8D12AAA39A70026E7DC /* DuckDuckGo Personal Information Removal.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
85012B0229133F9F003D0DCC /* NavigationBarPopovers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85012B0129133F9F003D0DCC /* NavigationBarPopovers.swift */; };
850E8DFB2A6FEC5E00691187 /* BookmarksBarAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 850E8DFA2A6FEC5E00691187 /* BookmarksBarAppearance.swift */; };
8511E18425F82B34002F516B /* 01_Fire_really_small.json in Resources */ = {isa = PBXBuildFile; fileRef = 8511E18325F82B34002F516B /* 01_Fire_really_small.json */; };
Expand Down Expand Up @@ -3125,7 +3125,7 @@
dstPath = Contents/Library/LoginItems;
dstSubfolderSpec = 1;
files = (
7BFF850F2B0C09DA00ECACA2 /* DuckDuckGoDBPBackgroundAgent.app in Embed Login Items */,
7BFF850F2B0C09DA00ECACA2 /* DuckDuckGo Personal Information Removal.app in Embed Login Items */,
4B2D065F2A11D2D700DE1F49 /* DuckDuckGo VPN.app in Embed Login Items */,
4B2D065E2A11D2D700DE1F49 /* DuckDuckGo Notifications.app in Embed Login Items */,
);
Expand All @@ -3138,7 +3138,7 @@
dstPath = Contents/Library/LoginItems;
dstSubfolderSpec = 1;
files = (
7BFF85102B0C09E300ECACA2 /* DuckDuckGoDBPBackgroundAgent.app in Embed Login Items */,
7BFF85102B0C09E300ECACA2 /* DuckDuckGo Personal Information Removal.app in Embed Login Items */,
4B957C342AC7AE700062CA31 /* DuckDuckGo VPN.app in Embed Login Items */,
4B957C352AC7AE700062CA31 /* DuckDuckGo Notifications.app in Embed Login Items */,
);
Expand Down Expand Up @@ -3804,7 +3804,7 @@
9D8FA00B2AC5BDCE005DD0D0 /* LoginItem+DataBrokerProtection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "LoginItem+DataBrokerProtection.swift"; sourceTree = "<group>"; };
9D9AE8682AA76CDC0026E7DC /* LoginItem+NetworkProtection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "LoginItem+NetworkProtection.swift"; sourceTree = "<group>"; };
9D9AE86A2AA76CF90026E7DC /* LoginItemsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginItemsManager.swift; sourceTree = "<group>"; };
9D9AE8D12AAA39A70026E7DC /* DuckDuckGoDBPBackgroundAgent.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DuckDuckGoDBPBackgroundAgent.app; sourceTree = BUILT_PRODUCTS_DIR; };
9D9AE8D12AAA39A70026E7DC /* DuckDuckGo Personal Information Removal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DuckDuckGo Personal Information Removal.app"; sourceTree = BUILT_PRODUCTS_DIR; };
9D9AE8F22AAA39D30026E7DC /* .app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = .app; sourceTree = BUILT_PRODUCTS_DIR; };
9D9AE9142AAA3B450026E7DC /* Info-AppStore.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-AppStore.plist"; sourceTree = "<group>"; };
9D9AE9152AAA3B450026E7DC /* DuckDuckGoDBPBackgroundAgentAppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DuckDuckGoDBPBackgroundAgentAppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6496,7 +6496,7 @@
4B25375A2A11BE7300610219 /* com.duckduckgo.macos.vpn.network-extension.debug.systemextension */,
4B2D06392A11CFBB00DE1F49 /* DuckDuckGo VPN.app */,
4B2D06692A13318400DE1F49 /* DuckDuckGo VPN App Store.app */,
9D9AE8D12AAA39A70026E7DC /* DuckDuckGoDBPBackgroundAgent.app */,
9D9AE8D12AAA39A70026E7DC /* DuckDuckGo Personal Information Removal.app */,
9D9AE8F22AAA39D30026E7DC /* .app */,
4B957C412AC7AE700062CA31 /* DuckDuckGo Privacy Pro.app */,
565E46DD2B2725DC0013AC2A /* SyncE2EUITests.xctest */,
Expand Down Expand Up @@ -8408,7 +8408,7 @@
9DEF97E02B06C4EE00764F03 /* Networking */,
);
productName = DuckDuckGoAgent;
productReference = 9D9AE8D12AAA39A70026E7DC /* DuckDuckGoDBPBackgroundAgent.app */;
productReference = 9D9AE8D12AAA39A70026E7DC /* DuckDuckGo Personal Information Removal.app */;
productType = "com.apple.product-type.application";
};
9D9AE8D32AAA39D30026E7DC /* DuckDuckGoDBPBackgroundAgentAppStore */ = {
Expand Down
47 changes: 44 additions & 3 deletions DuckDuckGo/Application/URLEventHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import Foundation
import NetworkProtection
#endif

#if DBP
import DataBrokerProtection
#endif

@MainActor
final class URLEventHandler {

Expand Down Expand Up @@ -100,9 +104,19 @@ final class URLEventHandler {

private static func openURL(_ url: URL) {
#if NETWORK_PROTECTION
if url.scheme == "networkprotection" {
if url.scheme?.isNetworkProtectionScheme == true {
handleNetworkProtectionURL(url)
} else {
}
#endif

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

#if NETWORK_PROTECTION || DBP
if url.scheme?.isNetworkProtectionScheme == false && url.scheme?.isDataBrokerProtectionScheme == false {
WaitlistModalDismisser.dismissWaitlistModalViewControllerIfNecessary(url)
WindowControllersManager.shared.show(url: url, source: .appOpenUrl, newTab: true)
}
Expand All @@ -111,7 +125,7 @@ final class URLEventHandler {
#endif
}

#if NETWORK_PROTECTION
#if NETWORK_PROTECTION || DBP

/// Handles NetP URLs
///
Expand All @@ -132,4 +146,31 @@ final class URLEventHandler {

#endif

#if DBP
/// Handles DBP URLs
///
private static func handleDataBrokerProtectionURL(_ url: URL) {
switch url {
case DataBrokerProtectionNotificationCommand.showDashboard.url:
WindowControllersManager.shared.showTab(with: .dataBrokerProtection)
Bunn marked this conversation as resolved.
Show resolved Hide resolved
default:
return
}
}

#endif

}

private extension String {
static let dataBrokerProtectionScheme = "databrokerprotection"
static let networkProtectionScheme = "networkprotection"

var isDataBrokerProtectionScheme: Bool {
return self == String.dataBrokerProtectionScheme
}

var isNetworkProtectionScheme: Bool {
return self == String.networkProtectionScheme
}
}
11 changes: 10 additions & 1 deletion DuckDuckGo/DBP/DBPHomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ extension DBPHomeViewController: DataBrokerProtectionInviteDialogsViewModelDeleg

public class DataBrokerProtectionPixelsHandler: EventMapping<DataBrokerProtectionPixels> {

// swiftlint:disable:next function_body_length
public init() {
super.init { event, _, _, _ in
switch event {
Expand Down Expand Up @@ -175,7 +176,15 @@ public class DataBrokerProtectionPixelsHandler: EventMapping<DataBrokerProtectio
.resetLoginItem,
.scanSuccess,
.scanFailed,
.scanError:
.scanError,
.dataBrokerProtectionNotificationSentFirstScanComplete,
.dataBrokerProtectionNotificationOpenedFirstScanComplete,
.dataBrokerProtectionNotificationSentFirstRemoval,
.dataBrokerProtectionNotificationOpenedFirstRemoval,
.dataBrokerProtectionNotificationScheduled2WeeksCheckIn,
.dataBrokerProtectionNotificationOpened2WeeksCheckIn,
.dataBrokerProtectionNotificationSentAllRecordsRemoved,
.dataBrokerProtectionNotificationOpenedAllRecordsRemoved:
Pixel.fire(.pixelKitEvent(event))
}
}
Expand Down
5 changes: 4 additions & 1 deletion DuckDuckGo/DBP/DataBrokerProtectionAppEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ struct DataBrokerProtectionAppEvents {

private func restartBackgroundAgent(loginItemsManager: LoginItemsManager) {
pixelHandler.fire(.resetLoginItem)
loginItemsManager.restartLoginItems([LoginItem.dbpBackgroundAgent], log: .dbp)
loginItemsManager.disableLoginItems([LoginItem.dbpBackgroundAgent])
loginItemsManager.enableLoginItems([LoginItem.dbpBackgroundAgent], log: .dbp)

// restartLoginItems doesn't work when we change the agent name
Bunn marked this conversation as resolved.
Show resolved Hide resolved
}
}
10 changes: 10 additions & 0 deletions DuckDuckGo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@
<string>networkprotection</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>DataBroker Protection URLs</string>
<key>CFBundleURLSchemes</key>
<array>
<string>databrokerprotection</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,17 @@ public final class DataBrokerProtectionBackgroundManager {
sessionKey: sessionKey,
featureToggles: features)

let pixelHandler = DataBrokerProtectionPixelsHandler()

let userNotificationService = DefaultDataBrokerProtectionUserNotificationService(pixelHandler: pixelHandler)

return DefaultDataBrokerProtectionScheduler(privacyConfigManager: privacyConfigurationManager,
contentScopeProperties: prefs,
dataManager: dataManager,
notificationCenter: NotificationCenter.default,
pixelHandler: DataBrokerProtectionPixelsHandler(),
redeemUseCase: redeemUseCase)
contentScopeProperties: prefs,
dataManager: dataManager,
notificationCenter: NotificationCenter.default,
pixelHandler: pixelHandler,
redeemUseCase: redeemUseCase,
userNotificationService: userNotificationService)
}()

private init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let nonSandboxedExtraInputFiles: Set<InputFile> = [
.init("VPNMetadataCollector.swift", .source),
.init("VPNFeedbackCategory.swift", .source),
.init("VPNFeedbackSender.swift", .source),
.init("DuckDuckGoDBPBackgroundAgent.app", .unknown),
.init("DuckDuckGo Personal Information Removal.app", .unknown),
.init("DataBrokerProtectionSubscriptionEventHandler.swift", .source)
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ final class DataBrokerOperationsCollection: Operation {
private let runner: WebOperationRunner
private let pixelHandler: EventMapping<DataBrokerProtectionPixels>
private let showWebView: Bool
private let userNotificationService: DataBrokerProtectionUserNotificationService

deinit {
os_log("Deinit operation: %{public}@", log: .dataBrokerProtection, String(describing: id.uuidString))
Expand All @@ -52,6 +53,7 @@ final class DataBrokerOperationsCollection: Operation {
notificationCenter: NotificationCenter = NotificationCenter.default,
runner: WebOperationRunner,
pixelHandler: EventMapping<DataBrokerProtectionPixels>,
userNotificationService: DataBrokerProtectionUserNotificationService,
showWebView: Bool) {

self.brokerProfileQueriesData = brokerProfileQueriesData
Expand All @@ -63,6 +65,7 @@ final class DataBrokerOperationsCollection: Operation {
self.runner = runner
self.pixelHandler = pixelHandler
self.showWebView = showWebView
self.userNotificationService = userNotificationService
super.init()
}

Expand Down Expand Up @@ -145,6 +148,7 @@ final class DataBrokerOperationsCollection: Operation {
runner: runner,
pixelHandler: pixelHandler,
showWebView: showWebView,
userNotificationService: userNotificationService,
shouldRunNextStep: { [weak self] in
guard let self = self else { return false }
return !self.isCancelled
Expand Down
Loading
Loading