Skip to content

Commit

Permalink
Merge branch 'main' into sam/add-netp-subscription-auth-support
Browse files Browse the repository at this point in the history
# By Diego Rey Mendez (4) and others
# Via Fernando Bunn (2) and GitHub (1)
* main:
  Adds option + click support for our VPN menu to show some useful debu… (#2007)
  Update latency & tunnel failure monitor implementation (#2005)
  Prevents VPNSettings from reporting fake changes (#2004)
  Updates the copy for the VPN status bar item context menu (#2003)
  Implement subscription purchase (#1906)
  DBP: Add m_mac prefix to Pixels (#1952)
  Bump version to 1.69.0 (96)
  Update embedded files
  Update Link Tracking Protection to preserve headers (#1965)
  VPN menus improvements (#1979)
  Data Import ux redo (#1754)
  Fix: "SwiftLintPlugin" must be enabled before it can be used (#1987)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
#	DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift
  • Loading branch information
samsymons committed Dec 24, 2023
2 parents cb505ab + 6925a02 commit 52f025c
Show file tree
Hide file tree
Showing 231 changed files with 20,945 additions and 6,631 deletions.
3 changes: 2 additions & 1 deletion Configuration/App/DuckDuckGoPrivacyPro.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@

#include "DuckDuckGo.xcconfig"

FEATURE_FLAGS = FEEDBACK NETWORK_PROTECTION SPARKLE SUBSCRIPTION DBP
FEATURE_FLAGS = FEEDBACK NETWORK_PROTECTION SPARKLE SUBSCRIPTION DBP STRIPE
PRODUCT_NAME = $(PRODUCT_NAME_PREFIX) Privacy Pro
PRODUCT_MODULE_NAME = DuckDuckGo_Privacy_Browser
2 changes: 1 addition & 1 deletion Configuration/BuildNumber.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 95
CURRENT_PROJECT_VERSION = 96
7 changes: 7 additions & 0 deletions Configuration/Global.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,10 @@ DDG_SLOW_COMPILE_CHECK_THRESHOLD[config=CI] = 250
DDG_SLOW_COMPILE_CHECK = -Xfrontend -warn-long-expression-type-checking=$(DDG_SLOW_COMPILE_CHECK_THRESHOLD) -Xfrontend -warn-long-function-bodies=$(DDG_SLOW_COMPILE_CHECK_THRESHOLD)
OTHER_SWIFT_FLAGS[config=Debug][arch=*][sdk=*] = $(inherited) $(DDG_SLOW_COMPILE_CHECK)
OTHER_SWIFT_FLAGS[config=CI][arch=*][sdk=*] = $(inherited) $(DDG_SLOW_COMPILE_CHECK)

// Automatically generate Color and Image asset accessor extensions
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES

// Automatically generate localization string catalogs
LOCALIZATION_PREFERS_STRING_CATALOGS = YES
SWIFT_EMIT_LOC_STRINGS = YES
438 changes: 244 additions & 194 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"branch" : "sam/add-netp-subscription-auth-support",
"revision" : "a2e41dbf95c49f66120497002c680b929e969f97"
"revision" : "18043cbc24e5bb79aa1f44e01a367e0bccd2fa6e",
"version" : "99.0.2"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
Expand Down
15 changes: 15 additions & 0 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import UserNotifications
import NetworkProtection
#endif

#if SUBSCRIPTION
import Subscription
#endif

@MainActor
final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDelegate {

Expand Down Expand Up @@ -263,6 +267,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
#if DBP
DataBrokerProtectionAppEvents().applicationDidFinishLaunching()
#endif

#if SUBSCRIPTION
Task {
#if STRIPE
SubscriptionPurchaseEnvironment.current = .stripe
#else
SubscriptionPurchaseEnvironment.current = .appStore
#endif
await AccountManager().checkSubscriptionState()
}
#endif
}

func applicationDidBecomeActive(_ notification: Notification) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Import-Export-16D.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Menu-Hamburger-16.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Menu-16.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Menu-Vertical-16.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
4 changes: 2 additions & 2 deletions DuckDuckGo/Bookmarks/Model/BookmarkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protocol BookmarkManager: AnyObject {
func canMoveObjectWithUUID(objectUUID uuid: String, to parent: BookmarkFolder) -> Bool
func move(objectUUIDs: [String], toIndex: Int?, withinParentFolder: ParentFolderType, completion: @escaping (Error?) -> Void)
func moveFavorites(with objectUUIDs: [String], toIndex: Int?, completion: @escaping (Error?) -> Void)
func importBookmarks(_ bookmarks: ImportedBookmarks, source: BookmarkImportSource) -> BookmarkImportResult
func importBookmarks(_ bookmarks: ImportedBookmarks, source: BookmarkImportSource) -> BookmarksImportSummary

func handleFavoritesAfterDisablingSync()

Expand Down Expand Up @@ -313,7 +313,7 @@ final class LocalBookmarkManager: BookmarkManager {

// MARK: - Import

func importBookmarks(_ bookmarks: ImportedBookmarks, source: BookmarkImportSource) -> BookmarkImportResult {
func importBookmarks(_ bookmarks: ImportedBookmarks, source: BookmarkImportSource) -> BookmarksImportSummary {
let results = bookmarkStore.importBookmarks(bookmarks, source: source)
loadBookmarks()
requestSync()
Expand Down
6 changes: 3 additions & 3 deletions DuckDuckGo/Bookmarks/Services/BookmarkStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ enum ParentFolderType {
case parent(uuid: String)
}

struct BookmarkImportResult: Equatable {
struct BookmarksImportSummary: Equatable {
var successful: Int
var duplicates: Int
var failed: Int

static func += (left: inout BookmarkImportResult, right: BookmarkImportResult) {
static func += (left: inout BookmarksImportSummary, right: BookmarksImportSummary) {
left.successful += right.successful
left.duplicates += right.duplicates
left.failed += right.failed
Expand All @@ -57,7 +57,7 @@ protocol BookmarkStore {
func canMoveObjectWithUUID(objectUUID uuid: String, to parent: BookmarkFolder) -> Bool
func move(objectUUIDs: [String], toIndex: Int?, withinParentFolder: ParentFolderType, completion: @escaping (Error?) -> Void)
func moveFavorites(with objectUUIDs: [String], toIndex: Int?, completion: @escaping (Error?) -> Void)
func importBookmarks(_ bookmarks: ImportedBookmarks, source: BookmarkImportSource) -> BookmarkImportResult
func importBookmarks(_ bookmarks: ImportedBookmarks, source: BookmarkImportSource) -> BookmarksImportSummary

func handleFavoritesAfterDisablingSync()
}
4 changes: 2 additions & 2 deletions DuckDuckGo/Bookmarks/Services/BookmarkStoreMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public final class BookmarkStoreMock: BookmarkStore {
}

var importBookmarksCalled = false
func importBookmarks(_ bookmarks: ImportedBookmarks, source: BookmarkImportSource) -> BookmarkImportResult {
func importBookmarks(_ bookmarks: ImportedBookmarks, source: BookmarkImportSource) -> BookmarksImportSummary {
importBookmarksCalled = true
return BookmarkImportResult(successful: 0, duplicates: 0, failed: 0)
return BookmarksImportSummary(successful: 0, duplicates: 0, failed: 0)
}

var canMoveObjectWithUUIDCalled = false
Expand Down
12 changes: 6 additions & 6 deletions DuckDuckGo/Bookmarks/Services/LocalBookmarkStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,8 @@ final class LocalBookmarkStore: BookmarkStore {
/// 2. **Safari:** Create a root level "Imported Favorites" folder to store bookmarks from the bookmarks bar, and all other bookmarks go at the root level.
/// 3. **Chrome:** Put all bookmarks at the root level, except for Other Bookmarks which go in a root level "Other Bookmarks" folder.
/// 4. **Firefox:** Put all bookmarks at the root level, except for Other Bookmarks which go in a root level "Other Bookmarks" folder.
func importBookmarks(_ bookmarks: ImportedBookmarks, source: BookmarkImportSource) -> BookmarkImportResult {
var total = BookmarkImportResult(successful: 0, duplicates: 0, failed: 0)
func importBookmarks(_ bookmarks: ImportedBookmarks, source: BookmarkImportSource) -> BookmarksImportSummary {
var total = BookmarksImportSummary(successful: 0, duplicates: 0, failed: 0)

do {
let context = makeContext()
Expand Down Expand Up @@ -747,15 +747,15 @@ final class LocalBookmarkStore: BookmarkStore {
private func createEntitiesFromBookmarks(allFolders: [BookmarkEntity],
bookmarks: ImportedBookmarks,
importSourceName: String,
in context: NSManagedObjectContext) -> BookmarkImportResult {
in context: NSManagedObjectContext) -> BookmarksImportSummary {

guard let root = bookmarksRoot(in: context) else {
return .init(successful: 0,
duplicates: 0,
failed: bookmarks.numberOfBookmarks)
}

var total = BookmarkImportResult(successful: 0, duplicates: 0, failed: 0)
var total = BookmarksImportSummary(successful: 0, duplicates: 0, failed: 0)

var parent = root
var makeFavorties = true
Expand Down Expand Up @@ -791,8 +791,8 @@ final class LocalBookmarkStore: BookmarkStore {
private func recursivelyCreateEntities(from bookmarks: [ImportedBookmarks.BookmarkOrFolder],
parent: BookmarkEntity,
markBookmarksAsFavorite: Bool? = false,
in context: NSManagedObjectContext) -> BookmarkImportResult {
var total = BookmarkImportResult(successful: 0, duplicates: 0, failed: 0)
in context: NSManagedObjectContext) -> BookmarksImportSummary {
var total = BookmarksImportSummary(successful: 0, duplicates: 0, failed: 0)

let favoritesFolders = BookmarkUtils.fetchFavoritesFolders(for: favoritesDisplayMode, in: context)

Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Bookmarks/View/BookmarkListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ final class BookmarkListViewController: NSViewController {
}

@IBAction func onImportClicked(_ sender: NSButton) {
DataImportViewController.show()
DataImportView.show()
}

// MARK: NSOutlineView Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ final class BookmarkManagementDetailViewController: NSViewController, NSMenuItem
}

@IBAction func onImportClicked(_ sender: NSButton) {
DataImportViewController.show()
DataImportView.show()
}

@IBAction func handleDoubleClick(_ sender: NSTableView) {
Expand Down
12 changes: 0 additions & 12 deletions DuckDuckGo/Common/Extensions/NSColorExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ extension NSColor {
NSColor(named: "FindInPageFocusedBackgroundColor")!
}

static var inactiveSearchBarBackground: NSColor {
NSColor(named: "InactiveSearchBarBackground")!
}

static var suggestionTextColor: NSColor {
NSColor(named: "SuggestionTextColor")!
}
Expand Down Expand Up @@ -138,14 +134,6 @@ extension NSColor {
NSColor(named: "DialogPanelBackground")!
}

static let bookmarkFilledTint = NSColor(named: "BookmarkFilledTint")!

static let bookmarkRepresentingColor1 = NSColor(named: "BookmarkRepresentingColor1")!
static let bookmarkRepresentingColor2 = NSColor(named: "BookmarkRepresentingColor2")!
static let bookmarkRepresentingColor3 = NSColor(named: "BookmarkRepresentingColor3")!
static let bookmarkRepresentingColor4 = NSColor(named: "BookmarkRepresentingColor4")!
static let bookmarkRepresentingColor5 = NSColor(named: "BookmarkRepresentingColor5")!

static var buttonMouseDownColor: NSColor {
NSColor(named: "ButtonMouseDownColor")!
}
Expand Down
15 changes: 7 additions & 8 deletions DuckDuckGo/Common/Extensions/NSOpenPanelExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ extension NSOpenPanel {
return panel
}

static func filePanel(allowedExtension: String) -> NSOpenPanel {
let panel = NSOpenPanel()

panel.directoryURL = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent("Desktop")
panel.canChooseFiles = true
panel.allowedContentTypes = UTType(filenameExtension: allowedExtension).map { [$0] } ?? []
panel.canChooseDirectories = false
convenience init(allowedFileTypes: [UTType], directoryURL: URL? = nil) {
self.init()

return panel
self.directoryURL = directoryURL
canChooseFiles = true
allowedContentTypes = allowedFileTypes
canChooseDirectories = false
}

}
8 changes: 8 additions & 0 deletions DuckDuckGo/Common/Extensions/NSWorkspaceExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ extension NSWorkspace {
return missionControlWindows.count > allScreenSizes.count
}

@available(macOS, obsoleted: 14.0, message: "This needs to be removed as it‘s no longer necessary.")
@nonobjc func urls(forApplicationsWithBundleId bundleId: String) -> [URL] {
if #available(macOS 12.0, *) {
return self.urlsForApplications(withBundleIdentifier: bundleId)
}
return LSCopyApplicationURLsForBundleIdentifier(bundleId as CFString, nil)?.takeRetainedValue() as? [URL] ?? []
}

}
8 changes: 8 additions & 0 deletions DuckDuckGo/Common/Extensions/SetExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ extension Set where Element == String {
}

}

extension Set {

@inlinable func intersects<S: Sequence>(_ other: S) -> Bool where Element == S.Element {
!isDisjoint(with: other)
}

}
Loading

0 comments on commit 52f025c

Please sign in to comment.