android-components / mozilla.components.support.webextensions / WebExtensionController

WebExtensionController

class WebExtensionController (source)

Provides functionality to feature modules that need to interact with a web extension.

Constructors

Name Summary
<init> WebExtensionController(extensionId: String, extensionUrl: String)
Provides functionality to feature modules that need to interact with a web extension.

Functions

Name Summary
disconnectPort fun disconnectPort(engineSession: EngineSession?, name: String = extensionId): Unit
Disconnects the port of the provided session.
install fun install(engine: Engine): Unit
Makes sure the web extension is installed in the provided engine. If a content message handler was registered (see registerContentMessageHandler) before install completed, registration will happen upon successful installation.
portConnected fun portConnected(engineSession: EngineSession?, name: String = extensionId): Boolean
Checks whether or not a port is connected for the provided session.
registerBackgroundMessageHandler fun registerBackgroundMessageHandler(messageHandler: MessageHandler, name: String = extensionId): Unit
Registers a background message handler for this extension. An existing handler will be replaced and there is no need to unregister.
registerContentMessageHandler fun registerContentMessageHandler(engineSession: EngineSession, messageHandler: MessageHandler, name: String = extensionId): Unit
Registers a content message handler for the provided session. Currently only one handler can be registered per session. An existing handler will be replaced and there is no need to unregister.
sendBackgroundMessage fun sendBackgroundMessage(msg: <ERROR CLASS>, name: String = extensionId): Unit
Sends a background message to the provided extension.
sendContentMessage fun sendContentMessage(msg: <ERROR CLASS>, engineSession: EngineSession?, name: String = extensionId): Unit
Sends a content message to the provided session.

Companion Object Properties

Name Summary
installedExtensions val installedExtensions: ConcurrentHashMap<String, WebExtension>

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.