Class WebExtension
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents either a Browser Action or a Page Action from the WebExtension API.static interfaceReceives updates whenever a Browser action or a Page action has been defined by an extension.static @interfaceBlocklist state definitions for extensions.static classDescribes the blocklist state for aWebExtension.static interfaceThis delegate is used to handle calls from the |browsingData| WebExtension API.static @interfaceBrowsing data type definitions for extensions.static @interfaceContext flag definitions for menu items.static classProvides details about creating a tab withtabs.create.static classFlags indicating reasons why an extension is disabled.static classRepresents a download for downloads API Instantiate usingWebExtensionController.createDownload(int)static interfaceHandles download requests from WebExtensions.static classRepresents initial information on a download provided to Web Extensionstatic classRepresents Web Extension API specific download requeststatic @interfaceEnabled/disabled flag definitions for WebExtensions.static classFlags that can be used to configure WebExtension behavior.static classExtension thrown when an error occurs during extension installation.static classException thrown when GeckoView receives unexpected invalid WebExtension metadata from Gecko (e.g.static interfaceDelegates that responds to messages sent from a WebExtension.static classDescribes the sender of a message from a WebExtension.classProvides information about aWebExtension.static classHolds all the information which the user has submited as part of a confirmation of a permissions prompt request.static classPort object that can be used for bidirectional communication with a WebExtension.static interfaceDelegate that handles communication from a WebExtension on a specificWebExtension.Portinstance.static classController for WebExtension session-related APIs (tabs, browsingData, downloads, etc.).static interfaceThis delegate is invoked whenever an extension uses the `tabs` WebExtension API to modify the state of a tab.static @interfaceSigned state type definitions for WebExtension verification status.static classDescribes the signed status for aWebExtension.static interfaceThis delegate is invoked whenever an extension uses the `tabs` WebExtension API and the request is not specific to an existing tab, e.g.static classProvides details about upating a tab withtabs.update.static @interfaceDefines the valid flags that can be applied to a WebExtension. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe list of data collection permission names.final longWebExtension.Flagsfor this WebExtension.final StringUnique identifier for this WebExtensionfinal booleanWhether this extension is built-in.final Stringfile:orresource:URI that points to the install location of this WebExtension.final WebExtension.MetaDataProvides information about thisWebExtension. -
Method Summary
Modifier and TypeMethodDescriptionReturns the delegate handling browsing-data operations for this extension.Get the download delegate for this extension.Get the tab delegate for this extension.voidsetActionDelegate(WebExtension.ActionDelegate delegate) Set the Action delegate for this WebExtension.voidSets the delegate to handle browsing-data operations (clear, remove, get settings).voidSet the download delegate for this extension.voidsetMessageDelegate(WebExtension.MessageDelegate messageDelegate, String nativeApp) Defines the message delegate for a Native App.voidsetTabDelegate(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://androidalias. 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.Flagsfor 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). -
DATA_COLLECTION_PERMISSIONS
The list of data collection permission names.This list should be kept in sync with the WebExtensions JSON schema defined at the gecko toolkit level. It is made public so that upper Android layers can have access to a list of data collection permissions that is guaranteed to match the gecko one, which can be useful in tests for instance.
-
-
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.sendNativeMessageWebExtension 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.Portobject that can be used to send messages to the WebExtension. Note: thenativeAppspecified in the WebExtension needs to match thenativeAppparameter of this method.You can unset the message delegate by setting a
nullmessageDelegate.nativeApp- which native app id this message delegate will handle messaging for. Needs to match theapplicationparameter ofruntime.sendNativeMessageandruntime.connectNative.- See Also:
-
getTabDelegate
Get the tab delegate for this extension.See also WebExtensions/API/tabs.
- Returns:
- The
WebExtension.TabDelegateinstance 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.TabDelegateinstance for this extension.
-
getBrowsingDataDelegate
Returns the delegate handling browsing-data operations for this extension.- Returns:
- the current BrowsingDataDelegate, or null if none set
-
setBrowsingDataDelegate
Sets the delegate to handle browsing-data operations (clear, remove, get settings).- Parameters:
delegate- the BrowsingDataDelegate to receive browsing-data calls; may be null
-
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.ActionDelegatethat 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.DownloadDelegateinstance for this extension.
-
getDownloadDelegate
Get the download delegate for this extension.See also WebExtensions downloads API.
- Returns:
- The
WebExtension.DownloadDelegateinstance for this extension.
-