Class WebExtension
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Represents either a Browser Action or a Page Action from the WebExtension API.static interface
Receives updates whenever a Browser action or a Page action has been defined by an extension.static @interface
static class
Describes the blocklist state for aWebExtension
.static interface
This delegate is used to handle calls from the |browsingData| WebExtension API.static @interface
static @interface
static class
Provides details about creating a tab withtabs.create
.static class
static class
Represents a download for downloads API Instantiate usingWebExtensionController.createDownload(int)
static interface
static class
Represents initial information on a download provided to Web Extensionstatic class
Represents Web Extension API specific download requeststatic @interface
static class
static class
Extension thrown when an error occurs during extension installation.static interface
Delegates that responds to messages sent from a WebExtension.static class
Describes the sender of a message from a WebExtension.class
Provides information about aWebExtension
.static class
Port object that can be used for bidirectional communication with a WebExtension.static interface
Delegate that handles communication from a WebExtension on a specificWebExtension.Port
instance.static class
static interface
This delegate is invoked whenever an extension uses the `tabs` WebExtension API to modify the state of a tab.static @interface
static class
Describes the signed status for aWebExtension
.static interface
This delegate is invoked whenever an extension uses the `tabs` WebExtension API and the request is not specific to an existing tab, e.g.static class
Provides details about upating a tab withtabs.update
.static @interface
-
Field Summary
Modifier and TypeFieldDescriptionfinal long
WebExtension.Flags
for this WebExtension.final String
Unique identifier for this WebExtensionfinal boolean
Whether this extension is built-in.final String
file:
orresource:
URI that points to the install location of this WebExtension.final WebExtension.MetaData
Provides information about thisWebExtension
. -
Method Summary
Modifier and TypeMethodDescriptionGet the download delegate for this extension.Get the tab delegate for this extension.void
setActionDelegate
(WebExtension.ActionDelegate delegate) Set the Action delegate for this WebExtension.void
void
Set the download delegate for this extension.void
setMessageDelegate
(WebExtension.MessageDelegate messageDelegate, String nativeApp) Defines the message delegate for a Native App.void
setTabDelegate
(WebExtension.TabDelegate delegate) Set the tab delegate for this extension.toString()
-
Field Details
-
location
file:
orresource:
URI that points to the install location of this WebExtension. When the WebExtension is included with the APK the file can be specified using theresource://android
alias. E.g.
Will point to folderresource://android/assets/web_extensions/my_webextension/
/assets/web_extensions/my_webextension/
in the APK. -
id
Unique identifier for this WebExtension -
flags
public final long flagsWebExtension.Flags
for this WebExtension. -
metaData
Provides information about thisWebExtension
. -
isBuiltIn
public final boolean isBuiltInWhether this extension is built-in. Built-in extension can be installed usingWebExtensionController.installBuiltIn(java.lang.String)
.
-
-
Method Details
-
toString
-
setMessageDelegate
@UiThread public void setMessageDelegate(@Nullable WebExtension.MessageDelegate messageDelegate, @NonNull String nativeApp) Defines the message delegate for a Native App.This message delegate will receive messages from the background script for the native app specified in
nativeApp
.For messages from content scripts, set a session-specific message delegate using
WebExtension.SessionController.setMessageDelegate(org.mozilla.geckoview.WebExtension, org.mozilla.geckoview.WebExtension.MessageDelegate, java.lang.String)
.See also WebExtensions/Native_messaging
- Parameters:
messageDelegate
- handles messaging between the WebExtension and the app. To send a message from the WebExtension use theruntime.sendNativeMessage
WebExtension API: E.g.
For bidirectional communication, usebrowser.runtime.sendNativeMessage(nativeApp, {message: "Hello from WebExtension!"});
runtime.connectNative
. E.g. in a content script:
The code above will trigger alet port = browser.runtime.connectNative(nativeApp); port.onMessage.addListener(message => { console.log("Message received from app"); }); port.postMessage("Ping from WebExtension");
WebExtension.MessageDelegate.onConnect(org.mozilla.geckoview.WebExtension.Port)
call that will contain the correspondingWebExtension.Port
object that can be used to send messages to the WebExtension. Note: thenativeApp
specified in the WebExtension needs to match thenativeApp
parameter of this method.You can unset the message delegate by setting a
null
messageDelegate.nativeApp
- which native app id this message delegate will handle messaging for. Needs to match theapplication
parameter ofruntime.sendNativeMessage
andruntime.connectNative
.- See Also:
-
getTabDelegate
Get the tab delegate for this extension.See also WebExtensions/API/tabs.
- Returns:
- The
WebExtension.TabDelegate
instance for this extension.
-
setTabDelegate
Set the tab delegate for this extension. This delegate will be invoked whenever this extension tries to modify the tabs state using the `tabs` WebExtension API.See also WebExtensions/API/tabs.
- Parameters:
delegate
- theWebExtension.TabDelegate
instance for this extension.
-
getBrowsingDataDelegate
-
setBrowsingDataDelegate
-
setActionDelegate
Set the Action delegate for this WebExtension.This delegate will receive updates every time the default Action value changes.
To listen for
GeckoSession
-specific updates, useWebExtension.SessionController.setActionDelegate(org.mozilla.geckoview.WebExtension, org.mozilla.geckoview.WebExtension.ActionDelegate)
- Parameters:
delegate
-WebExtension.ActionDelegate
that will receive updates.
-
setDownloadDelegate
Set the download delegate for this extension. This delegate will be invoked whenever this extension tries to use the `downloads` WebExtension API.See also WebExtensions/API/downloads.
- Parameters:
delegate
- theWebExtension.DownloadDelegate
instance for this extension.
-
getDownloadDelegate
Get the download delegate for this extension.See also WebExtensions downloads API.
- Returns:
- The
WebExtension.DownloadDelegate
instance for this extension.
-