Class WebExtension.SessionController
- Enclosing class:
- WebExtension
-
Method Summary
Modifier and TypeMethodDescriptiongetActionDelegate
(WebExtension extension) Get the Action delegate for this session.getMessageDelegate
(WebExtension extension, String nativeApp) Get the message delegate fornativeApp
.getTabDelegate
(WebExtension extension) Get the TabDelegate for the given extension.void
setActionDelegate
(WebExtension extension, WebExtension.ActionDelegate delegate) Set the Action delegate for this session.void
setMessageDelegate
(WebExtension webExtension, WebExtension.MessageDelegate delegate, String nativeApp) Defines a message delegate for a Native App.void
setTabDelegate
(WebExtension extension, WebExtension.SessionTabDelegate delegate) Set the TabDelegate for this session.
-
Method Details
-
setMessageDelegate
@AnyThread public void setMessageDelegate(@NonNull WebExtension webExtension, @Nullable WebExtension.MessageDelegate delegate, @NonNull String nativeApp) Defines a message delegate for a Native App.If a delegate is already present, this delegate will replace the existing one.
This message delegate will be responsible for handling messaging between a WebExtension content script running on the
GeckoSession
.Note: To receive messages from content scripts, the WebExtension needs to explicitely allow it in
WebExtension(org.mozilla.geckoview.WebExtension.DelegateControllerProvider, org.mozilla.gecko.util.GeckoBundle)
by settingWebExtension.Flags.ALLOW_CONTENT_MESSAGING
.- Parameters:
webExtension
-WebExtension
that this delegate receives messages from.delegate
-WebExtension.MessageDelegate
that will receive messages from this session.nativeApp
- which native app id this message delegate will handle messaging for.- See Also:
-
getMessageDelegate
@AnyThread @Nullable public WebExtension.MessageDelegate getMessageDelegate(@NonNull WebExtension extension, @NonNull String nativeApp) Get the message delegate fornativeApp
.- Parameters:
extension
-WebExtension
that this delegate receives messages from.nativeApp
- identifier for the native app- Returns:
- The
WebExtension.MessageDelegate
attached to thenativeApp
.null
if no delegate is present.
-
setActionDelegate
@AnyThread public void setActionDelegate(@NonNull WebExtension extension, @Nullable WebExtension.ActionDelegate delegate) Set the Action delegate for this session.This delegate will receive page and browser action overrides specific to this session. The default Action will be received by the delegate set by
WebExtension.setActionDelegate(org.mozilla.geckoview.WebExtension.ActionDelegate)
.- Parameters:
extension
- theWebExtension
object this delegate will receive updates fordelegate
- theWebExtension.ActionDelegate
that will receive updates.- See Also:
-
getActionDelegate
@AnyThread @Nullable public WebExtension.ActionDelegate getActionDelegate(@NonNull WebExtension extension) Get the Action delegate for this session.- Parameters:
extension
-WebExtension
that this delegates receive updates for.- Returns:
WebExtension.ActionDelegate
for this session
-
setTabDelegate
@AnyThread public void setTabDelegate(@NonNull WebExtension extension, @Nullable WebExtension.SessionTabDelegate delegate) Set the TabDelegate for this session.This delegate will receive messages specific for this session coming from the WebExtension
tabs
API.- Parameters:
extension
- theWebExtension
this delegate will receive updates fordelegate
- theWebExtension.TabDelegate
that will receive updates.- See Also:
-
getTabDelegate
@AnyThread @Nullable public WebExtension.SessionTabDelegate getTabDelegate(@NonNull WebExtension extension) Get the TabDelegate for the given extension.- Parameters:
extension
- theWebExtension
this delegate refers to.- Returns:
- the current
WebExtension.SessionTabDelegate
instance
-