android-components / mozilla.components.concept.engine.webextension / WebExtension

WebExtension

abstract class WebExtension (source)

Represents a browser extension based on the WebExtension API: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions

Constructors

Name Summary
<init> WebExtension(id: String, url: String, supportActions: Boolean)
Represents a browser extension based on the WebExtension API: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions

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 abstract fun disconnectPort(name: String, session: EngineSession? = null): Unit
Disconnect a Port of the provided EngineSession. This method has no effect if there’s no connected port with the given name.
getConnectedPort abstract fun getConnectedPort(name: String, session: EngineSession? = null): Port?
Returns a connected port with the given name and for the provided EngineSession, if one exists.
getMetadata abstract fun getMetadata(): Metadata?
Returns additional information about this extension.
hasActionHandler abstract fun hasActionHandler(session: EngineSession): Boolean
Checks whether there is an existing action handler for the provided session.
hasContentMessageHandler abstract fun hasContentMessageHandler(session: EngineSession, name: String): Boolean
Checks whether there is an existing content message handler for the provided session and “application” name.
isBuiltIn fun isBuiltIn(): Boolean
Checks whether or not this extension is built-in (packaged with the APK file) or coming from an external source.
isEnabled abstract fun isEnabled(): Boolean
Checks whether or not this extension is enabled.
registerActionHandler abstract fun registerActionHandler(actionHandler: ActionHandler): Unit
Registers an ActionHandler for this web extension. The handler will be invoked whenever browser and page action defaults change. To listen for session-specific overrides see registerActionHandler( EngineSession, ActionHandler).abstract fun registerActionHandler(session: EngineSession, actionHandler: ActionHandler): Unit
Registers an ActionHandler for the provided EngineSession. The handler will be invoked whenever browser and page action overrides are received for the provided session.
registerBackgroundMessageHandler abstract fun registerBackgroundMessageHandler(name: String, messageHandler: MessageHandler): Unit
Registers a MessageHandler for message events from background scripts.
registerContentMessageHandler abstract fun registerContentMessageHandler(session: EngineSession, name: String, messageHandler: MessageHandler): Unit
Registers a MessageHandler for message events from content scripts.

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.

Inheritors

Name Summary
GeckoWebExtension class GeckoWebExtension : WebExtension
Gecko-based implementation of WebExtension, wrapping the native web extension object provided by GeckoView.