Class WebExtension
Represents a WebExtension.
A WebKitWebExtension object encapsulates a web extension’s
resources that are defined by a manifest.json file.
This class handles the reading and parsing of the manifest file along with the supporting resources like icons and localizations.
- Since:
- 2.52
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classWebExtension.Builder<B extends WebExtension.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface Initable
Initable.Initable$Impl, Initable.InitableIface -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new WebExtension.WebExtension(MemorySegment address) Create a WebExtension instance for the provided memory address.WebExtension(String extensionPath) Creates a new WebKitWebExtension from a folder containing the extension contents. -
Method Summary
Modifier and TypeMethodDescriptionprotected WebExtensionasParent()Return this instance as if it were its parent type.static WebExtension.Builder<? extends WebExtension.Builder> builder()AWebExtension.Builderobject constructs aWebExtensionwith the specified properties.@Nullable IcongetActionIcon(double width, double height) Returns the extension's default action icon image for the specified size.Get the set of websites that the extension requires access to for injected content and for receiving messages from websites.@Nullable StringGet the default locale for the extension.@Nullable StringGet the localized display action label for the extension.@Nullable StringGet the localized display description for the extension.@Nullable StringGet the localized name for the extension.@Nullable StringGet the localized short name for the extension.@Nullable StringGet the localized display version for the extension.booleanGet whether the extension has background content that can run when needed.booleanGet whether the extension includes commands that users can invoke.booleanGet whether the extension includes rules used for content modification or blocking.booleanGet whether the extension has script or stylesheet content that can be injected into webpages.booleanGet whether the extension has an options page.booleanGet whether the extension provides an alternative to the default new tab page.booleanGet whether the extension has background content that stays in memory as long as the extension is loaded.@Nullable IcongetIcon(double width, double height) Returns the extension's icon image for the specified size.doubleGet the parsed manifest version, or0if there is no version specified in the manifest.static MemoryLayoutThe memory layout of the native struct.Get the set of websites that the extension may need access to for optional functionality.@Nullable String @Nullable []Get the set of permissions that the extension may need for optional functionality.getPath()Get the path pointing to the folder containing the extension manifest and resourcesGet the set of websites that the extension requires access to for its base functionality.@Nullable String @Nullable []Get the set of permissions that the extension requires for its base functionality.static @Nullable TypegetType()Get the GType of the WebExtension class.@Nullable StringGet the version for the extension.booleansupportsManifestVersion(double manifestVersion) Checks if a manifest version is supported by the extension.Methods inherited from class GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
WebExtension
Create a WebExtension instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
WebExtension
Creates a new WebKitWebExtension from a folder containing the extension contents. The folder must contain amanifest.jsonfile. If the manifest is invalid or missing, an error will be returned.- Parameters:
extensionPath- A string pointing to the folder containing the extension manifest and resources- Throws:
GErrorException- seeGError- Since:
- 2.52
-
WebExtension
public WebExtension()Create a new WebExtension.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Return this instance as if it were its parent type. Comparable to the Javasuperkeyword, but ensures the parent typeclass is also used in native code. -
getActionIcon
Returns the extension's default action icon image for the specified size. This icon serves as a default and should be used to represent the extension in contexts like action sheets or toolbars prior to the extension being loaded into an extension context. Once the extension is loaded, use theactionForTab:API to get the tab-specific icon. The returned image will be the best match for the specified size that is available in the extension's action icon set. If no matching icon is available, the method will fall back to the extension's icon.- Parameters:
width- The width to use when looking up the icon.height- The height to use when looking up the icon.- Returns:
- the icon image, or
nullif no icon could be loaded. - Since:
- 2.52
-
getAllRequestedMatchPatterns
Get the set of websites that the extension requires access to for injected content and for receiving messages from websites.- Returns:
- a
null-terminated array of match patterns matching all requested websites. - Since:
- 2.52
-
getDefaultLocale
Get the default locale for the extension.- Returns:
- the default locale, or
nullif there was no default locale specified. - Since:
- 2.52
-
getDisplayActionLabel
Get the localized display action label for the extension.
This label serves as a default and should be used to represent the extension in contexts like action sheets or toolbars prior to the extension being loaded into an extension context. Once the extension is loaded, use the
actionForTab:API to get the tab-specific label.- Returns:
- the localized display action label, or
nullif there was no display action label specified. - Since:
- 2.52
-
getDisplayDescription
Get the localized display description for the extension.- Returns:
- the localized display description, or
nullif there was no display description specified. - Since:
- 2.52
-
getDisplayName
Get the localized name for the extension.- Returns:
- the localized name, or
nullif there was no name specified. - Since:
- 2.52
-
getDisplayShortName
Get the localized short name for the extension.- Returns:
- the localized name, or
nullif there was no short name specified. - Since:
- 2.52
-
getDisplayVersion
Get the localized display version for the extension.- Returns:
- the localized display version, or
nullif there was no display version specified. - Since:
- 2.52
-
getHasBackgroundContent
public boolean getHasBackgroundContent()Get whether the extension has background content that can run when needed.- Returns:
TRUEif the extension can run in the background even when no webpages are open.- Since:
- 2.52
-
getHasCommands
public boolean getHasCommands()Get whether the extension includes commands that users can invoke.
These commands should be accessible via keyboard shortcuts, menu items, or other user interface elements provided by the app. The list of commands can be accessed via
commandson an extension context, and invoked viaperformCommand:.- Returns:
TRUEif the extension contains one or more commands that can be performed by the user.- Since:
- 2.52
-
getHasContentModificationRules
public boolean getHasContentModificationRules()Get whether the extension includes rules used for content modification or blocking.- Returns:
TRUEif the extension contains one or more rules for content modification.- Since:
- 2.52
-
getHasInjectedContent
public boolean getHasInjectedContent()Get whether the extension has script or stylesheet content that can be injected into webpages.
Once the extension is loaded, use the
hasInjectedContentproperty on an extension context, as the injectable content can change after the extension is loaded.- Returns:
TRUEif the extension has content that can be injected by matching against the extension's requested match patterns.- Since:
- 2.52
-
getHasOptionsPage
public boolean getHasOptionsPage()Get whether the extension has an options page.
The app should provide access to this page through a user interface element, which can be accessed via
optionsPageURLon an extension context.- Returns:
TRUEif the extension includes a dedicated options page where users can customize settings.- Since:
- 2.52
-
getHasOverrideNewTabPage
public boolean getHasOverrideNewTabPage()Get whether the extension provides an alternative to the default new tab page.
The app should prompt the user for permission to use the extension's new tab page as the default, which can be accessed via
overrideNewTabPageURLon an extension context.- Returns:
TRUEif the extension can specify a custom page that can be displayed when a new tab is opened in the app, instead of the default new tab page.- Since:
- 2.52
-
getHasPersistentBackgroundContent
public boolean getHasPersistentBackgroundContent()Get whether the extension has background content that stays in memory as long as the extension is loaded.- Returns:
TRUEif the extension can run in the background.- Since:
- 2.52
-
getIcon
Returns the extension's icon image for the specified size. This icon should represent the extension in settings or other areas that show the extension. The returned image will be the best match for the specified size that is available in the extension's icon set. If no matching icon can be found, the method will returnnull.- Parameters:
width- The width to use when looking up the icon.height- The height to use when looking up the icon.- Returns:
- the icon image, or
nullif no icon could be loaded. - Since:
- 2.52
-
getManifestVersion
public double getManifestVersion()Get the parsed manifest version, or
0if there is no version specified in the manifest.A
WebKit.WebExtensionError.UNSUPPORTED_MANIFEST_VERSIONerror will be reported if the manifest version isn't specified.- Returns:
- the parsed manifest version.
- Since:
- 2.52
-
getOptionalPermissionMatchPatterns
Get the set of websites that the extension may need access to for optional functionality. These match patterns can be requested by the extension at a later time.- Returns:
- a
null-terminated array of match patterns matching the optional websites. - Since:
- 2.52
-
getOptionalPermissions
Get the set of permissions that the extension may need for optional functionality. These permissions can be requested by the extension at a later time.- Returns:
- a
null-terminated array of strings containing permission names, ornullotherwise. This array and its contents are owned by WebKit and should not be modified or freed. - Since:
- 2.52
-
getPath
Get the path pointing to the folder containing the extension manifest and resources- Returns:
- the path of the extension folder
- Since:
- 2.52
-
getRequestedPermissionMatchPatterns
Get the set of websites that the extension requires access to for its base functionality.- Returns:
- a
null-terminated array of match patterns matching the required websites. - Since:
- 2.52
-
getRequestedPermissions
Get the set of permissions that the extension requires for its base functionality.- Returns:
- a
null-terminated array of strings containing permission names, ornullotherwise. This array and its contents are owned by WebKit and should not be modified or freed. - Since:
- 2.52
-
getVersion
Get the version for the extension.- Returns:
- the version, or
nullif there was no version specified. - Since:
- 2.52
-
supportsManifestVersion
public boolean supportsManifestVersion(double manifestVersion) Checks if a manifest version is supported by the extension.- Parameters:
manifestVersion- the version number to check- Returns:
TRUEif the extension specified a manifest version that is greater than or equal tomanifestVersion.- Since:
- 2.52
-
builder
AWebExtension.Builderobject constructs aWebExtensionwith the specified properties. Use the variousset...()methods to set properties, and finish construction withWebExtension.Builder.build().- Returns:
- the builder object
-