class ServiceWorkerSupportFeature( private val homeActivity: HomeActivity, ) : ServiceWorkerDelegate, DefaultLifecycleObserver { override fun onDestroy(owner: LifecycleOwner) { homeActivity.components.core.engine.unregisterServiceWorkerDelegate() } override fun onCreate(owner: LifecycleOwner) { homeActivity.components.core.engine.registerServiceWorkerDelegate(this) } override fun addNewTab(engineSession: EngineSession): Boolean { with(homeActivity) { openToBrowser(BrowserDirection.FromHome) components.useCases.tabsUseCases.addTab( flags = LoadUrlFlags.external(), engineSession = engineSession, source = SessionState.Source.Internal.None, ) } return true } }
Fenix own version of the `ServiceWorkerSupportFeature` from Android-Components which adds the ability to navigate to the browser before opening a new tab. Will automatically register callbacks for service workers requests and cleanup when [homeActivity] is destroyed.