Skip to content

Commit

Permalink
[iOS] - Fix private-mode/normal-mode flip when opening tabs (uplift t…
Browse files Browse the repository at this point in the history
…o 1.74.x) (#26637)

Uplift of #26621 (squashed) to beta
  • Loading branch information
brave-builds authored Nov 20, 2024
1 parent 7316cb8 commit 243098c
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 243098c

Please sign in to comment.