Package org.mozilla.geckoview
Class WebExtension.MessageSender
Object
org.mozilla.geckoview.WebExtension.MessageSender
- Enclosing class:
- WebExtension
Describes the sender of a message from a WebExtension.
See also: WebExtensions/API/runtime/MessageSender
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceEnvironment type definitions for WebExtension messaging. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThis sender originated inside a content script.static final intThis sender originated inside a privileged extension context like a background script.final intType of environment that sent this message, eitherENV_TYPE_EXTENSIONif the message was sent from a background pageENV_TYPE_CONTENT_SCRIPTif the message was sent from a content scriptfinal GeckoSessionGeckoSessionthat sent this message.final StringURL of the frame that sent this message.final WebExtensionWebExtensionthat sent this message. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether this MessageSender belongs to a top level frame.
-
Field Details
-
webExtension
WebExtensionthat sent this message. -
session
GeckoSessionthat sent this message.nullif coming from a background script. -
ENV_TYPE_EXTENSION
public static final int ENV_TYPE_EXTENSIONThis sender originated inside a privileged extension context like a background script.- See Also:
-
ENV_TYPE_CONTENT_SCRIPT
public static final int ENV_TYPE_CONTENT_SCRIPTThis sender originated inside a content script.- See Also:
-
environmentType
public final int environmentTypeType of environment that sent this message, eitherENV_TYPE_EXTENSIONif the message was sent from a background pageENV_TYPE_CONTENT_SCRIPTif the message was sent from a content script
-
url
URL of the frame that sent this message.Use this value together with
isTopLevelto verify that the message is coming from the expected page. Only top level frames can be trusted.
-
-
Constructor Details
-
MessageSender
protected MessageSender()Override for testing.
-
-
Method Details
-
isTopLevel
public boolean isTopLevel()Whether this MessageSender belongs to a top level frame.- Returns:
- true if the MessageSender was sent from the top level frame, false otherwise.
-