android-components / mozilla.components.browser.session / LegacySessionManager


class LegacySessionManager : Observable<Observer> (source)

This class provides access to a centralized registry of all active sessions.


Name Summary
<init> LegacySessionManager(engine: Engine, engineSessionLinker: EngineSessionLinker, delegate: Observable<Observer> = ObserverRegistry())
This class provides access to a centralized registry of all active sessions.


Name Summary
all val all: List<Session>
Returns a list of all active sessions (including CustomTab sessions).
engine val engine: Engine
selectedSession val selectedSession: Session?
Gets the currently selected session if there is one.
selectedSessionOrThrow val selectedSessionOrThrow: Session
Gets the currently selected session or throws an IllegalStateException if no session is selected.
sessions val sessions: List<Session>
Returns a list of active sessions and filters out sessions used for CustomTabs.
size val size: Int
Returns the number of session including CustomTab sessions.


Name Summary
add fun add(session: Session, selected: Boolean = false, engineSession: EngineSession? = null, parent: Session? = null): Unit
Adds the provided add(sessions: List<Session>): Unit
Adds multiple sessions.
createSessionSnapshot fun createSessionSnapshot(session: Session): Item
createSnapshot fun createSnapshot(): Snapshot
Produces a snapshot of this manager’s state, suitable for restoring via SessionManager.restore. Only regular sessions are included in the snapshot. Private and Custom Tab sessions are omitted.
findSessionById fun findSessionById(id: String): Session?
Finds and returns the session with the given id. Returns null if no matching session could be found.
getEngineSession fun getEngineSession(session: Session = selectedSessionOrThrow): EngineSession?
Gets the linked engine session for the provided session (if it exists).
getOrCreateEngineSession fun getOrCreateEngineSession(session: Session = selectedSessionOrThrow): EngineSession
Gets the linked engine session for the provided session and creates it if needed.
link fun link(session: Session, engineSession: EngineSession): Unit
onLowMemory fun onLowMemory(): Unit
Informs this SessionManager that the OS is in low memory condition so it can reduce its allocated objects.
remove fun remove(session: Session = selectedSessionOrThrow, selectParentIfExists: Boolean = false): Unit
Removes the provided session. If no session is provided then the selected session is removed.
removeAll fun removeAll(): Unit
Removes all sessions including CustomTab sessions.
removeSessions fun removeSessions(): Unit
Removes all sessions but CustomTab sessions.
restore fun restore(snapshot: Snapshot, updateSelection: Boolean = true): Unit
Restores sessions from the provided Snapshot.
select fun select(session: Session): Unit
Marks the given session as selected.

Companion Object Properties

Name Summary

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.