@UiThread public static class WebExtension.MessageSender extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ENV_TYPE_CONTENT_SCRIPT
This sender originated inside a content script.
|
static int |
ENV_TYPE_EXTENSION
This sender originated inside a privileged extension context like
a background script.
|
int |
environmentType
Type of environment that sent this message, either
ENV_TYPE_EXTENSION if the message was sent from
a background page
ENV_TYPE_CONTENT_SCRIPT if the message was sent
from a content script
|
GeckoSession |
session
GeckoSession that sent this message. |
String |
url
URL of the frame that sent this message.
|
WebExtension |
webExtension
WebExtension that sent this message. |
Modifier | Constructor and Description |
---|---|
protected |
MessageSender()
Override for testing.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isTopLevel()
Whether this MessageSender belongs to a top level frame.
|
@NonNull public final WebExtension webExtension
WebExtension
that sent this message.@Nullable public final GeckoSession session
GeckoSession
that sent this message.
null
if coming from a background script.public static final int ENV_TYPE_EXTENSION
public static final int ENV_TYPE_CONTENT_SCRIPT
public final int environmentType
ENV_TYPE_EXTENSION
if the message was sent from
a background page ENV_TYPE_CONTENT_SCRIPT
if the message was sent
from a content script @NonNull public final String url
isTopLevel
to
verify that the message is coming from the expected page. Only top
level frames can be trusted.