Skip to content

Commit

Permalink
Merge branch 'main' into sabrina/onboarding-import-state
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaTardio committed Nov 4, 2024
2 parents 0c77896 + 9184e92 commit 86f0411
Show file tree
Hide file tree
Showing 95 changed files with 2,196 additions and 822 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
36 changes: 22 additions & 14 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"branch" : "sabrina/onboarding-import-state",
"revision" : "05ea8316abb7cf3ba312b749b09ea2a437aa188a"
"revision" : "3aa45c028914206c3ecc24fcd51d365af32ca8fa"
}
},
{
Expand All @@ -42,7 +42,7 @@
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"branch" : "pr-releases/pr-1180",
"revision" : "551d15fcadecd1e8cddd0dca625358e8bf1fb3fa"
"revision" : "82be5d3ada8ff7743b08e5139c9e9ba83d66841c"
}
},
{
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
38 changes: 35 additions & 3 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ 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?

// MARK: - Freemium DBP
public let freemiumDBPFeature: FreemiumDBPFeature
Expand Down Expand Up @@ -325,6 +326,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
freemiumDBPFeature.subscribeToDependencyUpdates()
}

// swiftlint:disable:next cyclomatic_complexity
func applicationDidFinishLaunching(_ notification: Notification) {
guard NSApp.runType.requiresEnvironment else { return }
defer {
Expand Down Expand Up @@ -367,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 @@ -465,8 +491,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
guard didFinishLaunching else { return }

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

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

Expand All @@ -492,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
@@ -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 86f0411

Please sign in to comment.