Skip to content

Commit

Permalink
Merge branch 'main' into bunn/aichat/branch-from-head-pop-icon
Browse files Browse the repository at this point in the history
# Conflicts:
#	DuckDuckGo/Localizable.xcstrings
  • Loading branch information
Bunn committed Nov 4, 2024
2 parents 1fca336 + cee0c62 commit 107464c
Show file tree
Hide file tree
Showing 219 changed files with 8,526 additions and 1,837 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 = 291
CURRENT_PROJECT_VERSION = 296
210 changes: 195 additions & 15 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "e5946eee6af859690cc1cc5e51daef3c8368981b",
"version" : "201.0.0"
"revision" : "19f1e5c945aa92562ad2d087e8d6c99801edf656",
"version" : "203.1.0"
}
},
{
"identity" : "content-scope-scripts",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "b74549bd869fdecc16fad851f2f608b1724764df",
"version" : "6.25.0"
"revision" : "48fee2508995d4ac02d18b3d55424adedcb4ce4f",
"version" : "6.28.0"
}
},
{
"identity" : "duckduckgo-autofill",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/duckduckgo-autofill.git",
"state" : {
"revision" : "945ac09a0189dc6736db617867fde193ea984b20",
"version" : "15.0.0"
"revision" : "c992041d16ec10d790e6204dce9abf9966d1363c",
"version" : "15.1.0"
}
},
{
Expand All @@ -75,7 +75,7 @@
{
"identity" : "lottie-spm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-spm",
"location" : "https://github.com/airbnb/lottie-spm.git",
"state" : {
"revision" : "1d29eccc24cc8b75bff9f6804155112c0ffc9605",
"version" : "4.4.3"
Expand Down Expand Up @@ -104,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/privacy-dashboard",
"state" : {
"revision" : "9de2b2aa317a48d3ee31116dc15b0feeb2cc9414",
"version" : "5.3.0"
"revision" : "53fd1a0f8d91fcf475d9220f810141007300dffd",
"version" : "7.1.1"
}
},
{
Expand Down Expand Up @@ -167,8 +167,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/sync_crypto",
"state" : {
"revision" : "2ab6ab6f0f96b259c14c2de3fc948935fc16ac78",
"version" : "0.2.0"
"revision" : "0c8bf3c0e75591bc366407b9d7a73a9fcfc7736f",
"version" : "0.3.0"
}
},
{
Expand Down
83 changes: 75 additions & 8 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import NetworkProtectionIPC
import DataBrokerProtection
import RemoteMessaging
import os.log
import Freemium

final class AppDelegate: NSObject, NSApplicationDelegate {

Expand Down Expand Up @@ -96,15 +97,21 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

public let subscriptionManager: SubscriptionManager
public let subscriptionUIHandler: SubscriptionUIHandling
public let subscriptionCookieManager: SubscriptionCookieManaging
private let subscriptionCookieManager: SubscriptionCookieManaging
private var subscriptionCookieManagerFeatureFlagCancellable: AnyCancellable?

public let vpnSettings = VPNSettings(defaults: .netP)
// MARK: - Freemium DBP
public let freemiumDBPFeature: FreemiumDBPFeature
public let freemiumDBPPromotionViewCoordinator: FreemiumDBPPromotionViewCoordinator
private var freemiumDBPScanResultPolling: FreemiumDBPScanResultPolling?

var configurationStore = ConfigurationStore()
var configurationManager: ConfigurationManager

// MARK: - VPN

public let vpnSettings = VPNSettings(defaults: .netP)

private var networkProtectionSubscriptionEventHandler: NetworkProtectionSubscriptionEventHandler?

private var vpnXPCClient: VPNControllerXPCClient {
Expand Down Expand Up @@ -276,6 +283,20 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

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

// Freemium DBP
let freemiumDBPUserStateManager = DefaultFreemiumDBPUserStateManager(userDefaults: .dbp)

let experimentManager = FreemiumDBPPixelExperimentManager(subscriptionManager: subscriptionManager)
experimentManager.assignUserToCohort()

freemiumDBPFeature = DefaultFreemiumDBPFeature(privacyConfigurationManager: ContentBlocking.shared.privacyConfigurationManager,
experimentManager: experimentManager,
subscriptionManager: subscriptionManager,
accountManager: subscriptionManager.accountManager,
freemiumDBPUserStateManager: freemiumDBPUserStateManager)
freemiumDBPPromotionViewCoordinator = FreemiumDBPPromotionViewCoordinator(freemiumDBPUserStateManager: freemiumDBPUserStateManager,
freemiumDBPFeature: freemiumDBPFeature)
}

func applicationWillFinishLaunching(_ notification: Notification) {
Expand All @@ -300,8 +321,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
networkProtectionSubscriptionEventHandler = NetworkProtectionSubscriptionEventHandler(subscriptionManager: subscriptionManager,
tunnelController: tunnelController,
vpnUninstaller: vpnUninstaller)

// Freemium DBP
freemiumDBPFeature.subscribeToDependencyUpdates()
}

// swiftlint:disable:next cyclomatic_complexity
func applicationDidFinishLaunching(_ notification: Notification) {
guard NSApp.runType.requiresEnvironment else { return }
defer {
Expand Down Expand Up @@ -344,6 +369,30 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

subscriptionManager.loadInitialData()

let privacyConfigurationManager = ContentBlocking.shared.privacyConfigurationManager

// Enable subscriptionCookieManager if feature flag is present
if privacyConfigurationManager.privacyConfig.isSubfeatureEnabled(PrivacyProSubfeature.setAccessTokenCookieForSubscriptionDomains) {
subscriptionCookieManager.enableSettingSubscriptionCookie()
}

// Keep track of feature flag changes
subscriptionCookieManagerFeatureFlagCancellable = privacyConfigurationManager.updatesPublisher
.sink { [weak self, weak privacyConfigurationManager] in
guard let self, let privacyConfigurationManager else { return }

let isEnabled = privacyConfigurationManager.privacyConfig.isSubfeatureEnabled(PrivacyProSubfeature.setAccessTokenCookieForSubscriptionDomains)

Task { [weak self] in
if isEnabled {
self?.subscriptionCookieManager.enableSettingSubscriptionCookie()
await self?.subscriptionCookieManager.refreshSubscriptionCookie()
} else {
await self?.subscriptionCookieManager.disableSettingSubscriptionCookie()
}
}
}

if [.normal, .uiTests].contains(NSApp.runType) {
stateRestorationManager.applicationDidFinishLaunching()
}
Expand Down Expand Up @@ -391,7 +440,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
UNUserNotificationCenter.current().delegate = self

dataBrokerProtectionSubscriptionEventHandler.registerForSubscriptionAccountManagerEvents()
DataBrokerProtectionAppEvents(featureGatekeeper: DefaultDataBrokerProtectionFeatureGatekeeper(accountManager: subscriptionManager.accountManager)).applicationDidFinishLaunching()

let freemiumDBPUserStateManager = DefaultFreemiumDBPUserStateManager(userDefaults: .dbp)
let pirGatekeeper = DefaultDataBrokerProtectionFeatureGatekeeper(accountManager:
subscriptionManager.accountManager,
freemiumDBPUserStateManager: freemiumDBPUserStateManager)

DataBrokerProtectionAppEvents(featureGatekeeper: pirGatekeeper).applicationDidFinishLaunching()

setUpAutoClearHandler()

Expand All @@ -413,6 +468,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
PixelKit.fire(GeneralPixel.crashOnCrashHandlersSetUp)
didCrashDuringCrashHandlersSetUp = false
}

freemiumDBPScanResultPolling = DefaultFreemiumDBPScanResultPolling(dataManager: DataBrokerProtectionManager.shared.dataManager, freemiumDBPUserStateManager: freemiumDBPUserStateManager)
freemiumDBPScanResultPolling?.startPollingOrObserving()
}

private func fireFailedCompilationsPixelIfNeeded() {
Expand All @@ -433,14 +491,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
guard didFinishLaunching else { return }

PixelExperiment.fireOnboardingTestPixels()
syncService?.initializeIfNeeded()
syncService?.scheduler.notifyAppLifecycleEvent()
initializeSync()

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

DataBrokerProtectionAppEvents(featureGatekeeper:
DefaultDataBrokerProtectionFeatureGatekeeper(accountManager:
subscriptionManager.accountManager)).applicationDidBecomeActive()
let freemiumDBPUserStateManager = DefaultFreemiumDBPUserStateManager(userDefaults: .dbp)
let pirGatekeeper = DefaultDataBrokerProtectionFeatureGatekeeper(accountManager:
subscriptionManager.accountManager,
freemiumDBPUserStateManager: freemiumDBPUserStateManager)

DataBrokerProtectionAppEvents(featureGatekeeper: pirGatekeeper).applicationDidBecomeActive()

subscriptionManager.refreshCachedSubscriptionAndEntitlements { isSubscriptionActive in
if isSubscriptionActive {
Expand All @@ -457,6 +517,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}
}

private func initializeSync() {
guard let syncService else { return }
syncService.initializeIfNeeded()
syncService.scheduler.notifyAppLifecycleEvent()
SyncDiagnosisHelper(syncService: syncService).diagnoseAccountStatus()
}

func applicationDidResignActive(_ notification: Notification) {
Task { @MainActor in
await vpnRedditSessionWorkaround.removeRedditSessionWorkaround()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions DuckDuckGo/Assets.xcassets/Images/Check.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Check-Color-16.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "Icon 22.pdf",
"filename" : "Exclamation-High-Color-16.svg",
"idiom" : "universal"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Radar-Check-96x96.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "Document-Color-16.pdf",
"filename" : "Release-Notes-Color-16.svg",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "Icon 19.pdf",
"filename" : "Exclamation-Color-16-2.svg",
"idiom" : "universal"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
6 changes: 6 additions & 0 deletions DuckDuckGo/Common/Extensions/NSViewExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ extension NSView {
set { isHidden = !newValue }
}

var isVisible: Bool {
guard !isHiddenOrHasHiddenAncestor,
let window, window.isVisible else { return false }
return true
}

func makeMeFirstResponder() {
guard let window = window else {
Logger.general.error("\(self.className): Window not available")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ extension NSPopover {
// https://app.asana.com/0/1201037661562251/1206407295280737/f
@objc(swizzled_showRelativeToRect:ofView:preferredEdge:)
private dynamic func swizzled_show(relativeTo positioningRect: NSRect, of positioningView: NSView, preferredEdge: NSRectEdge) {
if positioningView.superview == nil {
if positioningView.window == nil {
var observer: Cancellable?
observer = positioningView.observe(\.window) { positioningView, _ in
if positioningView.window != nil {
Expand Down
27 changes: 27 additions & 0 deletions DuckDuckGo/Common/Extensions/XMLNodeExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// XMLNodeExtension.swift
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

extension XMLNode {

func childIfExists(at index: Int) -> XMLNode? {
assert(index >= 0)
guard childCount > index else { return nil }
return child(at: index)
}

}
Loading

0 comments on commit 107464c

Please sign in to comment.