Interface WebExtension.MessageDelegate

Enclosing class:
WebExtension

@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.
      Parameters:
      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.

      Returns:
      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.
      Parameters:
      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.