Skip to content

Commit

Permalink
Bugfix FXIOS-8334 [v122.1] Users can be moved from private browsing t…
Browse files Browse the repository at this point in the history
…abs to regular tabs with prefer switch to open tab enabled (backport #18513) (#18544)

* Bugfix FXIOS-8334 [v122.1] Users can be moved from private browsing tabs to regular tabs with prefer switch to open tab enabled (#18513)

* FXIOS-8334 #18469 Users can be moved from private browsing tabs to regular tabs, with prefer-switch-to-open-tab enabled

* Revert method on tab manager

(cherry picked from commit 6c72365)

# Conflicts:
#	Client/Frontend/Browser/BrowserViewController/Views/BrowserViewController.swift

* Remove spaces

* Add missing code changes

---------

Co-authored-by: Litianu Razvan <litianu.razvan@gmail.com>
  • Loading branch information
mergify[bot] and razvanlitianu authored Feb 5, 2024
1 parent 8956b23 commit 7475f2c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1906,10 +1906,12 @@ class BrowserViewController: UIViewController,
// MARK: - LibraryPanelDelegate

func libraryPanel(didSelectURL url: URL, visitType: VisitType) {
if isPreferSwitchToOpenTabOverDuplicateFeatureEnabled, let tab = tabManager.getTabFor(url, reversed: true) {
guard let tab = tabManager.selectedTab else { return }

if isPreferSwitchToOpenTabOverDuplicateFeatureEnabled,
let tab = tabManager.tabs.reversed().first(where: { $0.url == url && $0.isPrivate == tab.isPrivate }) {
tabManager.selectTab(tab)
} else {
guard let tab = tabManager.selectedTab else { return }
// Handle keyboard shortcuts from homepage with url selection
// (ex: Cmd + Tap on Link; which is a cell in this case)
if navigateLinkShortcutIfNeeded(url: url) {
Expand Down Expand Up @@ -2140,14 +2142,16 @@ extension BrowserViewController: HomePanelDelegate {
}

func homePanel(didSelectURL url: URL, visitType: VisitType, isGoogleTopSite: Bool) {
if isPreferSwitchToOpenTabOverDuplicateFeatureEnabled, let tab = tabManager.getTabFor(url, reversed: true) {
guard let tab = tabManager.selectedTab else { return }
if isPreferSwitchToOpenTabOverDuplicateFeatureEnabled,
let tab = tabManager.tabs.reversed().first(where: { $0.url == url && $0.isPrivate == tab.isPrivate }) {
tabManager.selectTab(tab)
} else {
guard let tab = tabManager.selectedTab else { return }
if isGoogleTopSite {
tab.urlType = .googleTopSite
searchTelemetry?.shouldSetGoogleTopSiteSearch = true
}

// Handle keyboard shortcuts from homepage with url selection
// (ex: Cmd + Tap on Link; which is a cell in this case)
if navigateLinkShortcutIfNeeded(url: url) {
Expand Down
3 changes: 1 addition & 2 deletions Client/TabManagement/Legacy/LegacyTabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ class LegacyTabManager: NSObject, FeatureFlaggable, TabManager, TabEventHandler
}

// MARK: Get tabs
func getTabFor(_ url: URL, reversed: Bool = false) -> Tab? {
let tabs = reversed ? self.tabs.reversed() : self.tabs
func getTabFor(_ url: URL) -> Tab? {
for tab in tabs {
if let webViewUrl = tab.webView?.url,
url.isEqual(webViewUrl) {
Expand Down
6 changes: 1 addition & 5 deletions Client/TabManagement/TabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protocol TabManager: AnyObject {
func removeTabs(_ tabs: [Tab])
func undoCloseTab(tab: Tab, position: Int?)
func getMostRecentHomepageTab() -> Tab?
func getTabFor(_ url: URL, reversed: Bool) -> Tab?
func getTabFor(_ url: URL) -> Tab?
func clearAllTabsHistory()
func willSwitchTabMode(leavingPBM: Bool)
func cleanupClosedTabs(_ closedTabs: [Tab], previous: Tab?, isPrivate: Bool)
Expand Down Expand Up @@ -70,10 +70,6 @@ protocol TabManager: AnyObject {
}

extension TabManager {
func getTabFor(_ url: URL, reversed: Bool = false) -> Tab? {
getTabFor(url, reversed: reversed)
}

func removeDelegate(_ delegate: TabManagerDelegate) {
removeDelegate(delegate, completion: nil)
}
Expand Down

1 comment on commit 7475f2c

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

InterpreterError at template.tasks[0].extra[0].treeherder[1].symbol: unknown context value cron

Please sign in to comment.