Skip to content
This repository has been archived by the owner on Feb 24, 2025. It is now read-only.

Commit

Permalink
Trusted url indicator (#2665)
Browse files Browse the repository at this point in the history
  • Loading branch information
mallexxx authored Apr 26, 2024
1 parent 78f919c commit b2a1608
Show file tree
Hide file tree
Showing 25 changed files with 347 additions and 161 deletions.
6 changes: 0 additions & 6 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@
3706FC8C293F65D500E42796 /* FirefoxDataImporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B5FF67726B602B100D42879 /* FirefoxDataImporter.swift */; };
3706FC8D293F65D500E42796 /* PreferencesGeneralView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37AFCE8A27DB69BC00471A10 /* PreferencesGeneralView.swift */; };
3706FC8E293F65D500E42796 /* PinnedTabsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37BF3F1F286F0A7A00BD9014 /* PinnedTabsView.swift */; };
3706FC92293F65D500E42796 /* NSStoryboardExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE0DF0426781961006337B7 /* NSStoryboardExtension.swift */; };
3706FC93293F65D500E42796 /* PreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37AFCE8027DA2CA600471A10 /* PreferencesViewController.swift */; };
3706FC94293F65D500E42796 /* FireproofDomains.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B02198125E05FAC00ED7DEA /* FireproofDomains.swift */; };
3706FC95293F65D500E42796 /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B677440255DBEEA00025BD8 /* Database.swift */; };
Expand Down Expand Up @@ -1361,7 +1360,6 @@
4BD57C042AC112DF00B580EE /* NetworkProtectionRemoteMessagingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BD57C032AC112DF00B580EE /* NetworkProtectionRemoteMessagingTests.swift */; };
4BD57C052AC112DF00B580EE /* NetworkProtectionRemoteMessagingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BD57C032AC112DF00B580EE /* NetworkProtectionRemoteMessagingTests.swift */; };
4BDFA4AE27BF19E500648192 /* ToggleableScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDFA4AD27BF19E500648192 /* ToggleableScrollView.swift */; };
4BE0DF06267819A1006337B7 /* NSStoryboardExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE0DF0426781961006337B7 /* NSStoryboardExtension.swift */; };
4BE344EE2B2376DF003FC223 /* VPNFeedbackFormViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE344ED2B2376DF003FC223 /* VPNFeedbackFormViewModelTests.swift */; };
4BE344EF2B23786F003FC223 /* VPNFeedbackFormViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE344ED2B2376DF003FC223 /* VPNFeedbackFormViewModelTests.swift */; };
4BE4005327CF3DC3007D3161 /* SavePaymentMethodPopover.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE4005227CF3DC3007D3161 /* SavePaymentMethodPopover.swift */; };
Expand Down Expand Up @@ -3216,7 +3214,6 @@
4BD18F04283F151F00058124 /* BookmarksBar.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = BookmarksBar.storyboard; sourceTree = "<group>"; };
4BD57C032AC112DF00B580EE /* NetworkProtectionRemoteMessagingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionRemoteMessagingTests.swift; sourceTree = "<group>"; };
4BDFA4AD27BF19E500648192 /* ToggleableScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleableScrollView.swift; sourceTree = "<group>"; };
4BE0DF0426781961006337B7 /* NSStoryboardExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSStoryboardExtension.swift; sourceTree = "<group>"; };
4BE344ED2B2376DF003FC223 /* VPNFeedbackFormViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNFeedbackFormViewModelTests.swift; sourceTree = "<group>"; };
4BE4005227CF3DC3007D3161 /* SavePaymentMethodPopover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SavePaymentMethodPopover.swift; sourceTree = "<group>"; };
4BE4005427CF3F19007D3161 /* SavePaymentMethodViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SavePaymentMethodViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -7357,7 +7354,6 @@
B6B3E0DC2657E9CF0040E0A2 /* NSScreenExtension.swift */,
AAC5E4E325D6BA9C007F5990 /* NSSizeExtension.swift */,
4B39AAF527D9B2C700A73FD5 /* NSStackViewExtension.swift */,
4BE0DF0426781961006337B7 /* NSStoryboardExtension.swift */,
AA5C8F58258FE21F00748EB7 /* NSTextFieldExtension.swift */,
858A798426A8BB5D00A75A42 /* NSTextViewExtension.swift */,
4B0511E0262CAA8600F6079C /* NSViewControllerExtension.swift */,
Expand Down Expand Up @@ -10122,7 +10118,6 @@
3706FC8D293F65D500E42796 /* PreferencesGeneralView.swift in Sources */,
37197EA92942443D00394917 /* WebView.swift in Sources */,
3706FC8E293F65D500E42796 /* PinnedTabsView.swift in Sources */,
3706FC92293F65D500E42796 /* NSStoryboardExtension.swift in Sources */,
B6B5F58A2B03673B008DB58A /* BrowserImportMoreInfoView.swift in Sources */,
3706FC93293F65D500E42796 /* PreferencesViewController.swift in Sources */,
3706FC94293F65D500E42796 /* FireproofDomains.swift in Sources */,
Expand Down Expand Up @@ -11464,7 +11459,6 @@
AA8EDF2424923E980071C2E8 /* URLExtension.swift in Sources */,
B634DBDF293C8F7F00C3C99E /* Tab+UIDelegate.swift in Sources */,
B6F1B02E2BCE6B47005E863C /* TunnelControllerProvider.swift in Sources */,
4BE0DF06267819A1006337B7 /* NSStoryboardExtension.swift in Sources */,
37AFCE8127DA2CA600471A10 /* PreferencesViewController.swift in Sources */,
4B02198A25E05FAC00ED7DEA /* FireproofDomains.swift in Sources */,
4B677442255DBEEA00025BD8 /* Database.swift in Sources */,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "Chevron-Right-12.svg",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "Chevron-Right-12-light.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Identity-Theft-Restoration-Multicolor-16.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
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "PersonalInformationRemoval-Multicolor-16.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Settings-Multicolor-16.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
35 changes: 26 additions & 9 deletions DuckDuckGo/Common/Extensions/NSAttributedStringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import AppKit

typealias NSAttributedStringBuilder = ArrayBuilder<NSAttributedString>
extension NSAttributedString {

/// These values come from Figma. Click on the text in Figma and choose Code > iOS to see the values.
Expand All @@ -31,6 +32,31 @@ extension NSAttributedString {
])
}

convenience init(image: NSImage, rect: CGRect) {
let attachment = NSTextAttachment()
attachment.image = image
attachment.bounds = rect
self.init(attachment: attachment)
}

convenience init(@NSAttributedStringBuilder components: () -> [NSAttributedString]) {
let components = components()
guard !components.isEmpty else {
self.init()
return
}
guard components.count > 1 else {
self.init(attributedString: components[0])
return
}
let result = NSMutableAttributedString(attributedString: components[0])
for component in components[1...] {
result.append(component)
}

self.init(attributedString: result)
}

}

extension NSMutableAttributedString {
Expand All @@ -48,12 +74,3 @@ extension NSMutableAttributedString {
}

}

extension NSTextAttachment {
func setImageHeight(height: CGFloat, offset: CGPoint = .zero) {
guard let image = image else { return }
let ratio = image.size.width / image.size.height

bounds = CGRect(x: bounds.origin.x + offset.x, y: bounds.origin.y + offset.y, width: ratio * height, height: height)
}
}
25 changes: 0 additions & 25 deletions DuckDuckGo/Common/Extensions/NSStoryboardExtension.swift

This file was deleted.

5 changes: 5 additions & 0 deletions DuckDuckGo/Common/Extensions/NSViewExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ extension NSView {
return self
}

var isShown: Bool {
get { !isHidden }
set { isHidden = !newValue }
}

func makeMeFirstResponder() {
guard let window = window else {
os_log("%s: Window not available", type: .error, className)
Expand Down
19 changes: 15 additions & 4 deletions DuckDuckGo/Common/Extensions/URLExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ extension URL {
// base url for Error Page Alternate HTML loaded into Web View
static let error = URL(string: "duck://error")!

static let dataBrokerProtection = URL(string: "duck://dbp")!
static let dataBrokerProtection = URL(string: "duck://personal-information-removal")!

#if !SANDBOX_TEST_TOOL
static func settingsPane(_ pane: PreferencePaneIdentifier) -> URL {
Expand Down Expand Up @@ -409,6 +409,10 @@ extension URL {
return false
}

var isEmailProtection: Bool {
self.isChild(of: .duckDuckGoEmailLogin) || self == .duckDuckGoEmail
}

enum DuckDuckGoParameters: String {
case search = "q"
case ia
Expand Down Expand Up @@ -552,7 +556,7 @@ extension URL {
return false
}

func stripUnsupportedCredentials() -> String {
func strippingUnsupportedCredentials() -> String {
if self.absoluteString.firstIndex(of: "@") != nil {
let authPattern = "([^:]+):\\/\\/[^\\/]*@"
let strippedURL = self.absoluteString.replacingOccurrences(of: authPattern, with: "$1://", options: .regularExpression)
Expand All @@ -563,7 +567,14 @@ extension URL {
}

public func isChild(of parentURL: URL) -> Bool {
guard let parentURLHost = parentURL.host, self.isPart(ofDomain: parentURLHost) else { return false }
return pathComponents.starts(with: parentURL.pathComponents)
if scheme == parentURL.scheme,
port == parentURL.port,
let parentURLHost = parentURL.host,
self.isPart(ofDomain: parentURLHost),
pathComponents.starts(with: parentURL.pathComponents) {
return true
} else {
return false
}
}
}
2 changes: 1 addition & 1 deletion DuckDuckGo/Common/View/AppKit/LoadingProgressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class LoadingProgressView: NSView, CAAnimationDelegate {
private var targetProgress: Double = 0.0
private var targetTime: CFTimeInterval = 0.0

var isShown: Bool {
var isProgressShown: Bool {
progressMask.opacity == 1.0
}

Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/Menus/MainMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,8 @@ extension MainViewController: NSMenuItemValidation {
case #selector(findInPage),
#selector(findInPageNext),
#selector(findInPagePrevious):
return activeTabViewModel?.canReload == true // must have content loaded
&& view.window?.isKeyWindow == true // disable in full screen
return activeTabViewModel?.canFindInPage == true // must have content loaded
&& view.window?.isKeyWindow == true // disable in video full screen

case #selector(findInPageDone):
return getActiveTabAndIndex()?.tab.findInPage?.isActive == true
Expand Down
Loading

0 comments on commit b2a1608

Please sign in to comment.