From 60d23da861615862bdc0884084bdaebd5f1a5497 Mon Sep 17 00:00:00 2001 From: brave-builds Date: Tue, 19 Nov 2024 16:32:24 +0000 Subject: [PATCH] Uplift of #26621 (squashed) to beta --- .../BrowserViewController/BrowserViewController.swift | 7 ++++++- .../Sources/Brave/Frontend/Browser/TabManager.swift | 7 +++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift index b3d63eb01cbc..8cabf1a20212 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift @@ -2171,7 +2171,12 @@ public class BrowserViewController: UIViewController { let request: URLRequest? if let url = url { // If only empty tab present, the url will open in existing tab - if tabManager.isBrowserEmptyForCurrentMode { + // We also need to respect private browsing mode when opening URLs directly. + // If the only tab open is NTP, AND the private mode matches that of the tab request, + // only then we can open the tab directly. + if tabManager.isBrowserEmptyForCurrentMode + && tabManager.privateBrowsingManager.isPrivateBrowsing == isPrivate + { finishEditingAndSubmit(url) return } diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/TabManager.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/TabManager.swift index a6ada00e715e..872aa253b3f6 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/TabManager.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/TabManager.swift @@ -333,10 +333,9 @@ class TabManager: NSObject { if previous === tab { return } - // Convert the global mode to private if opening private tab from normal tab/ history/bookmark. - if selectedTab?.isPrivate != true && tab?.isPrivate == true { - privateBrowsingManager.isPrivateBrowsing = true - } + // Convert the global mode to normal/private + privateBrowsingManager.isPrivateBrowsing = tab?.isPrivate == true + // Make sure to wipe the private tabs if the user has the pref turned on if !TabType.of(tab).isPrivate && (Preferences.Privacy.privateBrowsingOnly.value