Skip to content

Commit

Permalink
Merge branch 'develop' into sam/vpn-waitlist
Browse files Browse the repository at this point in the history
# By Brad Slayter (1) and others
# Via Graeme Arthur (2) and others
* develop:
  Add NetP widget (#2142)
  Normalize ampUrl in breakage pixel (#2154)
  Bump submodules/privacy-reference-tests from `0d23f76` to `7519c3d` (#2135)
  Properly refresh home page favorites view when updating favorites display mode (#2148)

# Conflicts:
#	DuckDuckGo/AppDelegate.swift
  • Loading branch information
samsymons committed Nov 14, 2023
2 parents 0eeef8b + 7243cb6 commit ed22279
Show file tree
Hide file tree
Showing 23 changed files with 620 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ jobs:
restore-keys: |
${{ runner.os }}-spm-
# Using Xcode 15 as the alpha build uses iOS 17 APIs
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_$(<.xcode-version).app/Contents/Developer
run: sudo xcode-select -s /Applications/Xcode_15.0.1.app/Contents/Developer

- name: Prepare fastlane
run: bundle install
Expand Down
2 changes: 2 additions & 0 deletions Core/AppDeepLinkSchemes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public enum AppDeepLinkSchemes: String, CaseIterable {

case addFavorite = "ddgAddFavorite"

case openVPN = "ddgOpenVPN"

public var url: URL {
URL(string: rawValue + "://")!
}
Expand Down
6 changes: 6 additions & 0 deletions Core/UserDefaults+NetworkProtection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ public extension UserDefaults {
}
}

public enum NetworkProtectionUserDefaultKeys {

public static let lastSelectedServer = "com.duckduckgo.network-protection.last-selected-server"

}

#endif
42 changes: 41 additions & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
37FCAAC029930E26000E420A /* FailedAssertionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37FCAABF29930E26000E420A /* FailedAssertionView.swift */; };
37FD780F2A29E28B00B36DB1 /* SyncErrorHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37FD780E2A29E28B00B36DB1 /* SyncErrorHandler.swift */; };
4B0295192537BC6700E00CEF /* ConfigurationDebugViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B0295182537BC6700E00CEF /* ConfigurationDebugViewController.swift */; };
4B274F602AFEAECC003F0745 /* NetworkProtectionWidgetRefreshModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B274F5F2AFEAECC003F0745 /* NetworkProtectionWidgetRefreshModel.swift */; };
4B2754EC29E8C7DF00394032 /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 4B2754EB29E8C7DF00394032 /* Lottie */; };
4B470ED6299C49800086EBDC /* AppTrackingProtectionDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B470ED5299C49800086EBDC /* AppTrackingProtectionDatabase.swift */; };
4B470ED9299C4AED0086EBDC /* AppTrackingProtectionModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 4B470ED7299C4AED0086EBDC /* AppTrackingProtectionModel.xcdatamodeld */; };
Expand All @@ -275,6 +276,8 @@
4B470EE4299C6DFB0086EBDC /* Core.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F143C2E41E4A4CD400CFDE3A /* Core.framework */; };
4B52648B25F9613B00CB4C24 /* trackerData.json in Resources */ = {isa = PBXBuildFile; fileRef = 4B52648A25F9613B00CB4C24 /* trackerData.json */; };
4B53648A26718D0E001AA041 /* EmailWaitlist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B53648926718D0E001AA041 /* EmailWaitlist.swift */; };
4B5C462A2AF2A6E6002A4432 /* VPNIntents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B5C46292AF2A6E6002A4432 /* VPNIntents.swift */; };
4B5C462B2AF2BDC4002A4432 /* VPNIntents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B5C46292AF2A6E6002A4432 /* VPNIntents.swift */; };
4B60AC97252EC07B00E8D219 /* fullscreenvideo.js in Resources */ = {isa = PBXBuildFile; fileRef = 4B60AC96252EC07B00E8D219 /* fullscreenvideo.js */; };
4B60ACA1252EC0B100E8D219 /* FullScreenVideoUserScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B60ACA0252EC0B100E8D219 /* FullScreenVideoUserScript.swift */; };
4B62C4BA25B930DD008912C6 /* AppConfigurationFetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B62C4B925B930DD008912C6 /* AppConfigurationFetchTests.swift */; };
Expand All @@ -291,6 +294,8 @@
4B83397329AFB8D2003F7EA9 /* AppTrackingProtectionFeedbackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B83397229AFB8D2003F7EA9 /* AppTrackingProtectionFeedbackModel.swift */; };
4B83397529AFBCE6003F7EA9 /* AppTrackingProtectionFeedbackModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B83397429AFBCE6003F7EA9 /* AppTrackingProtectionFeedbackModelTests.swift */; };
4B948E2629DCCDB9002531FA /* Persistence in Frameworks */ = {isa = PBXBuildFile; productRef = 4B948E2529DCCDB9002531FA /* Persistence */; };
4BB7CBB02AF59C310014A35F /* VPNWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB7CBAF2AF59C310014A35F /* VPNWidget.swift */; };
4BBBBA872B02E85400D965DA /* DesignResourcesKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4BBBBA862B02E85400D965DA /* DesignResourcesKit */; };
4BC21A2F27238B7500229F0E /* RunLoopExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BC21A2C272388BD00229F0E /* RunLoopExtensionTests.swift */; };
4BC6DD1C2A60E6AD001EC129 /* ReportBrokenSiteView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BC6DD1B2A60E6AD001EC129 /* ReportBrokenSiteView.swift */; };
4BE2756827304F57006B20B0 /* URLRequestExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE27566272F878F006B20B0 /* URLRequestExtension.swift */; };
Expand Down Expand Up @@ -1282,13 +1287,15 @@
37FCAACB2993149A000E420A /* Waitlist */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Waitlist; sourceTree = "<group>"; };
37FD780E2A29E28B00B36DB1 /* SyncErrorHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncErrorHandler.swift; sourceTree = "<group>"; };
4B0295182537BC6700E00CEF /* ConfigurationDebugViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigurationDebugViewController.swift; sourceTree = "<group>"; };
4B274F5F2AFEAECC003F0745 /* NetworkProtectionWidgetRefreshModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionWidgetRefreshModel.swift; sourceTree = "<group>"; };
4B470ED5299C49800086EBDC /* AppTrackingProtectionDatabase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTrackingProtectionDatabase.swift; sourceTree = "<group>"; };
4B470ED8299C4AED0086EBDC /* AppTrackingProtectionModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = AppTrackingProtectionModel.xcdatamodel; sourceTree = "<group>"; };
4B470EDA299C4FB20086EBDC /* AppTrackingProtectionListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTrackingProtectionListViewModel.swift; sourceTree = "<group>"; };
4B470EDE299C67270086EBDC /* AppTrackerEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTrackerEntity.swift; sourceTree = "<group>"; };
4B470EE2299C6DD10086EBDC /* AppTrackingProtectionStoringModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTrackingProtectionStoringModel.swift; sourceTree = "<group>"; };
4B52648A25F9613B00CB4C24 /* trackerData.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = trackerData.json; sourceTree = "<group>"; };
4B53648926718D0E001AA041 /* EmailWaitlist.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailWaitlist.swift; sourceTree = "<group>"; };
4B5C46292AF2A6E6002A4432 /* VPNIntents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNIntents.swift; sourceTree = "<group>"; };
4B60AC96252EC07B00E8D219 /* fullscreenvideo.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = fullscreenvideo.js; sourceTree = "<group>"; };
4B60ACA0252EC0B100E8D219 /* FullScreenVideoUserScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FullScreenVideoUserScript.swift; sourceTree = "<group>"; };
4B62C4B925B930DD008912C6 /* AppConfigurationFetchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppConfigurationFetchTests.swift; sourceTree = "<group>"; };
Expand All @@ -1303,6 +1310,7 @@
4B83397029AC18C9003F7EA9 /* AppTrackingProtectionStoringModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTrackingProtectionStoringModelTests.swift; sourceTree = "<group>"; };
4B83397229AFB8D2003F7EA9 /* AppTrackingProtectionFeedbackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTrackingProtectionFeedbackModel.swift; sourceTree = "<group>"; };
4B83397429AFBCE6003F7EA9 /* AppTrackingProtectionFeedbackModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTrackingProtectionFeedbackModelTests.swift; sourceTree = "<group>"; };
4BB7CBAF2AF59C310014A35F /* VPNWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNWidget.swift; sourceTree = "<group>"; };
4BC21A2C272388BD00229F0E /* RunLoopExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunLoopExtensionTests.swift; sourceTree = "<group>"; };
4BC6DD1B2A60E6AD001EC129 /* ReportBrokenSiteView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReportBrokenSiteView.swift; sourceTree = "<group>"; };
4BE27566272F878F006B20B0 /* URLRequestExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = URLRequestExtension.swift; path = ../DuckDuckGo/URLRequestExtension.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2586,6 +2594,7 @@
8512EA5124ED30D20073EE19 /* SwiftUI.framework in Frameworks */,
85DF714624F7FE6100C89288 /* Core.framework in Frameworks */,
8512EA4F24ED30D20073EE19 /* WidgetKit.framework in Frameworks */,
4BBBBA872B02E85400D965DA /* DesignResourcesKit in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -3379,6 +3388,14 @@
name = WindowsBrowser;
sourceTree = "<group>";
};
4B274F5E2AFEAEB3003F0745 /* Widget */ = {
isa = PBXGroup;
children = (
4B274F5F2AFEAECC003F0745 /* NetworkProtectionWidgetRefreshModel.swift */,
);
name = Widget;
sourceTree = "<group>";
};
4B470ED4299C484B0086EBDC /* AppTrackingProtection */ = {
isa = PBXGroup;
children = (
Expand All @@ -3394,6 +3411,14 @@
name = AppTrackingProtection;
sourceTree = "<group>";
};
4B5C46282AF2A6DB002A4432 /* Intents */ = {
isa = PBXGroup;
children = (
4B5C46292AF2A6E6002A4432 /* VPNIntents.swift */,
);
name = Intents;
sourceTree = "<group>";
};
4B6484F427FD1E390050A7A1 /* Waitlist */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3701,6 +3726,7 @@
8512EA5324ED30D20073EE19 /* Widgets.swift */,
853273AF24FEFE4600E3C778 /* WidgetsExtension.entitlements */,
853273A924FEF24300E3C778 /* WidgetViews.swift */,
4BB7CBAF2AF59C310014A35F /* VPNWidget.swift */,
);
path = Widgets;
sourceTree = "<group>";
Expand Down Expand Up @@ -4496,6 +4522,8 @@
EE0153DF2A6EABAF002A8B26 /* Helpers */,
EEFD562D2A65B68B00DAEC48 /* Invite */,
EECD94B32A28B96C0085C66E /* Status */,
4B5C46282AF2A6DB002A4432 /* Intents */,
4B274F5E2AFEAEB3003F0745 /* Widget */,
EE8594982A44791C008A6D06 /* NetworkProtectionTunnelController.swift */,
);
name = NetworkProtection;
Expand Down Expand Up @@ -5417,6 +5445,9 @@
85DF714924F7FE6100C89288 /* PBXTargetDependency */,
);
name = WidgetsExtension;
packageProductDependencies = (
4BBBBA862B02E85400D965DA /* DesignResourcesKit */,
);
productName = WidgetsExtension;
productReference = 8512EA4D24ED30D20073EE19 /* WidgetsExtension.appex */;
productType = "com.apple.product-type.app-extension";
Expand Down Expand Up @@ -6379,6 +6410,7 @@
85C861E628FF1B5F00189466 /* HomeViewSectionRenderersExtension.swift in Sources */,
F1D477C61F2126CC0031ED49 /* OmniBarState.swift in Sources */,
85F2FFCD2211F615006BB258 /* MainViewController+KeyCommands.swift in Sources */,
4B274F602AFEAECC003F0745 /* NetworkProtectionWidgetRefreshModel.swift in Sources */,
0268FC132A449F04000EE6A2 /* OnboardingContainerView.swift in Sources */,
858650D9246B0D3C00C36F8A /* DaxOnboardingViewController.swift in Sources */,
312E5746283BB04A00C18FA0 /* AutofillEmptySearchView.swift in Sources */,
Expand Down Expand Up @@ -6437,6 +6469,7 @@
020108A729A6ABF600644F9D /* AppTPToggleView.swift in Sources */,
02A54A982A093126000C8FED /* AppTPHomeViewModel.swift in Sources */,
F1617C191E573EA800DEDCAF /* TabSwitcherDelegate.swift in Sources */,
4B5C462A2AF2A6E6002A4432 /* VPNIntents.swift in Sources */,
310742A62848CD780012660B /* BackForwardMenuHistoryItem.swift in Sources */,
858566FB252E55D6007501B8 /* ImageCacheDebugViewController.swift in Sources */,
0290472E29E99A2F0008FE3C /* GenericIconView.swift in Sources */,
Expand Down Expand Up @@ -6667,6 +6700,8 @@
853273B324FF114700E3C778 /* DeepLinks.swift in Sources */,
853273B424FFB36100E3C778 /* UIColorExtension.swift in Sources */,
853273AB24FEF27500E3C778 /* WidgetViews.swift in Sources */,
4B5C462B2AF2BDC4002A4432 /* VPNIntents.swift in Sources */,
4BB7CBB02AF59C310014A35F /* VPNWidget.swift in Sources */,
8512EA5424ED30D20073EE19 /* Widgets.swift in Sources */,
85DB12EB2A1FE2A4000A4A72 /* LockScreenWidgets.swift in Sources */,
8544C37C250B827300A0FE73 /* UserText.swift in Sources */,
Expand Down Expand Up @@ -8499,7 +8534,7 @@
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG NETWORK_PROTECTION";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG NETWORK_PROTECTION ALPHA";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
VALID_ARCHS = "$(ARCHS_STANDARD_64_BIT)";
Expand Down Expand Up @@ -9197,6 +9232,11 @@
package = 98A16C2928A11BDE00A6C003 /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = Persistence;
};
4BBBBA862B02E85400D965DA /* DesignResourcesKit */ = {
isa = XCSwiftPackageProductDependency;
package = F42D541B29DCA40B004C4FF1 /* XCRemoteSwiftPackageReference "DesignResourcesKit" */;
productName = DesignResourcesKit;
};
851481872A600EFC00ABC65F /* RemoteMessaging */ = {
isa = XCSwiftPackageProductDependency;
package = 98A16C2928A11BDE00A6C003 /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
Expand Down
6 changes: 6 additions & 0 deletions DuckDuckGo/AppDelegate+AppDeepLinks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Core

extension AppDelegate {

// swiftlint:disable:next cyclomatic_complexity
func handleAppDeepLink(_ app: UIApplication, _ mainViewController: MainViewController?, _ url: URL) -> Bool {
guard let mainViewController else { return false }

Expand Down Expand Up @@ -50,6 +51,11 @@ extension AppDelegate {
case .newEmail:
mainViewController.newEmailAddress()

case .openVPN:
#if NETWORK_PROTECTION
presentNetworkProtectionStatusSettingsModal()
#endif

default:
guard app.applicationState == .active,
let currentTab = mainViewController.currentTab else {
Expand Down
22 changes: 20 additions & 2 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
private var appTrackingProtectionDatabase: CoreDataDatabase = AppTrackingProtectionDatabase.make()
#endif

#if NETWORK_PROTECTION
private let widgetRefreshModel = NetworkProtectionWidgetRefreshModel()
#endif

private var autoClear: AutoClear?
private var showKeyboardIfSettingOn = true
private var lastBackgroundDate: Date?
Expand Down Expand Up @@ -278,6 +282,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
syncDataProviders: syncDataProviders,
appSettings: AppDependencyProvider.shared.appSettings)
#endif

main.loadViewIfNeeded()

window = UIWindow(frame: UIScreen.main.bounds)
Expand Down Expand Up @@ -318,6 +323,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
AppDependencyProvider.shared.appSettings.setAutofillIsNewInstallForOnByDefault()
}

#if NETWORK_PROTECTION
widgetRefreshModel.beginObservingVPNStatus()
#endif

return true
}

Expand Down Expand Up @@ -453,6 +462,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
syncService.scheduler.notifyAppLifecycleEvent()
fireFailedCompilationsPixelIfNeeded()
refreshShortcuts()

#if NETWORK_PROTECTION
widgetRefreshModel.refreshVPNWidget()
#endif
}

func applicationWillResignActive(_ application: UIApplication) {
Expand Down Expand Up @@ -608,7 +621,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

NotificationCenter.default.post(name: AutofillLoginListAuthenticator.Notifications.invalidateContext, object: nil)
mainViewController?.clearNavigationStack()

// The openVPN action handles the navigation stack on its own and does not need it to be cleared
if url != AppDeepLinkSchemes.openVPN.url {
mainViewController?.clearNavigationStack()
}

autoClear?.applicationWillMoveToForeground()
showKeyboardIfSettingOn = false

Expand Down Expand Up @@ -867,7 +885,7 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
}
}

private func presentNetworkProtectionStatusSettingsModal() {
func presentNetworkProtectionStatusSettingsModal() {
if #available(iOS 15, *) {
let networkProtectionRoot = NetworkProtectionRootViewController()
presentSettings(with: networkProtectionRoot)
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/BrokenSiteInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public struct BrokenSiteInfo {
Keys.manufacturer: manufacturer,
Keys.model: model,
Keys.gpc: gpc ? "true" : "false",
Keys.ampUrl: ampUrl ?? "",
Keys.ampUrl: normalize(URL(string: ampUrl ?? "")),
Keys.urlParametersRemoved: urlParametersRemoved ? "true" : "false",
Keys.protectionsState: protectionsState ? "true" : "false"
]
Expand Down
Loading

0 comments on commit ed22279

Please sign in to comment.