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

Commit e018eef

Browse files
Debug vanilla browser (#2236)
Task/Issue URL: https://app.asana.com/0/1199230911884351/1206522891480880/f Tech Design URL: https://app.asana.com/0/0/1206524485561895/f CC: @jaceklyp @laghee **Description**: This PR adds a vanilla browser to the debug menu. The browser features are described [here](https://app.asana.com/0/0/1206524485561895/f) Note: - Multi-windows and multi-tab functionalities are simulated just opening a new Vanilla browser window at the new URL. - Cookies are shared between the Vanilla Browser windows and are persisted until the app main is closed. **Steps to test this PR**: Basic navigation: 1. Debug menu > Open vanilla browser 2. Navigate to any website New window/Popup: - navigate to a website that opens a new window/popup (example [Sign with apple here ](https://www.mathway.com/auth?mode=signin&cultureRoute=en-US&redirect=https%3A%2F%2Fwww.mathway.com%2FAlgebra)) Cookies retention - log in on a website, open a new window and navigate to the same website, the login is retained.
1 parent be5aa6d commit e018eef

File tree

8 files changed

+156
-3
lines changed

8 files changed

+156
-3
lines changed

DuckDuckGo.xcodeproj/project.pbxproj

+41
Original file line numberDiff line numberDiff line change
@@ -3153,6 +3153,12 @@
31533153
EECE10E629DD77E60044D027 /* FeatureFlag.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECE10E429DD77E60044D027 /* FeatureFlag.swift */; };
31543154
EEF12E6F2A2111880023E6BF /* MacPacketTunnelProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF12E6D2A2111880023E6BF /* MacPacketTunnelProvider.swift */; };
31553155
EEF53E182950CED5002D78F4 /* JSAlertViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF53E172950CED5002D78F4 /* JSAlertViewModelTests.swift */; };
3156+
F1D43AEE2B98D8DF00BAB743 /* MainMenuActions+VanillaBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1D43AED2B98D8DF00BAB743 /* MainMenuActions+VanillaBrowser.swift */; };
3157+
F1D43AEF2B98D8DF00BAB743 /* MainMenuActions+VanillaBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1D43AED2B98D8DF00BAB743 /* MainMenuActions+VanillaBrowser.swift */; };
3158+
F1D43AF02B98D8DF00BAB743 /* MainMenuActions+VanillaBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1D43AED2B98D8DF00BAB743 /* MainMenuActions+VanillaBrowser.swift */; };
3159+
F1D43AF32B98E47800BAB743 /* BareBonesBrowserKit in Frameworks */ = {isa = PBXBuildFile; productRef = F1D43AF22B98E47800BAB743 /* BareBonesBrowserKit */; };
3160+
F1D43AF52B98E48900BAB743 /* BareBonesBrowserKit in Frameworks */ = {isa = PBXBuildFile; productRef = F1D43AF42B98E48900BAB743 /* BareBonesBrowserKit */; };
3161+
F1D43AF72B98E48F00BAB743 /* BareBonesBrowserKit in Frameworks */ = {isa = PBXBuildFile; productRef = F1D43AF62B98E48F00BAB743 /* BareBonesBrowserKit */; };
31563162
F41D174125CB131900472416 /* NSColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F41D174025CB131900472416 /* NSColorExtension.swift */; };
31573163
F44C130225C2DA0400426E3E /* NSAppearanceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44C130125C2DA0400426E3E /* NSAppearanceExtension.swift */; };
31583164
F4A6198C283CFFBB007F2080 /* ContentScopeFeatureFlagging.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A6198B283CFFBB007F2080 /* ContentScopeFeatureFlagging.swift */; };
@@ -4489,6 +4495,7 @@
44894495
EECE10E429DD77E60044D027 /* FeatureFlag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureFlag.swift; sourceTree = "<group>"; };
44904496
EEF12E6D2A2111880023E6BF /* MacPacketTunnelProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacPacketTunnelProvider.swift; sourceTree = "<group>"; };
44914497
EEF53E172950CED5002D78F4 /* JSAlertViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSAlertViewModelTests.swift; sourceTree = "<group>"; };
4498+
F1D43AED2B98D8DF00BAB743 /* MainMenuActions+VanillaBrowser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MainMenuActions+VanillaBrowser.swift"; sourceTree = "<group>"; };
44924499
F41D174025CB131900472416 /* NSColorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSColorExtension.swift; sourceTree = "<group>"; };
44934500
F44C130125C2DA0400426E3E /* NSAppearanceExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSAppearanceExtension.swift; sourceTree = "<group>"; };
44944501
F4A6198B283CFFBB007F2080 /* ContentScopeFeatureFlagging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentScopeFeatureFlagging.swift; sourceTree = "<group>"; };
@@ -4510,6 +4517,7 @@
45104517
37A5E2F0298AA1B20047046B /* Persistence in Frameworks */,
45114518
9DC70B1A2AA1FA5B005A844B /* LoginItems in Frameworks */,
45124519
37269EFD2B332FAC005E8E46 /* Common in Frameworks */,
4520+
F1D43AF52B98E48900BAB743 /* BareBonesBrowserKit in Frameworks */,
45134521
378F44E629B4BDEE00899924 /* SwiftUIExtensions in Frameworks */,
45144522
3706FCA7293F65D500E42796 /* BrowserServicesKit in Frameworks */,
45154523
3129788A2B64131200B67619 /* DataBrokerProtection in Frameworks */,
@@ -4656,6 +4664,7 @@
46564664
4B957BDC2AC7AE700062CA31 /* SwiftUIExtensions in Frameworks */,
46574665
4B957BDD2AC7AE700062CA31 /* UserScript in Frameworks */,
46584666
7BBD44282AD730A400D0A064 /* PixelKit in Frameworks */,
4667+
F1D43AF72B98E48F00BAB743 /* BareBonesBrowserKit in Frameworks */,
46594668
7B31FD902AD1257B0086AA24 /* NetworkProtectionIPC in Frameworks */,
46604669
4B957BDE2AC7AE700062CA31 /* Configuration in Frameworks */,
46614670
4B957BE02AC7AE700062CA31 /* Lottie in Frameworks */,
@@ -4745,6 +4754,7 @@
47454754
1E950E3F2912A10D0051A99B /* ContentBlocking in Frameworks */,
47464755
31A3A4E32B0C115F0021063C /* DataBrokerProtection in Frameworks */,
47474756
378F44E429B4BDE900899924 /* SwiftUIExtensions in Frameworks */,
4757+
F1D43AF32B98E47800BAB743 /* BareBonesBrowserKit in Frameworks */,
47484758
1E950E432912A10D0051A99B /* UserScript in Frameworks */,
47494759
CBC83E3629B63D380008E19C /* Configuration in Frameworks */,
47504760
7B31FD8C2AD125620086AA24 /* NetworkProtectionIPC in Frameworks */,
@@ -7360,6 +7370,7 @@
73607370
AA7E919628746BCC00AB6B62 /* HistoryMenu.swift */,
73617371
AA4BBA3A25C58FA200C4FB0F /* MainMenu.swift */,
73627372
AA6EF9B425081B4C004754E6 /* MainMenuActions.swift */,
7373+
F1D43AED2B98D8DF00BAB743 /* MainMenuActions+VanillaBrowser.swift */,
73637374
AAAB9115288EB46B00A057A9 /* VisitMenuItem.swift */,
73647375
);
73657376
path = Menus;
@@ -8416,6 +8427,7 @@
84168427
7B1459562B7D43E500047F2C /* NetworkProtectionProxy */,
84178428
B64E428A2B908666006C1346 /* Macros */,
84188429
85E2BBCF2B8F534A00DBEC7A /* History */,
8430+
F1D43AF42B98E48900BAB743 /* BareBonesBrowserKit */,
84198431
);
84208432
productName = DuckDuckGo;
84218433
productReference = 3706FD05293F65D500E42796 /* DuckDuckGo App Store.app */;
@@ -8711,6 +8723,7 @@
87118723
7B94E1642B7ED95100E32B96 /* NetworkProtectionProxy */,
87128724
B64E42A82B9086BE006C1346 /* Macros */,
87138725
85E2BBD12B8F536F00DBEC7A /* History */,
8726+
F1D43AF62B98E48F00BAB743 /* BareBonesBrowserKit */,
87148727
);
87158728
productName = DuckDuckGo;
87168729
productReference = 4B957C412AC7AE700062CA31 /* DuckDuckGo Privacy Pro.app */;
@@ -8883,6 +8896,7 @@
88838896
85E2BBCD2B8F534000DBEC7A /* History */,
88848897
1EA7B8D22B7E078C000330A4 /* SubscriptionUI */,
88858898
1EA7B8D42B7E078C000330A4 /* Subscription */,
8899+
F1D43AF22B98E47800BAB743 /* BareBonesBrowserKit */,
88868900
B64E42882B90865F006C1346 /* Macros */,
88878901
);
88888902
productName = DuckDuckGo;
@@ -9024,6 +9038,7 @@
90249038
4B2AAAF329E70DEA0026AFC0 /* XCRemoteSwiftPackageReference "lottie-ios" */,
90259039
B65CD8C92B316DF100A595BB /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */,
90269040
B6F997B92B8F352500476735 /* XCRemoteSwiftPackageReference "apple-toolbox" */,
9041+
F1D43AF12B98E47800BAB743 /* XCRemoteSwiftPackageReference "BareBonesBrowser" */,
90279042
);
90289043
productRefGroup = AA585D7F248FD31100E9A3E2 /* Products */;
90299044
projectDirPath = "";
@@ -9805,6 +9820,7 @@
98059820
3706FAC1293F65D500E42796 /* FeedbackViewController.swift in Sources */,
98069821
3706FAC2293F65D500E42796 /* FaviconSelector.swift in Sources */,
98079822
B696AFFC2AC5924800C93203 /* FileLineError.swift in Sources */,
9823+
F1D43AEF2B98D8DF00BAB743 /* MainMenuActions+VanillaBrowser.swift in Sources */,
98089824
B6E1491129A5C30A00AAFBE8 /* FBProtectionTabExtension.swift in Sources */,
98099825
3706FAC4293F65D500E42796 /* PrintingUserScript.swift in Sources */,
98109826
9D9AE86C2AA76D1B0026E7DC /* LoginItemsManager.swift in Sources */,
@@ -11149,6 +11165,7 @@
1114911165
4B957A302AC7AE700062CA31 /* NavigationBarViewController.swift in Sources */,
1115011166
4B957A312AC7AE700062CA31 /* MainViewController.swift in Sources */,
1115111167
4B957A322AC7AE700062CA31 /* DuckPlayer.swift in Sources */,
11168+
F1D43AF02B98D8DF00BAB743 /* MainMenuActions+VanillaBrowser.swift in Sources */,
1115211169
4B957A332AC7AE700062CA31 /* Favicon.swift in Sources */,
1115311170
1E2AE4CA2ACB21A000684E0A /* NetworkProtectionRemoteMessage.swift in Sources */,
1115411171
4B957A342AC7AE700062CA31 /* SuggestionContainerViewModel.swift in Sources */,
@@ -11932,6 +11949,7 @@
1193211949
4B9292DB2667125D00AD2C21 /* ContextualMenu.swift in Sources */,
1193311950
AA68C3D32490ED62001B8783 /* NavigationBarViewController.swift in Sources */,
1193411951
AA585DAF2490E6E600E9A3E2 /* MainViewController.swift in Sources */,
11952+
F1D43AEE2B98D8DF00BAB743 /* MainMenuActions+VanillaBrowser.swift in Sources */,
1193511953
37F19A6A28E2F2D000740DC6 /* DuckPlayer.swift in Sources */,
1193611954
AA5FA69A275F91C700DCE9C9 /* Favicon.swift in Sources */,
1193711955
AABEE69A24A902A90043105B /* SuggestionContainerViewModel.swift in Sources */,
@@ -13736,6 +13754,14 @@
1373613754
version = 2.0.0;
1373713755
};
1373813756
};
13757+
F1D43AF12B98E47800BAB743 /* XCRemoteSwiftPackageReference "BareBonesBrowser" */ = {
13758+
isa = XCRemoteSwiftPackageReference;
13759+
repositoryURL = "https://github.com/duckduckgo/BareBonesBrowser.git";
13760+
requirement = {
13761+
kind = exactVersion;
13762+
version = 0.1.0;
13763+
};
13764+
};
1373913765
/* End XCRemoteSwiftPackageReference section */
1374013766

1374113767
/* Begin XCSwiftPackageProductDependency section */
@@ -14477,6 +14503,21 @@
1447714503
package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
1447814504
productName = NetworkProtection;
1447914505
};
14506+
F1D43AF22B98E47800BAB743 /* BareBonesBrowserKit */ = {
14507+
isa = XCSwiftPackageProductDependency;
14508+
package = F1D43AF12B98E47800BAB743 /* XCRemoteSwiftPackageReference "BareBonesBrowser" */;
14509+
productName = BareBonesBrowserKit;
14510+
};
14511+
F1D43AF42B98E48900BAB743 /* BareBonesBrowserKit */ = {
14512+
isa = XCSwiftPackageProductDependency;
14513+
package = F1D43AF12B98E47800BAB743 /* XCRemoteSwiftPackageReference "BareBonesBrowser" */;
14514+
productName = BareBonesBrowserKit;
14515+
};
14516+
F1D43AF62B98E48F00BAB743 /* BareBonesBrowserKit */ = {
14517+
isa = XCSwiftPackageProductDependency;
14518+
package = F1D43AF12B98E47800BAB743 /* XCRemoteSwiftPackageReference "BareBonesBrowser" */;
14519+
productName = BareBonesBrowserKit;
14520+
};
1448014521
/* End XCSwiftPackageProductDependency section */
1448114522

1448214523
/* Begin XCVersionGroup section */

DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
"version" : "2.0.0"
1010
}
1111
},
12+
{
13+
"identity" : "barebonesbrowser",
14+
"kind" : "remoteSourceControl",
15+
"location" : "https://github.com/duckduckgo/BareBonesBrowser.git",
16+
"state" : {
17+
"revision" : "31e5bfedc3c2ca005640c4bf2b6959d69b0e18b9",
18+
"version" : "0.1.0"
19+
}
20+
},
1221
{
1322
"identity" : "bloom_cpp",
1423
"kind" : "remoteSourceControl",

DuckDuckGo/InfoPlist.xcstrings

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"en" : {
1515
"stringUnit" : {
1616
"state" : "new",
17-
"value" : "DuckDuckGo Privacy Pro"
17+
"value" : "DuckDuckGo"
1818
}
1919
},
2020
"es" : {

DuckDuckGo/Localizable.xcstrings

+39
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
}
5353
}
5454
}
55+
},
56+
"-1 -> 0 ... 1" : {
57+
5558
},
5659
"**%lld** tracking attempts blocked" : {
5760
"comment" : "The number of tracking attempts blocked in the last 7 days, shown on a new tab, translate as: Tracking attempts blocked: %@",
@@ -427,6 +430,24 @@
427430
}
428431
}
429432
}
433+
},
434+
"0->1->nil" : {
435+
436+
},
437+
"10%" : {
438+
439+
},
440+
"20%" : {
441+
442+
},
443+
"50%" : {
444+
445+
},
446+
"80%" : {
447+
448+
},
449+
"100%" : {
450+
430451
},
431452
"about.app_name" : {
432453
"comment" : "Application name to be displayed in the About dialog",
@@ -2005,6 +2026,9 @@
20052026
}
20062027
}
20072028
}
2029+
},
2030+
"Animate" : {
2031+
20082032
},
20092033
"auth.alert.login.button" : {
20102034
"comment" : "Authentication Alert Sign In Button",
@@ -23646,6 +23670,9 @@
2364623670
}
2364723671
}
2364823672
}
23673+
},
23674+
"Indeterminate (-1)" : {
23675+
2364923676
},
2365023677
"invite.dialog.get.started.button" : {
2365123678
"comment" : "Get Started button on an invite dialog",
@@ -29276,6 +29303,9 @@
2927629303
}
2927729304
}
2927829305
}
29306+
},
29307+
"nil->0->nil" : {
29308+
2927929309
},
2928029310
"no.access.to.downloads.folder.header" : {
2928129311
"comment" : "Header of the alert dialog warning the user they need to give the browser permission to access the Downloads folder",
@@ -43846,6 +43876,9 @@
4384643876
}
4384743877
}
4384843878
}
43879+
},
43880+
"Reset (nil)" : {
43881+
4384943882
},
4385043883
"restart.bitwarden" : {
4385143884
"comment" : "Button to restart Bitwarden application",
@@ -45953,6 +45986,9 @@
4595345986
}
4595445987
}
4595545988
}
45989+
},
45990+
"Slow animations" : {
45991+
4595645992
},
4595745993
"Smart Copy/Paste" : {
4595845994
"comment" : "Main Menu Edit-Substitutions item",
@@ -49692,6 +49728,9 @@
4969249728
}
4969349729
}
4969449730
}
49731+
},
49732+
"Zero" : {
49733+
4969549734
},
4969649735
"zoom" : {
4969749736
"comment" : "Menu with Zooming commands",

DuckDuckGo/Menus/MainMenu.swift

+2
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,8 @@ import SubscriptionUI
565565
// swiftlint:disable:next function_body_length
566566
private func setupDebugMenu() -> NSMenu {
567567
let debugMenu = NSMenu(title: "Debug") {
568+
NSMenuItem(title: "Open Vanilla Browser", action: #selector(MainViewController.openVanillaBrowser))
569+
NSMenuItem.separator()
568570
NSMenuItem(title: "Reset Data") {
569571
NSMenuItem(title: "Reset Default Browser Prompt", action: #selector(MainViewController.resetDefaultBrowserPrompt))
570572
NSMenuItem(title: "Reset Default Grammar Checks", action: #selector(MainViewController.resetDefaultGrammarChecks))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//
2+
// MainMenuActions+VanillaBrowser.swift
3+
//
4+
// Copyright © 2024 DuckDuckGo. All rights reserved.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
19+
import Foundation
20+
import BareBonesBrowserKit
21+
import SwiftUI
22+
23+
extension MainViewController: BareBonesBrowserUIDelegate {
24+
25+
fileprivate static let ddgURL = URL(string: "https://duckduckgo.com/")!
26+
@objc func openVanillaBrowser(_ sender: Any?) {
27+
let currentURL = WindowControllersManager.shared.selectedTab?.url ?? MainViewController.ddgURL
28+
openVanillaBrowser(url: currentURL)
29+
}
30+
31+
static var webViewConfiguration: WKWebViewConfiguration = {
32+
let configuration = WKWebViewConfiguration()
33+
configuration.websiteDataStore = WKWebsiteDataStore.nonPersistent()
34+
configuration.processPool = WKProcessPool()
35+
return configuration
36+
}()
37+
38+
private func openVanillaBrowser(url: URL) {
39+
let browserView = NSHostingView(rootView: BareBonesBrowserView(initialURL: url,
40+
homeURL: MainViewController.ddgURL,
41+
uiDelegate: self,
42+
configuration: Self.webViewConfiguration,
43+
userAgent: UserAgent.brandedDefault))
44+
browserView.translatesAutoresizingMaskIntoConstraints = false
45+
browserView.widthAnchor.constraint(greaterThanOrEqualToConstant: 640).isActive = true
46+
browserView.heightAnchor.constraint(greaterThanOrEqualToConstant: 480).isActive = true
47+
let viewController = NSViewController()
48+
viewController.view = browserView
49+
let window = NSWindow(contentViewController: viewController)
50+
window.center()
51+
window.title = "Vanilla browser"
52+
let wc = NSWindowController(window: window)
53+
wc.showWindow(nil)
54+
}
55+
56+
func browserDidRequestNewWindow(urlRequest: URLRequest) {
57+
if let url = urlRequest.url {
58+
openVanillaBrowser(url: url)
59+
}
60+
}
61+
}

DuckDuckGo/UserAgent/Model/UserAgent.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ extension UserAgent {
6666
"Safari/537.36"
6767
static let `default` = UserAgent.safari
6868
static let webViewDefault = ""
69+
static let brandedDefault = Self.default.appending(ddgVersion)
6970

7071
static let localUserAgentConfiguration: KeyValuePairs<RegEx, String> = [
7172
// use safari when serving up PDFs from duckduckgo directly
@@ -94,7 +95,7 @@ extension UserAgent {
9495
}
9596

9697
if isBrandPolicy(forConfig: privacyConfig) {
97-
return Self.default.appending(ddgVersion)
98+
return Self.brandedDefault
9899
} else {
99100
return Self.default
100101
}

0 commit comments

Comments
 (0)