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
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
This sender originated inside a content script.static final int
This sender originated inside a privileged extension context like a background script.final int
Type of environment that sent this message, eitherENV_TYPE_EXTENSION
if the message was sent from a background pageENV_TYPE_CONTENT_SCRIPT
if the message was sent from a content scriptfinal GeckoSession
GeckoSession
that sent this message.final String
URL of the frame that sent this message.final WebExtension
WebExtension
that sent this message. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether this MessageSender belongs to a top level frame.
-
Field Details
-
webExtension
WebExtension
that sent this message. -
session
GeckoSession
that sent this message.null
if 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_EXTENSION
if the message was sent from a background pageENV_TYPE_CONTENT_SCRIPT
if the message was sent from a content script
-
url
URL of the frame that sent this message.Use this value together with
isTopLevel
to 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.
-