Skip to content

Commit

Permalink
Merge latest main
Browse files Browse the repository at this point in the history
  • Loading branch information
aataraxiaa committed Feb 29, 2024
2 parents aac7d7c + abe67a7 commit c08178d
Show file tree
Hide file tree
Showing 96 changed files with 837 additions and 577 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 = 128
CURRENT_PROJECT_VERSION = 129
48 changes: 24 additions & 24 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3186,13 +3186,6 @@
remoteGlobalIDString = 3706FA6A293F65D500E42796;
remoteInfo = "DuckDuckGo Privacy Browser App Store";
};
4B1AD8A225FC27E200261379 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = AA585D76248FD31100E9A3E2 /* Project object */;
proxyType = 1;
remoteGlobalIDString = AA585D7D248FD31100E9A3E2;
remoteInfo = "DuckDuckGo Privacy Browser";
};
4BA7C4DE2B3F6F4900AFE511 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = AA585D76248FD31100E9A3E2 /* Project object */;
Expand Down Expand Up @@ -3228,19 +3221,26 @@
remoteGlobalIDString = 4B2537592A11BE7300610219;
remoteInfo = NetworkProtectionSystemExtension;
};
AA585D91248FD31400E9A3E2 /* PBXContainerItemProxy */ = {
B696E8182B8619D6008368F0 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = AA585D76248FD31100E9A3E2 /* Project object */;
proxyType = 1;
remoteGlobalIDString = B6EC37E729B5DA2A001ACE79;
remoteInfo = "tests-server";
};
B6CAC23C2B8F0EC6006CD402 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = AA585D76248FD31100E9A3E2 /* Project object */;
proxyType = 1;
remoteGlobalIDString = AA585D7D248FD31100E9A3E2;
remoteInfo = DuckDuckGo;
remoteInfo = "DuckDuckGo Privacy Browser";
};
B696E8182B8619D6008368F0 /* PBXContainerItemProxy */ = {
B6CAC23E2B8F0ECA006CD402 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = AA585D76248FD31100E9A3E2 /* Project object */;
proxyType = 1;
remoteGlobalIDString = B6EC37E729B5DA2A001ACE79;
remoteInfo = "tests-server";
remoteGlobalIDString = AA585D7D248FD31100E9A3E2;
remoteInfo = "DuckDuckGo Privacy Browser";
};
B6EC37F129B5DA8F001ACE79 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
Expand Down Expand Up @@ -8487,9 +8487,9 @@
buildRules = (
);
dependencies = (
B6CAC23F2B8F0ECA006CD402 /* PBXTargetDependency */,
B69D06162A4C0ACD0032D14D /* PBXTargetDependency */,
B6EC37F229B5DA8F001ACE79 /* PBXTargetDependency */,
4B1AD8A325FC27E200261379 /* PBXTargetDependency */,
);
name = "Integration Tests";
packageProductDependencies = (
Expand Down Expand Up @@ -8863,8 +8863,8 @@
buildRules = (
);
dependencies = (
B6CAC23D2B8F0EC6006CD402 /* PBXTargetDependency */,
B69D06142A4C0AC50032D14D /* PBXTargetDependency */,
AA585D92248FD31400E9A3E2 /* PBXTargetDependency */,
);
name = "Unit Tests";
packageProductDependencies = (
Expand Down Expand Up @@ -12622,11 +12622,6 @@
target = 3706FA6A293F65D500E42796 /* DuckDuckGo Privacy Browser App Store */;
targetProxy = 376113D52B29CD6800E794BB /* PBXContainerItemProxy */;
};
4B1AD8A325FC27E200261379 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = AA585D7D248FD31100E9A3E2 /* DuckDuckGo Privacy Browser */;
targetProxy = 4B1AD8A225FC27E200261379 /* PBXContainerItemProxy */;
};
4B4BEC4A2A11B627001D9AC5 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = 4B4BEC492A11B627001D9AC5 /* NetworkProtection */;
Expand Down Expand Up @@ -12672,11 +12667,6 @@
target = 4B2537592A11BE7300610219 /* NetworkProtectionSystemExtension */;
targetProxy = 7BEC18302AD5DA3300D30536 /* PBXContainerItemProxy */;
};
AA585D92248FD31400E9A3E2 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = AA585D7D248FD31100E9A3E2 /* DuckDuckGo Privacy Browser */;
targetProxy = AA585D91248FD31400E9A3E2 /* PBXContainerItemProxy */;
};
B6080B9D2B20AF7700B418EF /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = B6F997BA2B8F353F00476735 /* SwiftLintPlugin */;
Expand Down Expand Up @@ -12730,6 +12720,16 @@
isa = PBXTargetDependency;
productRef = B6F997BA2B8F353F00476735 /* SwiftLintPlugin */;
};
B6CAC23D2B8F0EC6006CD402 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = AA585D7D248FD31100E9A3E2 /* DuckDuckGo Privacy Browser */;
targetProxy = B6CAC23C2B8F0EC6006CD402 /* PBXContainerItemProxy */;
};
B6CAC23F2B8F0ECA006CD402 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = AA585D7D248FD31100E9A3E2 /* DuckDuckGo Privacy Browser */;
targetProxy = B6CAC23E2B8F0ECA006CD402 /* PBXContainerItemProxy */;
};
B6EC37F229B5DA8F001ACE79 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = B6EC37E729B5DA2A001ACE79 /* tests-server */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,9 @@
<Test
Identifier = "CoreDataEncryptionTests/testSavingIncorrectValueTypes()">
</Test>
<Test
Identifier = "DownloadsIntegrationTests/testWhenNavigationActionIsData_downloadStarts()">
</Test>
<Test
Identifier = "EncryptionKeyStoreTests">
</Test>
<Test
Identifier = "ErrorPageTests/testWhenGoingBackToFailingPage_reloadIsTriggered()">
</Test>
<Test
Identifier = "ErrorPageTests/testWhenTabWithNoConnectionErrorActivated_reloadTriggered()">
</Test>
<Test
Identifier = "HTTPSUpgradeIntegrationTests">
</Test>
Expand All @@ -165,9 +156,6 @@
<Test
Identifier = "NavigationProtectionIntegrationTests/testReferrerTrimming()">
</Test>
<Test
Identifier = "SearchNonexistentDomainTests/testWhenNonexistentDomainSuggestionChosen_redirectedToSERP()">
</Test>
</SkippedTests>
</TestableReference>
<TestableReference
Expand Down
24 changes: 16 additions & 8 deletions DuckDuckGo/Common/Database/Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,23 @@ final class Database {
}())
#endif

let keyStore: EncryptionKeyStoring
let containerLocation: URL
#if CI
keyStore = (NSClassFromString("MockEncryptionKeyStore") as? EncryptionKeyStoring.Type)!.init()
containerLocation = FileManager.default.temporaryDirectory
#else
keyStore = EncryptionKeyStore(generator: EncryptionKeyGenerator())
containerLocation = URL.sandboxApplicationSupportURL
let keyStore: EncryptionKeyStoring = {
#if DEBUG
guard case .normal = NSApp.runType else {
return (NSClassFromString("MockEncryptionKeyStore") as? EncryptionKeyStoring.Type)!.init()
}
#endif
return EncryptionKeyStore(generator: EncryptionKeyGenerator())
}()

let containerLocation: URL = {
#if DEBUG
guard case .normal = NSApp.runType else {
return FileManager.default.temporaryDirectory
}
#endif
return .sandboxApplicationSupportURL
}()

return makeDatabase(keyStore: keyStore, containerLocation: containerLocation)
}
Expand Down
7 changes: 7 additions & 0 deletions DuckDuckGo/Common/Extensions/NavigationActionExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ extension NavigationAction {
return false
}

var isCustom: Bool {
if case .custom = self.navigationType {
return true
}
return false
}

}

extension CustomNavigationType {
Expand Down
3 changes: 2 additions & 1 deletion DuckDuckGo/Common/Extensions/URLExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
// limitations under the License.
//

import AppKit
import BrowserServicesKit
import Common
import Foundation
import BrowserServicesKit

extension URL.NavigationalScheme {

Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Common/Extensions/URLRequestExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension URLRequest {
request.setValue(userAgent, forHTTPHeaderField: HeaderKey.userAgent.rawValue)

let languages = Locale.preferredLanguages.prefix(6)
let acceptLanguage = languages.enumerated().map { index, language in
let acceptLanguage: String = languages.enumerated().map { index, language in
let q = 1.0 - (Double(index) * 0.1)
return "\(language);q=\(q)"
}.joined(separator: ", ")
Expand Down
8 changes: 7 additions & 1 deletion DuckDuckGo/Common/View/AppKit/LoadingProgressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ final class LoadingProgressView: NSView, CAAnimationDelegate {
&& progressMask.animation(forKey: Constants.fadeOutAnimationKey) == nil
else { return }

self.lastEvent = ProgressEvent(progress: Constants.max, interval: Constants.hideAnimationDuration)
increaseProgress(to: Constants.max, animationDuration: Constants.hideAnimationDuration)
}

Expand Down Expand Up @@ -302,7 +303,12 @@ extension LoadingProgressView {

for (idx, step) in milestones.enumerated() {
if let event = lastProgressEvent {
if event.progress >= step.progress {
if event.progress == Constants.max {
// 100%: finish fast
nextStepIdx = milestones.indices.last!
estimatedElapsedTime = TimeInterval.greatestFiniteMagnitude
break
} else if event.progress >= step.progress {
estimatedElapsedTime += step.interval
} else {
// take percentage of estimated time for the current step based of (actual / estimated) progress difference
Expand Down
9 changes: 4 additions & 5 deletions DuckDuckGo/MainWindow/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ final class MainViewController: NSViewController {
super.viewDidAppear()
mainView.setMouseAboveWebViewTrackingAreaEnabled(true)
registerForBookmarkBarPromptNotifications()
adjustFirstResponder()
adjustFirstResponder(force: true)
}

var bookmarkBarPromptObserver: Any?
Expand Down Expand Up @@ -417,9 +417,8 @@ final class MainViewController: NSViewController {

// MARK: - First responder

func adjustFirstResponder(selectedTabViewModel: TabViewModel? = nil, tabContent: Tab.TabContent? = nil) {
func adjustFirstResponder(selectedTabViewModel: TabViewModel? = nil, tabContent: Tab.TabContent? = nil, force: Bool = false) {
guard let selectedTabViewModel = selectedTabViewModel ?? tabCollectionViewModel.selectedTabViewModel else {
assertionFailure("No tab view model selected")
return
}
let tabContent = tabContent ?? selectedTabViewModel.tab.content
Expand All @@ -430,8 +429,8 @@ final class MainViewController: NSViewController {
} else {
// ignore published tab switch: BrowserTabViewController
// adjusts first responder itself
guard selectedTabViewModel === tabCollectionViewModel.selectedTabViewModel else { return }
browserTabViewController.adjustFirstResponder(tabContent: tabContent)
guard selectedTabViewModel === tabCollectionViewModel.selectedTabViewModel || force else { return }
browserTabViewController.adjustFirstResponder(force: force, tabContent: tabContent)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ final class AddressBarViewController: NSViewController {
self.updateMode()
self.addressBarButtonsViewController?.updateButtons()

guard let window = view.window else { return }
guard let window = view.window, NSApp.runType != .unitTests else { return }

NSAppearance.withAppAppearance {
if window.isKeyWindow {
Expand Down
10 changes: 9 additions & 1 deletion DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class MoreOptionsMenu: NSMenu {
private let emailManager: EmailManager
private let passwordManagerCoordinator: PasswordManagerCoordinating
private let internalUserDecider: InternalUserDecider
private lazy var sharingMenu = SharingMenu(title: UserText.shareMenuItem)
private lazy var sharingMenu: NSMenu = SharingMenu(title: UserText.shareMenuItem)

#if NETWORK_PROTECTION
private let networkProtectionFeatureVisibility: NetworkProtectionFeatureVisibility
Expand All @@ -76,6 +76,7 @@ final class MoreOptionsMenu: NSMenu {
emailManager: EmailManager = EmailManager(),
passwordManagerCoordinator: PasswordManagerCoordinator,
networkProtectionFeatureVisibility: NetworkProtectionFeatureVisibility = DefaultNetworkProtectionVisibility(),
sharingMenu: NSMenu? = nil,
internalUserDecider: InternalUserDecider) {

self.tabCollectionViewModel = tabCollectionViewModel
Expand All @@ -86,6 +87,9 @@ final class MoreOptionsMenu: NSMenu {

super.init(title: "")

if let sharingMenu {
self.sharingMenu = sharingMenu
}
self.emailManager.requestDelegate = self

setupMenuItems()
Expand All @@ -94,6 +98,7 @@ final class MoreOptionsMenu: NSMenu {
init(tabCollectionViewModel: TabCollectionViewModel,
emailManager: EmailManager = EmailManager(),
passwordManagerCoordinator: PasswordManagerCoordinator,
sharingMenu: NSMenu? = nil,
internalUserDecider: InternalUserDecider) {

self.tabCollectionViewModel = tabCollectionViewModel
Expand All @@ -103,6 +108,9 @@ final class MoreOptionsMenu: NSMenu {

super.init(title: "")

if let sharingMenu {
self.sharingMenu = sharingMenu
}
self.emailManager.requestDelegate = self

setupMenuItems()
Expand Down
3 changes: 3 additions & 0 deletions DuckDuckGo/Preferences/View/FireproofDomains.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="removeAllDomains:" target="Clu-Bo-JRW" id="xPH-8I-h5n"/>
</connections>
</button>
<scrollView autohidesScrollers="YES" horizontalLineScroll="24" horizontalPageScroll="10" verticalLineScroll="24" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aPG-Pg-rGL">
<rect key="frame" x="20" y="60" width="435" height="195"/>
Expand Down
Loading

0 comments on commit c08178d

Please sign in to comment.