Interface WebExtension.MessageDelegate

Enclosing class:

@UiThread public static interface WebExtension.MessageDelegate
Delegates that responds to messages sent from a WebExtension.
  • 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 using runtime.sendNativeMessage.
      nativeApp - The application identifier of the MessageDelegate that sent this message.
      message - The message that was sent, either a primitive type or a JSONObject.
      sender - The WebExtension.MessageSender corresponding to the frame that originated the message.

      Note: all messages are to be considered untrusted and should be checked carefully for validity.

      A GeckoResult that resolves with a response to the message.
    • onConnect

      @Nullable default void onConnect(@NonNull WebExtension.Port port)
      Called whenever the WebExtension connects to an app using runtime.connectNative.
      port - WebExtension.Port instance that can be used to send and receive messages from the WebExtension. Use WebExtension.Port.sender to verify the origin of this connection request.