android-components / mozilla.components.browser.engine.gecko.webextension / GeckoWebExtension

GeckoWebExtension

class GeckoWebExtension : WebExtension (source)

Gecko-based implementation of WebExtension, wrapping the native web extension object provided by GeckoView.

Types

Name Summary
PortId data class PortId
Uniquely identifies a port using its name and the session it was opened for. Ports connected from background scripts will have a null session.

Constructors

| Name | Summary | |—|—| | <init> | GeckoWebExtension(native: WebExtension, webExtensionController: WebExtensionController)GeckoWebExtension(id: String, url: String, webExtensionController: WebExtensionController, allowContentMessaging: Boolean = true, supportActions: Boolean = false, nativeExtension: WebExtension = GeckoNativeWebExtension( url, id, createWebExtensionFlags(allowContentMessaging), webExtensionController ), connectedPorts: MutableMap<PortId, Port> = mutableMapOf())
Gecko-based implementation of WebExtension, wrapping the native web extension object provided by GeckoView. |

Properties

Name Summary
nativeExtension val nativeExtension: WebExtension

Inherited Properties

Name Summary
id val id: String
the unique ID of this extension.
supportActions val supportActions: Boolean
whether or not browser and page actions are handled when received from the web extension
url val url: String
the url pointing to a resources path for locating the extension within the APK file e.g. resource://android/assets/extensions/my_web_ext.

Functions

Name Summary
disconnectPort fun disconnectPort(name: String, session: EngineSession?): Unit
See WebExtension.disconnectPort.
getConnectedPort fun getConnectedPort(name: String, session: EngineSession?): Port?
See WebExtension.getConnectedPort.
getMetadata fun getMetadata(): Metadata?
See WebExtension.getMetadata.
hasActionHandler fun hasActionHandler(session: EngineSession): Boolean
See WebExtension.hasActionHandler.
hasContentMessageHandler fun hasContentMessageHandler(session: EngineSession, name: String): Boolean
See WebExtension.hasContentMessageHandler.
isEnabled fun isEnabled(): Boolean
Checks whether or not this extension is enabled.
registerActionHandler fun registerActionHandler(actionHandler: ActionHandler): Unit
fun registerActionHandler(session: EngineSession, actionHandler: ActionHandler): Unit
See WebExtension.registerActionHandler.
registerBackgroundMessageHandler fun registerBackgroundMessageHandler(name: String, messageHandler: MessageHandler): Unit
See WebExtension.registerBackgroundMessageHandler.
registerContentMessageHandler fun registerContentMessageHandler(session: EngineSession, name: String, messageHandler: MessageHandler): Unit
See WebExtension.registerContentMessageHandler.

Inherited Functions

Name Summary
isBuiltIn fun isBuiltIn(): Boolean
Checks whether or not this extension is built-in (packaged with the APK file) or coming from an external source.

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.