android-components / mozilla.components.concept.engine / EngineSession


abstract class EngineSession : Observable<Observer>, DataCleanable (source)

Class representing a single engine session.

In browsers usually a session corresponds to a tab.


Name Summary
LoadUrlFlags class LoadUrlFlags
Describes a combination of flags provided to the engine when loading a URL.
Observer interface Observer
Interface to be implemented by classes that want to observe this engine session.
SafeBrowsingPolicy enum class SafeBrowsingPolicy
Represents a safe browsing policy, which is indicates with type of site should be alerted to user as possible harmful.
TrackingProtectionPolicy open class TrackingProtectionPolicy
Represents a tracking protection policy, which is a combination of tracker categories that should be blocked. Unless otherwise specified, a TrackingProtectionPolicy is applicable to all session types (see TrackingProtectionPolicyForSessionTypes).
TrackingProtectionPolicyForSessionTypes class TrackingProtectionPolicyForSessionTypes : TrackingProtectionPolicy
Subtype of TrackingProtectionPolicy to control the type of session this policy should be applied to. By default, a policy will be applied to all sessions.


Name Summary
<init> EngineSession(delegate: Observable<Observer> = ObserverRegistry())
Class representing a single engine session.


Name Summary
settings abstract val settings: Settings
Provides access to the settings of this engine session.


Name Summary
clearFindMatches abstract fun clearFindMatches(): Unit
Clears the highlighted results of previous calls to findAll / findNext.
close open fun close(): Unit
Close the session. This may free underlying objects. Call this when you are finished using this session.
disableTrackingProtection abstract fun disableTrackingProtection(): Unit
Disables tracking protection for this engine session.
enableTrackingProtection abstract fun enableTrackingProtection(policy: TrackingProtectionPolicy = TrackingProtectionPolicy.strict()): Unit
Enables tracking protection for this engine session.
exitFullScreenMode abstract fun exitFullScreenMode(): Unit
Exits fullscreen mode if currently in it that state.
findAll abstract fun findAll(text: String): Unit
Finds and highlights all occurrences of the provided String and highlights them asynchronously.
findNext abstract fun findNext(forward: Boolean): Unit
Finds and highlights the next or previous match found by findAll.
goBack abstract fun goBack(): Unit
Navigates back in the history of this session.
goForward abstract fun goForward(): Unit
Navigates forward in the history of this session.
goToHistoryIndex abstract fun goToHistoryIndex(index: Int): Unit
Navigates to the specified index in the HistoryState of this session. The current index of this session’s HistoryState will be updated but the items within it will be unchanged. Invalid index values are ignored.
loadData abstract fun loadData(data: String, mimeType: String = "text/html", encoding: String = "UTF-8"): Unit
Loads the data with the given mimeType. Example:
loadUrl abstract fun loadUrl(url: String, parent: EngineSession? = null, flags: LoadUrlFlags = LoadUrlFlags.none(), additionalHeaders: Map<String, String>? = null): Unit
Loads the given URL.
markActiveForWebExtensions open fun markActiveForWebExtensions(active: Boolean): Unit
Marks this session active/inactive for web extensions to support tabs.query({active: true}).
recoverFromCrash abstract fun recoverFromCrash(): Boolean
Tries to recover from a crash by restoring the last know state.
reload abstract fun reload(flags: LoadUrlFlags = LoadUrlFlags.none()): Unit
Reloads the current URL.
restoreState abstract fun restoreState(state: EngineSessionState): Boolean
Restores the engine state as provided by saveState.
saveState abstract fun saveState(): EngineSessionState
Saves and returns the engine state. Engine implementations are not required to persist the state anywhere else than in the returned map. Engines that already provide a serialized state can use a single entry in this map to provide this state. The only requirement is that the same map can be used to restore the original state. See restoreState and the specific engine implementation for details.
stopLoading abstract fun stopLoading(): Unit
Stops loading the current session.
toggleDesktopMode abstract fun toggleDesktopMode(enable: Boolean, reload: Boolean = false): Unit
Enables/disables Desktop Mode with an optional ability to reload the session right after.

Inherited Functions

Name Summary
clearData open fun clearData(data: BrowsingData = Engine.BrowsingData.all(), host: String? = null, onSuccess: () -> Unit = { }, onError: (Throwable) -> Unit = { }): Unit
Clears browsing data stored.

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.


Name Summary
GeckoEngineSession class GeckoEngineSession : CoroutineScope, EngineSession
Gecko-based EngineSession implementation.
SystemEngineSession class SystemEngineSession : EngineSession
WebView-based EngineSession implementation.