You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.fenix.tabhistory
|
|
|
|
|
|
|
|
import androidx.navigation.NavController
|
|
|
|
import mozilla.components.browser.session.SessionManager
|
|
|
|
import mozilla.components.feature.session.SessionUseCases
|
|
|
|
|
|
|
|
interface TabHistoryController {
|
|
|
|
fun handleGoToHistoryItem(item: TabHistoryItem)
|
|
|
|
}
|
|
|
|
|
|
|
|
class DefaultTabHistoryController(
|
|
|
|
private val navController: NavController,
|
|
|
|
private val goToHistoryIndexUseCase: SessionUseCases.GoToHistoryIndexUseCase,
|
|
|
|
private val customTabId: String? = null,
|
|
|
|
private val sessionManager: SessionManager
|
|
|
|
) : TabHistoryController {
|
|
|
|
|
|
|
|
override fun handleGoToHistoryItem(item: TabHistoryItem) {
|
|
|
|
navController.navigateUp()
|
|
|
|
goToHistoryIndexUseCase.invoke(
|
|
|
|
item.index,
|
|
|
|
session = customTabId?.let { sessionManager.findSessionById(customTabId) }
|
|
|
|
?: sessionManager.selectedSession)
|
|
|
|
}
|
|
|
|
}
|