Package org.mozilla.geckoview
Interface WebExtension.MessageDelegate
- Enclosing class:
- WebExtension
@UiThread
public static interface WebExtension.MessageDelegate
Delegates that responds to messages sent from a WebExtension.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
onConnect
(WebExtension.Port port) Called whenever the WebExtension connects to an app usingruntime.connectNative
.default GeckoResult<Object>
onMessage
(String nativeApp, Object message, WebExtension.MessageSender sender) Called whenever the WebExtension sends a message to an app usingruntime.sendNativeMessage
.
-
Method Details
-
onMessage
@Nullable default GeckoResult<Object> onMessage(@NonNull String nativeApp, @NonNull Object message, @NonNull WebExtension.MessageSender sender) Called whenever the WebExtension sends a message to an app usingruntime.sendNativeMessage
.- Parameters:
nativeApp
- The application identifier of the MessageDelegate that sent this message.message
- The message that was sent, either a primitive type or aJSONObject
.sender
- TheWebExtension.MessageSender
corresponding to the frame that originated the message.Note: all messages are to be considered untrusted and should be checked carefully for validity.
- Returns:
- A
GeckoResult
that resolves with a response to the message.
-
onConnect
Called whenever the WebExtension connects to an app usingruntime.connectNative
.- Parameters:
port
-WebExtension.Port
instance that can be used to send and receive messages from the WebExtension. UseWebExtension.Port.sender
to verify the origin of this connection request.
-