Skip to content

Commit

Permalink
Merge branch 'main' into sam/fix-vpn-app-store-agent-compilation
Browse files Browse the repository at this point in the history
* main:
  Fix Gatekeeper dialog for binaries downloaded by the browser (#2068)
  Display "Copy Email Address" context menu action for email links (#2076)
  add pixels for sync flows (#2056)
  Sign up with Apple bug fix (#2083)
  Improve DBP onboarding experience for FE devs (#2082)
  Prompt for Primary Password for FF Key3.db logins (#2066)
  Throw error on import database mapping error (#2065)
  Bump BrowserServicesKit Version (#2063)
  Bump autoconsent to 9.1.0 (#2067)
  Fix casing in some copy items in Preferences and Main Menu (#2070)
  Fix vertical alignment of privacy feed shield icon (#2069)
  Fix giving focus to webView when it's loaded in BrowserTabViewController (#2073)
  • Loading branch information
samsymons committed Jan 19, 2024
2 parents 9d55839 + 5352e94 commit f3952da
Show file tree
Hide file tree
Showing 57 changed files with 1,177 additions and 155 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13234,7 +13234,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 101.1.2;
version = 101.1.4;
};
};
AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "44569e233945c099887266c1d7b8e07b25558a02",
"version" : "101.1.2"
"revision" : "7f9eb807af196ec3db8fe6f0b168df89ea16a11c",
"version" : "101.1.4"
}
},
{
"identity" : "content-scope-scripts",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "bb027f14bec7fbb1a85d308139e7a66686da160e",
"version" : "4.59.0"
"revision" : "0b68b0d404d8d4f32296cd84fa160b18b0aeaf44",
"version" : "4.59.1"
}
},
{
Expand Down Expand Up @@ -147,7 +147,7 @@
{
"identity" : "trackerradarkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/TrackerRadarKit.git",
"location" : "https://github.com/duckduckgo/TrackerRadarKit",
"state" : {
"revision" : "a6b7ba151d9dc6684484f3785293875ec01cc1ff",
"version" : "1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Autoconsent/autoconsent-bundle.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions DuckDuckGo/BookmarksBar/View/BookmarksBarMenuFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ struct BookmarksBarMenuFactory {
private static func makeMenuItem( _ prefs: AppearancePreferences) -> NSMenuItem {
let item = NSMenuItem(title: UserText.showBookmarksBar, action: nil, keyEquivalent: "B")
item.submenu = NSMenu(items: [
BlockMenuItem(title: UserText.showBookmarksBarAlways, isChecked: prefs.showBookmarksBar && prefs.bookmarksBarAppearance == .alwaysOn) {
BlockMenuItem(title: UserText.mainMenuBookmarksShowBookmarksBarAlways, isChecked: prefs.showBookmarksBar && prefs.bookmarksBarAppearance == .alwaysOn) {
prefs.bookmarksBarAppearance = .alwaysOn
prefs.showBookmarksBar = true
},
BlockMenuItem(title: UserText.showBookmarksBarNewTabOnly, isChecked: prefs.showBookmarksBar && prefs.bookmarksBarAppearance == .newTabOnly) {
BlockMenuItem(title: UserText.mainMenuBookmarksShowBookmarksBarNewTabOnly, isChecked: prefs.showBookmarksBar && prefs.bookmarksBarAppearance == .newTabOnly) {
prefs.bookmarksBarAppearance = .newTabOnly
prefs.showBookmarksBar = true
},
BlockMenuItem(title: UserText.showBookmarksBarNever, isChecked: !prefs.showBookmarksBar) {
BlockMenuItem(title: UserText.mainMenuBookmarksShowBookmarksBarNever, isChecked: !prefs.showBookmarksBar) {
prefs.showBookmarksBar = false
}
])
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/Common/Database/Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// limitations under the License.
//

import AppKit
import BrowserServicesKit
import Foundation
import CoreData
Expand Down
25 changes: 15 additions & 10 deletions DuckDuckGo/Common/Extensions/URLExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ extension URL {
// MARK: ATB

static var devMode: String {
#if DEBUG
#if DEBUG
return "?test=1"
#else
#else
return ""
#endif
#endif
}

static let atb = "\(Self.duckDuckGo)atb.js\(devMode)"
Expand Down Expand Up @@ -270,8 +270,7 @@ extension URL {

return self.toString(decodePunycode: decodePunycode,
dropScheme: input.isEmpty || !(hasInputScheme && !hasInputHost),
needsWWW: !input.dropping(prefix: self.separatedScheme ?? "").isEmpty
&& hasInputWww,
needsWWW: !input.dropping(prefix: self.separatedScheme ?? "").isEmpty && hasInputWww,
dropTrailingSlash: !input.hasSuffix("/"))
}

Expand All @@ -292,6 +291,14 @@ extension URL {
return filename
}

var emailAddresses: [String] {
guard navigationalScheme == .mailto, let path = URLComponents(url: self, resolvingAgainstBaseURL: false)?.path else {
return []
}

return path.components(separatedBy: .init(charactersIn: ", ")).filter { !$0.isEmpty }
}

// MARK: - Validity

var isDataURL: Bool {
Expand Down Expand Up @@ -423,11 +430,9 @@ extension URL {
quarantineProperties[kLSQuarantineDataURLKey as String] = sourceURL
quarantineProperties[kLSQuarantineOriginURLKey as String] = referrerURL

if quarantineProperties[kLSQuarantineTypeKey as String] == nil {
quarantineProperties[kLSQuarantineTypeKey as String] = ["http", "https"].contains(sourceURL?.scheme)
? kLSQuarantineTypeWebDownload
: kLSQuarantineTypeOtherDownload
}
quarantineProperties[kLSQuarantineTypeKey as String] = ["http", "https"].contains(sourceURL?.scheme)
? kLSQuarantineTypeWebDownload
: kLSQuarantineTypeOtherDownload

try (self as NSURL).setResourceValue(quarantineProperties, forKey: .quarantinePropertiesKey)
}
Expand Down
34 changes: 26 additions & 8 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ struct UserText {
static let mainMenuViewHome = NSLocalizedString("Home", comment: "Main Menu View item")
static let mainMenuHomeButton = NSLocalizedString("Home Button", comment: "Main Menu > View > Home Button item")

static func mainMenuHomeButton(for position: HomeButtonPosition) -> String {
static func mainMenuHomeButtonMode(for position: HomeButtonPosition) -> String {
switch position {
case .hidden:
return NSLocalizedString("Hide", comment: "Main Menu > View > Home Button > None item")
case .left:
return NSLocalizedString("Show left of the back button", comment: "Main Menu > View > Home Button > left position item")
return NSLocalizedString("Show Left of the Back Button", comment: "Main Menu > View > Home Button > left position item")
case .right:
return NSLocalizedString("Show right of the reload button", comment: "Main Menu > View > Home Button > right position item")
return NSLocalizedString("Show Right of the Reload Button", comment: "Main Menu > View > Home Button > right position item")
}
}

Expand All @@ -167,6 +167,12 @@ struct UserText {
static let mainMenuHistoryClearAllHistory = NSLocalizedString("Clear All History…", comment: "Main Menu History item")
static let mainMenuHistoryManageBookmarks = NSLocalizedString("Manage Bookmarks", comment: "Main Menu History item")
static let mainMenuHistoryFavoriteThisPage = NSLocalizedString("Favorite This Page…", comment: "Main Menu History item")
static let mainMenuHistoryReopenAllWindowsFromLastSession = NSLocalizedString("Reopen All Windows from Last Session", comment: "Main Menu History item")

// MARK: - Main Menu -> Bookmarks -> Bookmarks Bar
static let mainMenuBookmarksShowBookmarksBarAlways = NSLocalizedString("Always Show", comment: "Preference for always showing the bookmarks bar")
static let mainMenuBookmarksShowBookmarksBarNewTabOnly = NSLocalizedString("Only Show on New Tab", comment: "Preference for only showing the bookmarks bar on new tab")
static let mainMenuBookmarksShowBookmarksBarNever = NSLocalizedString("Never Show", comment: "Preference for never showing the bookmarks bar on new tab")

// MARK: - Main Menu -> Window
static let mainMenuWindow = NSLocalizedString("Window", comment: "Main Menu ")
Expand Down Expand Up @@ -229,6 +235,8 @@ struct UserText {
static let openImageInNewBurnerTab = NSLocalizedString("open.image.in.new.burner.tab", value: "Open Image in New Fire Tab", comment: "Context menu item")
static let copyImageAddress = NSLocalizedString("copy.image.address", value: "Copy Image Address", comment: "Context menu item")
static let saveImageAs = NSLocalizedString("save.image.as", value: "Save Image As…", comment: "Context menu item")
static let copyEmailAddress = NSLocalizedString("copy.email.address", value: "Copy Email Address", comment: "Context menu item")
static let copyEmailAddresses = NSLocalizedString("copy.email.addresses", value: "Copy Email Addresses", comment: "Context menu item")
static let downloadLinkedFileAs = NSLocalizedString("save.image.as", value: "Download Linked File As…", comment: "Context menu item")
static let addLinkToBookmarks = NSLocalizedString("add.link.to.bookmarks", value: "Add Link to Bookmarks", comment: "Context menu item")
static let bookmarkPage = NSLocalizedString("bookmark.page", value: "Bookmark Page", comment: "Context menu item")
Expand Down Expand Up @@ -534,7 +542,7 @@ struct UserText {
static let isNotDefaultBrowser = NSLocalizedString("preferences.default-browser.inactive", value: "DuckDuckGo is not your default browser.", comment: "Indicate that the browser is not the default")
static let makeDefaultBrowser = NSLocalizedString("preferences.default-browser.button.make-default", value: "Make DuckDuckGo Default…", comment: "")
static let onStartup = NSLocalizedString("preferences.on-startup", value: "On Startup", comment: "Name of the preferences section related to app startup")
static let reopenAllWindowsFromLastSession = NSLocalizedString("preferences.reopen-windows", value: "Reopen All Windows from Last Session", comment: "Option to control session restoration")
static let reopenAllWindowsFromLastSession = NSLocalizedString("preferences.reopen-windows", value: "Reopen all windows from last session", comment: "Option to control session restoration")
static let showHomePage = NSLocalizedString("preferences.show-home", value: "Open a new window", comment: "Option to control session startup")

static let homePage = NSLocalizedString("preferences-homepage", value: "Homepage", comment: "Title for Homepage section in settings")
Expand All @@ -545,7 +553,18 @@ struct UserText {

static let setHomePage = NSLocalizedString("preferences-homepage-set-homePage", value: "Set Homepage", comment: "Set Homepage dialog title")
static let addressLabel = NSLocalizedString("preferences-homepage-address", value: "Address:", comment: "Homepage address field label")


static func homeButtonMode(for position: HomeButtonPosition) -> String {
switch position {
case .hidden:
return NSLocalizedString("Hide", comment: "Preferences > Home Button > None item")
case .left:
return NSLocalizedString("Show left of the back button", comment: "Preferences > Home Button > left position item")
case .right:
return NSLocalizedString("Show right of the reload button", comment: "Preferences > Home Button > right position item")
}
}

static let theme = NSLocalizedString("preferences.appearance.theme", value: "Theme", comment: "Theme preferences")
static let addressBar = NSLocalizedString("preferences.appearance.address-bar", value: "Address Bar", comment: "Theme preferences")
static let showFullWebsiteAddress = NSLocalizedString("preferences.appearance.show-full-url", value: "Full website address", comment: "Option to show full URL in the address bar")
Expand Down Expand Up @@ -766,9 +785,8 @@ struct UserText {

static let showBookmarksBar = NSLocalizedString("bookmarks.bar.show", value: "Bookmarks Bar", comment: "Menu item for showing the bookmarks bar")
static let showBookmarksBarPreference = NSLocalizedString("bookmarks.bar.show", value: "Show Bookmarks Bar", comment: "Preference item for showing the bookmarks bar")
static let showBookmarksBarAlways = NSLocalizedString("bookmarks.bar.show.always", value: "Always Show", comment: "Preference for always showing the bookmarks bar")
static let showBookmarksBarNewTabOnly = NSLocalizedString("bookmarks.bar.show.new-tab-only", value: "Only Show on New Tab", comment: "Preference for only showing the bookmarks bar on new tab")
static let showBookmarksBarNever = NSLocalizedString("bookmarks.bar.show.never", value: "Never Show", comment: "Preference for never showing the bookmarks bar on new tab")
static let showBookmarksBarAlways = NSLocalizedString("bookmarks.bar.show.always", value: "Always show", comment: "Preference for always showing the bookmarks bar")
static let showBookmarksBarNewTabOnly = NSLocalizedString("bookmarks.bar.show.new-tab-only", value: "Only show on New Tab", comment: "Preference for only showing the bookmarks bar on new tab")
static let bookmarksBarFolderEmpty = NSLocalizedString("bookmarks.bar.folder.empty", value: "Empty", comment: "Empty state for a bookmarks bar folder")
static let bookmarksBarContextMenuCopy = NSLocalizedString("bookmarks.bar.context-menu.copy", value: "Copy", comment: "Copy menu item for the bookmarks bar context menu")
static let bookmarksBarContextMenuDelete = NSLocalizedString("bookmarks.bar.context-menu.delete", value: "Delete", comment: "Delete menu item for the bookmarks bar context menu")
Expand Down
9 changes: 5 additions & 4 deletions DuckDuckGo/DBP/DataBrokerProtectionDebugMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ final class DataBrokerProtectionDebugMenu: NSMenu {

@objc private func setWebUICustomURL() {
showCustomURLAlert { [weak self] value in
if let url = value {
let modifiedURL = url.hasPrefix("https://") ? url : "https://\(url)"
self?.webUISettings.setCustomURL(modifiedURL)
}

guard let value = value,
URL(string: value) != nil else { return }

self?.webUISettings.setCustomURL(value)
}
}

Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/DBP/DataBrokerProtectionFeatureVisibility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ struct DefaultDataBrokerProtectionFeatureVisibility: DataBrokerProtectionFeature
regionCode = Locale.current.regionCode
}

if isInternalUser {
regionCode = "US"
}

#if DEBUG // Always assume US for debug builds
regionCode = "US"
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// limitations under the License.
//

import AppKit
import Foundation
import GRDB

Expand Down Expand Up @@ -52,11 +53,11 @@ final class ChromiumFaviconsReader {
NSImage(data: imageData)
}

init(row: Row) {
pageURL = row["page_url"]
iconURL = row["url"]
size = row["width"]
imageData = row["image_data"]
init(row: Row) throws {
pageURL = try row["page_url"] ?? { throw FetchableRecordError<ChromiumFavicon>(column: 0) }()
iconURL = try row["url"] ?? { throw FetchableRecordError<ChromiumFavicon>(column: 1) }()
size = try row["width"] ?? { throw FetchableRecordError<ChromiumFavicon>(column: 2) }()
imageData = try row["image_data"] ?? { throw FetchableRecordError<ChromiumFavicon>(column: 3) }()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ final class FirefoxBookmarksReader {
let parent: Int
let guid: String

init(row: Row) {
id = row["id"]
title = row["title"]
parent = row["parent"]
guid = row["guid"]
init(row: Row) throws {
id = try row["id"] ?? { throw FetchableRecordError<FolderRow>(column: 0) }()
title = try row["title"] ?? { throw FetchableRecordError<FolderRow>(column: 1) }()
parent = try row["parent"] ?? { throw FetchableRecordError<FolderRow>(column: 2) }()
guid = try row["guid"] ?? { throw FetchableRecordError<FolderRow>(column: 3) }()
}
}

Expand All @@ -153,11 +153,11 @@ final class FirefoxBookmarksReader {
let url: String
let parent: Int

init(row: Row) {
id = row["id"]
title = row["title"]
url = row["url"]
parent = row["parent"]
init(row: Row) throws {
id = try row["id"] ?? { throw FetchableRecordError<BookmarkRow>(column: 0) }()
self.title = row["title"]
url = try row["url"] ?? { throw FetchableRecordError<BookmarkRow>(column: 2) }()
parent = try row["parent"] ?? { throw FetchableRecordError<BookmarkRow>(column: 3) }()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// limitations under the License.
//

import AppKit
import Foundation
import GRDB

Expand Down Expand Up @@ -49,11 +50,11 @@ final class FirefoxFaviconsReader {
NSImage(data: imageData)
}

init(row: Row) {
pageURL = row["page_url"]
iconURL = row["icon_url"]
size = row["width"]
imageData = row["data"]
init(row: Row) throws {
pageURL = try row["page_url"] ?? { throw FetchableRecordError<FirefoxFavicon>(column: 0) }()
iconURL = try row["icon_url"] ?? { throw FetchableRecordError<FirefoxFavicon>(column: 1) }()
size = try row["width"] ?? { throw FetchableRecordError<FirefoxFavicon>(column: 2) }()
imageData = try row["data"] ?? { throw FetchableRecordError<FirefoxFavicon>(column: 3) }()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// limitations under the License.
//

import AppKit
import Foundation
import Common
import CryptoKit
Expand Down Expand Up @@ -60,8 +61,8 @@ final class SafariFaviconsReader {
return components.string
}

init(row: Row) {
host = row["host"]
init(row: Row) throws {
host = try row["host"] ?? { throw FetchableRecordError<SafariFaviconRecord>(column: 0) }()
}
}

Expand Down
7 changes: 7 additions & 0 deletions DuckDuckGo/DataImport/DataImport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,13 @@ extension DataImportError /* : LocalizedError */ {

}

struct FetchableRecordError<T>: Error, CustomNSError {
let column: Int

static var errorDomain: String { "FetchableRecordError.\(T.self)" }
var errorCode: Int { column }
}

enum DataImportProgressEvent {
case initial
case importingPasswords(numberOfPasswords: Int?, fraction: Double)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ private struct ChromiumCredential: Identifiable {

extension ChromiumCredential: FetchableRecord {

init(row: Row) {
url = row["signon_realm"]
username = row["username_value"]
encryptedPassword = row["password_value"]
init(row: Row) throws {
url = try row["signon_realm"] ?? { throw FetchableRecordError<ChromiumCredential>(column: 0) }()
username = try row["username_value"] ?? { throw FetchableRecordError<ChromiumCredential>(column: 1) }()
encryptedPassword = try row["password_value"] ?? { throw FetchableRecordError<ChromiumCredential>(column: 2) }()
passwordModifiedAt = row["date_password_modified"]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,15 @@ enum FirefoxBerkeleyDatabaseReader {
Data(bytes: pointer, count: currentDataDBT.size)
}

let currentKeyHexadecimalString = currentKeyData.hexadecimalString
let currentKeyString = String(bytes: currentKeyData, encoding: .utf8)

if currentKeyHexadecimalString == Self.firefoxASN1Key {
if currentKeyData == Self.firefoxASN1Key {
results["data"] = currentData
} else if let currentKeyString {
} else if let currentKeyString = currentKeyData.utf8String() {
results[currentKeyString] = currentData
}
}

return results
}

private static let firefoxASN1Key: String = "f8000000000000000000000000000001"
}

private extension Data {
var hexadecimalString: String {
Array(self).reduce(into: String()) { $0.append(String(format: "%02lx", $1)) }
}
private static let firefoxASN1Key = Data([0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01])
}
Loading

0 comments on commit f3952da

Please sign in to comment.