Skip to content

Commit

Permalink
[iOS] - Fix private-mode/normal-mode flip when opening tabs (#26621)
Browse files Browse the repository at this point in the history
Respect private-mode/normal-mode settings when opening tabs.
  • Loading branch information
Brandon-T authored Nov 19, 2024
1 parent 023382f commit 65683c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 3 additions & 4 deletions ios/brave-ios/Sources/Brave/Frontend/Browser/TabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 65683c1

Please sign in to comment.