Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez committed Jul 23, 2024
1 parent 1e16f9d commit d2d4107
Show file tree
Hide file tree
Showing 23 changed files with 388 additions and 101 deletions.
42 changes: 21 additions & 21 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1593,12 +1593,12 @@
7B4D8A222BDA857300852966 /* VPNOperationErrorRecorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4D8A202BDA857300852966 /* VPNOperationErrorRecorder.swift */; };
7B4D8A232BDA857300852966 /* VPNOperationErrorRecorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4D8A202BDA857300852966 /* VPNOperationErrorRecorder.swift */; };
7B4D8A242BDA857300852966 /* VPNOperationErrorRecorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4D8A202BDA857300852966 /* VPNOperationErrorRecorder.swift */; };
7B5A23682C468233007213AC /* ExcludedSitesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5A23672C468233007213AC /* ExcludedSitesViewController.swift */; };
7B5A23692C468233007213AC /* ExcludedSitesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5A23672C468233007213AC /* ExcludedSitesViewController.swift */; };
7B5A236F2C46A116007213AC /* ExcludedSitesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5A236E2C46A116007213AC /* ExcludedSitesModel.swift */; };
7B5A23702C46A116007213AC /* ExcludedSitesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5A236E2C46A116007213AC /* ExcludedSitesModel.swift */; };
7B5A23752C46A4A8007213AC /* ExcludedSites.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7B5A23742C46A4A8007213AC /* ExcludedSites.storyboard */; };
7B5A23762C46A4A8007213AC /* ExcludedSites.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7B5A23742C46A4A8007213AC /* ExcludedSites.storyboard */; };
7B5A23682C468233007213AC /* ExcludedDomainsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5A23672C468233007213AC /* ExcludedDomainsViewController.swift */; };
7B5A23692C468233007213AC /* ExcludedDomainsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5A23672C468233007213AC /* ExcludedDomainsViewController.swift */; };
7B5A236F2C46A116007213AC /* ExcludedDomainsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5A236E2C46A116007213AC /* ExcludedDomainsModel.swift */; };
7B5A23702C46A116007213AC /* ExcludedDomainsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5A236E2C46A116007213AC /* ExcludedDomainsModel.swift */; };
7B5A23752C46A4A8007213AC /* ExcludedDomains.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7B5A23742C46A4A8007213AC /* ExcludedDomains.storyboard */; };
7B5A23762C46A4A8007213AC /* ExcludedDomains.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7B5A23742C46A4A8007213AC /* ExcludedDomains.storyboard */; };
7B624F172BA25C1F00A6C544 /* NetworkProtectionUI in Frameworks */ = {isa = PBXBuildFile; productRef = 7B624F162BA25C1F00A6C544 /* NetworkProtectionUI */; };
7B6545ED2C0778BB00115BEA /* VPNControllerUDSClient+ConvenienceInitializers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6545EC2C0778BB00115BEA /* VPNControllerUDSClient+ConvenienceInitializers.swift */; };
7B6545EE2C0779D500115BEA /* VPNControllerUDSClient+ConvenienceInitializers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6545EC2C0778BB00115BEA /* VPNControllerUDSClient+ConvenienceInitializers.swift */; };
Expand Down Expand Up @@ -3537,9 +3537,9 @@
7B4D8A202BDA857300852966 /* VPNOperationErrorRecorder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNOperationErrorRecorder.swift; sourceTree = "<group>"; };
7B5291882A1697680022E406 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7B5291892A169BC90022E406 /* DeveloperID.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DeveloperID.xcconfig; sourceTree = "<group>"; };
7B5A23672C468233007213AC /* ExcludedSitesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExcludedSitesViewController.swift; sourceTree = "<group>"; };
7B5A236E2C46A116007213AC /* ExcludedSitesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExcludedSitesModel.swift; sourceTree = "<group>"; };
7B5A23742C46A4A8007213AC /* ExcludedSites.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = ExcludedSites.storyboard; sourceTree = "<group>"; };
7B5A23672C468233007213AC /* ExcludedDomainsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExcludedDomainsViewController.swift; sourceTree = "<group>"; };
7B5A236E2C46A116007213AC /* ExcludedDomainsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExcludedDomainsModel.swift; sourceTree = "<group>"; };
7B5A23742C46A4A8007213AC /* ExcludedDomains.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = ExcludedDomains.storyboard; sourceTree = "<group>"; };
7B6545EC2C0778BB00115BEA /* VPNControllerUDSClient+ConvenienceInitializers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VPNControllerUDSClient+ConvenienceInitializers.swift"; sourceTree = "<group>"; };
7B6EC5E42AE2D8AF004FE6DF /* DuckDuckGoDBPAgentAppStore.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DuckDuckGoDBPAgentAppStore.xcconfig; sourceTree = "<group>"; };
7B6EC5E52AE2D8AF004FE6DF /* DuckDuckGoDBPAgent.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DuckDuckGoDBPAgent.xcconfig; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5353,7 +5353,7 @@
4B4D60572A0B29FA00BCD287 /* AppAndExtensionTargets */,
4B4D60602A0B29FA00BCD287 /* AppTargets */,
4B4D60742A0B29FA00BCD287 /* NetworkExtensionTargets */,
7B5A236D2C46A0DA007213AC /* ExcludedSites */,
7B5A236D2C46A0DA007213AC /* ExcludedDomains */,
);
path = NetworkProtection;
sourceTree = "<group>";
Expand Down Expand Up @@ -6149,14 +6149,14 @@
path = UITests;
sourceTree = "<group>";
};
7B5A236D2C46A0DA007213AC /* ExcludedSites */ = {
7B5A236D2C46A0DA007213AC /* ExcludedDomains */ = {
isa = PBXGroup;
children = (
7B5A23742C46A4A8007213AC /* ExcludedSites.storyboard */,
7B5A23672C468233007213AC /* ExcludedSitesViewController.swift */,
7B5A236E2C46A116007213AC /* ExcludedSitesModel.swift */,
7B5A23742C46A4A8007213AC /* ExcludedDomains.storyboard */,
7B5A23672C468233007213AC /* ExcludedDomainsViewController.swift */,
7B5A236E2C46A116007213AC /* ExcludedDomainsModel.swift */,
);
path = ExcludedSites;
path = ExcludedDomains;
sourceTree = "<group>";
};
7B6EC5E32AE2D88C004FE6DF /* DBP */ = {
Expand Down Expand Up @@ -9287,7 +9287,7 @@
3706FCD0293F65D500E42796 /* BookmarksBarCollectionViewItem.xib in Resources */,
3706FCD2293F65D500E42796 /* shield.json in Resources */,
3706FCD4293F65D500E42796 /* TabBarViewItem.xib in Resources */,
7B5A23762C46A4A8007213AC /* ExcludedSites.storyboard in Resources */,
7B5A23762C46A4A8007213AC /* ExcludedDomains.storyboard in Resources */,
3706FCD6293F65D500E42796 /* httpsMobileV2FalsePositives.json in Resources */,
3706FCD8293F65D500E42796 /* BookmarksBar.storyboard in Resources */,
3706FCD9293F65D500E42796 /* trackers-1.json in Resources */,
Expand Down Expand Up @@ -9482,7 +9482,7 @@
4BE5336B286912D40019DBFD /* BookmarksBarCollectionViewItem.xib in Resources */,
AA34396C2754D4E300B241FA /* shield.json in Resources */,
AA7412B324D0B3AC00D22FE0 /* TabBarViewItem.xib in Resources */,
7B5A23752C46A4A8007213AC /* ExcludedSites.storyboard in Resources */,
7B5A23752C46A4A8007213AC /* ExcludedDomains.storyboard in Resources */,
4B677435255DBEB800025BD8 /* httpsMobileV2FalsePositives.json in Resources */,
4BD18F05283F151F00058124 /* BookmarksBar.storyboard in Resources */,
AA3439792754D55100B241FA /* trackers-1.json in Resources */,
Expand Down Expand Up @@ -9927,7 +9927,7 @@
3706FAAD293F65D500E42796 /* BadgeNotificationAnimationModel.swift in Sources */,
3706FAAE293F65D500E42796 /* HyperLink.swift in Sources */,
3706FAAF293F65D500E42796 /* PasteboardWriting.swift in Sources */,
7B5A23692C468233007213AC /* ExcludedSitesViewController.swift in Sources */,
7B5A23692C468233007213AC /* ExcludedDomainsViewController.swift in Sources */,
B6E3E5512BBFCDEE00A41922 /* OpenDownloadsCellView.swift in Sources */,
3706FAB0293F65D500E42796 /* BookmarkOutlineCellView.swift in Sources */,
3706FAB1293F65D500E42796 /* UnprotectedDomains.xcdatamodeld in Sources */,
Expand Down Expand Up @@ -10628,7 +10628,7 @@
4BCBE4552BA7E16600FC75A1 /* NetworkProtectionSubscriptionEventHandler.swift in Sources */,
371209312C233D69003ADF3D /* RemoteMessagingStoreErrorHandling.swift in Sources */,
3706FC83293F65D500E42796 /* PopoverMessageViewController.swift in Sources */,
7B5A23702C46A116007213AC /* ExcludedSitesModel.swift in Sources */,
7B5A23702C46A116007213AC /* ExcludedDomainsModel.swift in Sources */,
4BF97ADA2B43C5DC00EB4240 /* VPNFeedbackCategory.swift in Sources */,
9D9AE86E2AA76D1F0026E7DC /* LoginItem+NetworkProtection.swift in Sources */,
3707C721294B5D2900682A9F /* WKMenuItemIdentifier.swift in Sources */,
Expand Down Expand Up @@ -11894,7 +11894,7 @@
4B723E1326B0007A00E14D75 /* CSVLoginExporter.swift in Sources */,
B6BCC51E2AFCD9ED002C5499 /* DataImportSourcePicker.swift in Sources */,
85C48CCC278D808F00D3263E /* NSAttributedStringExtension.swift in Sources */,
7B5A236F2C46A116007213AC /* ExcludedSitesModel.swift in Sources */,
7B5A236F2C46A116007213AC /* ExcludedDomainsModel.swift in Sources */,
1D710F4B2C48F1F200C3975F /* UpdateDialogHelper.swift in Sources */,
4B41EDB42B168C55001EEDF4 /* VPNFeedbackFormViewModel.swift in Sources */,
AA7EB6E527E7D6DC00036718 /* AnimationView.swift in Sources */,
Expand Down Expand Up @@ -12018,7 +12018,7 @@
1456D6E124EFCBC300775049 /* TabBarCollectionView.swift in Sources */,
4B4D60BF2A0C848A00BCD287 /* NetworkProtection+ConvenienceInitializers.swift in Sources */,
4B6B64842BA930420009FF9F /* WaitlistThankYouPromptPresenter.swift in Sources */,
7B5A23682C468233007213AC /* ExcludedSitesViewController.swift in Sources */,
7B5A23682C468233007213AC /* ExcludedDomainsViewController.swift in Sources */,
BDA7647C2BC497BE00D0400C /* DefaultVPNLocationFormatter.swift in Sources */,
3158B1592B0BF76400AF130C /* DataBrokerProtectionFeatureDisabler.swift in Sources */,
B655124829A79465009BFE1C /* NavigationActionExtension.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
{
"identity" : "lottie-spm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-spm.git",
"location" : "https://github.com/airbnb/lottie-spm",
"state" : {
"revision" : "1d29eccc24cc8b75bff9f6804155112c0ffc9605",
"version" : "4.4.3"
Expand Down Expand Up @@ -131,8 +131,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
"version" : "1.5.0"
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b",
"version" : "1.4.0"
}
},
{
Expand Down
12 changes: 9 additions & 3 deletions DuckDuckGo/Common/Localizables/UserText+NetworkProtection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,15 @@ extension UserText {
return String(format: message, count)
}

// MARK: - Excluded Sites
// "vpn.setting.excluded.sites.description" - Excluded Sites description
static let vpnExcludedSitesDescription = "Websites you selected to be excluded even when the VPN is connected."
// MARK: - Excluded Domains
// "vpn.setting.excluded.domains.description" - Excluded Sites description
static let vpnExcludedDomainsDescription = "Websites you selected to be excluded even when the VPN is connected."
// "vpn.setting.excluded.domains.manage.button.title" - Excluded Sites management button title
static let vpnExcludedDomainsManageButtonTitle = "Manage Excluded Sites…"
// "vpn.excluded.domains.add.domain" - Add Domain button for the excluded sites view
static let vpnExcludedDomainsAddDomain = "Add Website"
// "vpn.excluded.domains.title" - Title for the excluded sites view
static let vpnExcludedDomainsTitle = "Excluded Websites"

// MARK: - DNS
// "vpn.dns.server.title" - Title of the DNS Server section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import NetworkProtectionIPC
import NetworkProtectionUI
import Subscription
import VPNAppLauncher
import SwiftUI

protocol NetworkProtectionIPCClient {
var ipcStatusObserver: ConnectionStatusObserver { get }
Expand Down Expand Up @@ -59,9 +60,37 @@ final class NetworkProtectionNavBarPopoverManager: NetPPopoverManager {
networkProtectionPopover?.isShown ?? false
}

func show(positionedBelow view: NSView, withDelegate delegate: NSPopoverDelegate) -> NSPopover {
let popover = {
@MainActor
func currentSitePublisher() -> Published<CurrentSite?>.Publisher {
let domain: String?

if case .url(let url, _, _) = WindowControllersManager.shared.lastKeyMainWindowController?.mainViewController.activeTabViewModel?.tabContent {

domain = url.host
} else {
domain = nil
}

let icon: NSImage?
let currentSite: NetworkProtectionUI.CurrentSite?

if let domain {
icon = FaviconManager.shared.getCachedFavicon(for: domain, sizeCategory: .small)?.image
currentSite = NetworkProtectionUI.CurrentSite(icon: icon,
domain: domain,
excluded: false)
} else {
icon = nil
currentSite = nil
}

var currentSitePublisher = Published<CurrentSite?>(initialValue: currentSite)
return currentSitePublisher.projectedValue
}

@MainActor
func show(positionedBelow view: NSView, withDelegate delegate: NSPopoverDelegate) -> NSPopover {
let popover: NSPopover = {
let controller = NetworkProtectionIPCTunnelController(ipcClient: ipcClient)

let statusReporter = DefaultNetworkProtectionStatusReporter(
Expand All @@ -77,10 +106,12 @@ final class NetworkProtectionNavBarPopoverManager: NetPPopoverManager {
let onboardingStatusPublisher = UserDefaults.netP.networkProtectionOnboardingStatusPublisher
_ = VPNSettings(defaults: .netP)
let appLauncher = AppLauncher(appBundleURL: Bundle.main.bundleURL)
let currentSitePublisher = currentSitePublisher()

let popover = NetworkProtectionPopover(controller: controller,
onboardingStatusPublisher: onboardingStatusPublisher,
statusReporter: statusReporter,
currentSitePublisher: currentSitePublisher,
uiActionHandler: appLauncher,
menuItems: {
if UserDefaults.netP.networkProtectionOnboardingStatus == .completed {
Expand Down Expand Up @@ -136,6 +167,7 @@ final class NetworkProtectionNavBarPopoverManager: NetPPopoverManager {
popover.show(positionedBelow: view.bounds.insetFromLineOfDeath(flipped: view.isFlipped), in: view)
}

@MainActor
func toggle(positionedBelow view: NSView, withDelegate delegate: NSPopoverDelegate) -> NSPopover? {
if let networkProtectionPopover, networkProtectionPopover.isShown {
networkProtectionPopover.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Excluded Sites View Controller-->
<!--Excluded Domains View Controller-->
<scene sceneID="YwQ-9C-eXK">
<objects>
<viewController storyboardIdentifier="FireproofDomainsViewController" id="Clu-Bo-JRW" userLabel="Excluded Sites View Controller" customClass="ExcludedSitesViewController" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="ExcludedDomainsViewController" id="Clu-Bo-JRW" customClass="ExcludedDomainsViewController" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="fBT-ND-Nbh">
<rect key="frame" x="0.0" y="0.0" width="475" height="307"/>
<autoresizingMask key="autoresizingMask"/>
Expand All @@ -30,7 +30,7 @@
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="removeAllDomains:" target="Clu-Bo-JRW" id="xPH-8I-h5n"/>
<action selector="addDomain:" target="Clu-Bo-JRW" id="DcY-dR-cTx"/>
</connections>
</button>
<scrollView autohidesScrollers="YES" horizontalLineScroll="24" horizontalPageScroll="10" verticalLineScroll="24" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aPG-Pg-rGL">
Expand Down Expand Up @@ -58,7 +58,7 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="FireproofDomainCell" id="SIf-3r-xTz">
<tableCellView identifier="ExcludedDomainCell" id="SIf-3r-xTz">
<rect key="frame" x="8" y="0.0" width="416" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
Expand Down Expand Up @@ -115,7 +115,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aur-0h-QzR">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aur-0h-QzR" userLabel="Excluded Sites Label">
<rect key="frame" x="18" y="271" width="95" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Excluded Sites" id="s7t-C5-auR">
<font key="font" metaFont="systemMedium" size="13"/>
Expand Down Expand Up @@ -169,9 +169,9 @@ DQ
</constraints>
</view>
<connections>
<outlet property="addDomainButton" destination="KAc-ZW-ZAV" id="24L-wi-b08"/>
<outlet property="doneButton" destination="goL-jl-7Gp" id="8Yb-2X-umJ"/>
<outlet property="fireproofSitesLabel" destination="aur-0h-QzR" id="B5V-iN-MUj"/>
<outlet property="removeAllDomainsButton" destination="KAc-ZW-ZAV" id="g8n-OJ-q2k"/>
<outlet property="excludedDomainsLabel" destination="aur-0h-QzR" id="B5V-iN-MUj"/>
<outlet property="removeDomainButton" destination="DEQ-Uh-Y7p" id="Zne-M8-g88"/>
<outlet property="tableView" destination="pIp-Qw-5G1" id="kNl-PR-zGb"/>
</connections>
Expand Down
Loading

0 comments on commit d2d4107

Please sign in to comment.