WebKit.WebExtension

g GObject.GInterface GObject.GInterface Gio.Initable Gio.Initable GObject.GInterface->Gio.Initable GObject.Object GObject.Object WebKit.WebExtension WebKit.WebExtension GObject.Object->WebKit.WebExtension Gio.Initable->WebKit.WebExtension

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.Initable (2)

Structs:

GObject.ObjectClass (5)

class

new (extension_path)

get_action_icon (width, height)

get_all_requested_match_patterns ()

get_default_locale ()

get_display_action_label ()

get_display_description ()

get_display_name ()

get_display_short_name ()

get_display_version ()

get_has_background_content ()

get_has_commands ()

get_has_content_modification_rules ()

get_has_injected_content ()

get_has_options_page ()

get_has_override_new_tab_page ()

get_has_persistent_background_content ()

get_icon (width, height)

get_manifest_version ()

get_optional_permission_match_patterns ()

get_optional_permissions ()

get_path ()

get_requested_permission_match_patterns ()

get_requested_permissions ()

get_version ()

supports_manifest_version (manifest_version)

Virtual Methods

Inherited:

GObject.Object (7), Gio.Initable (1)

Properties

Name

Type

Flags

Short Description

default-locale

str

r

display-action-label

str

r

display-description

str

r

display-name

str

r

display-short-name

str

r

display-version

str

r

has-background-content

bool

r

has-commands

bool

r

has-content-modification-rules

bool

r

has-injected-content

bool

r

has-options-page

bool

r

has-override-new-tab-page

bool

r

has-persistent-background-content

bool

r

manifest-version

str

r

optional-permissions

[str]

r

path

str

r/w/co

requested-permissions

[str]

r

version

str

r

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class WebKit.WebExtension(**kwargs)
Bases:

GObject.Object, Gio.Initable

Abstract:

No

Structure:

WebKit.WebExtensionClass

Represents a WebExtension.

A WebKit.WebExtension 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.

New in version 2.52.

classmethod new(extension_path)
Parameters:

extension_path (str) – A string pointing to the folder containing the extension manifest and resources

Raises:

GLib.Error

Returns:

the new WebKit.WebExtension, or None if the extension failed to be created

Return type:

WebKit.WebExtension or None

Creates a new WebKit.WebExtension from a folder containing the extension contents. The folder must contain a manifest.json file. If the manifest is invalid or missing, an error will be returned.

New in version 2.52.

get_action_icon(width, height)
Parameters:
  • width (float) – The width to use when looking up the icon.

  • height (float) – The height to use when looking up the icon.

Returns:

the icon image, or None if no icon could be loaded.

Return type:

Gio.Icon or None

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 the actionForTab: 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.

New in version 2.52.

get_all_requested_match_patterns()
Returns:

a None-terminated array of match patterns matching all requested websites.

Return type:

[WebKit.WebExtensionMatchPattern]

Get the set of websites that the extension requires access to for injected content and for receiving messages from websites.

New in version 2.52.

get_default_locale()
Returns:

the default locale, or None if there was no default locale specified.

Return type:

str or None

Get the default locale for the extension.

New in version 2.52.

get_display_action_label()
Returns:

the localized display action label, or None if there was no display action label specified.

Return type:

str or None

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.

New in version 2.52.

get_display_description()
Returns:

the localized display description, or None if there was no display description specified.

Return type:

str or None

Get the localized display description for the extension.

New in version 2.52.

get_display_name()
Returns:

the localized name, or None if there was no name specified.

Return type:

str or None

Get the localized name for the extension.

New in version 2.52.

get_display_short_name()
Returns:

the localized name, or None if there was no short name specified.

Return type:

str or None

Get the localized short name for the extension.

New in version 2.52.

get_display_version()
Returns:

the localized display version, or None if there was no display version specified.

Return type:

str or None

Get the localized display version for the extension.

New in version 2.52.

get_has_background_content()
Returns:

TRUE if the extension can run in the background even when no webpages are open.

Return type:

bool

Get whether the extension has background content that can run when needed.

New in version 2.52.

get_has_commands()
Returns:

TRUE if the extension contains one or more commands that can be performed by the user.

Return type:

bool

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 commands on an extension context, and invoked via performCommand:.

New in version 2.52.

get_has_content_modification_rules()
Returns:

TRUE if the extension contains one or more rules for content modification.

Return type:

bool

Get whether the extension includes rules used for content modification or blocking.

New in version 2.52.

get_has_injected_content()
Returns:

TRUE if the extension has content that can be injected by matching against the extension’s requested match patterns.

Return type:

bool

Get whether the extension has script or stylesheet content that can be injected into webpages.

Once the extension is loaded, use the hasInjectedContent property on an extension context, as the injectable content can change after the extension is loaded.

New in version 2.52.

get_has_options_page()
Returns:

TRUE if the extension includes a dedicated options page where users can customize settings.

Return type:

bool

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 optionsPageURL on an extension context.

New in version 2.52.

get_has_override_new_tab_page()
Returns:

TRUE if 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.

Return type:

bool

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 overrideNewTabPageURL on an extension context.

New in version 2.52.

get_has_persistent_background_content()
Returns:

TRUE if the extension can run in the background.

Return type:

bool

Get whether the extension has background content that stays in memory as long as the extension is loaded.

New in version 2.52.

get_icon(width, height)
Parameters:
  • width (float) – The width to use when looking up the icon.

  • height (float) – The height to use when looking up the icon.

Returns:

the icon image, or None if no icon could be loaded.

Return type:

Gio.Icon or None

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 return None.

New in version 2.52.

get_manifest_version()
Returns:

the parsed manifest version.

Return type:

float

Get the parsed manifest version, or 0 if there is no version specified in the manifest.

A [error`WebKit`.WebExtensionError.UNSUPPORTED_MANIFEST_VERSION] error will be reported if the manifest version isn’t specified.

New in version 2.52.

get_optional_permission_match_patterns()
Returns:

a None-terminated array of match patterns matching the optional websites.

Return type:

[WebKit.WebExtensionMatchPattern]

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.

New in version 2.52.

get_optional_permissions()
Returns:

a None-terminated array of strings containing permission names, or None otherwise. This array and its contents are owned by WebKit and should not be modified or freed.

Return type:

[str] or None

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.

New in version 2.52.

get_path()
Returns:

the path of the extension folder

Return type:

str

Get the path pointing to the folder containing the extension manifest and resources

New in version 2.52.

get_requested_permission_match_patterns()
Returns:

a None-terminated array of match patterns matching the required websites.

Return type:

[WebKit.WebExtensionMatchPattern]

Get the set of websites that the extension requires access to for its base functionality.

New in version 2.52.

get_requested_permissions()
Returns:

a None-terminated array of strings containing permission names, or None otherwise. This array and its contents are owned by WebKit and should not be modified or freed.

Return type:

[str] or None

Get the set of permissions that the extension requires for its base functionality.

New in version 2.52.

get_version()
Returns:

the version, or None if there was no version specified.

Return type:

str or None

Get the version for the extension.

New in version 2.52.

supports_manifest_version(manifest_version)
Parameters:

manifest_version (float) – the version number to check

Returns:

TRUE if the extension specified a manifest version that is greater than or equal to manifest_version.

Return type:

bool

Checks if a manifest version is supported by the extension.

New in version 2.52.

Property Details

WebKit.WebExtension.props.default_locale
Name:

default-locale

Type:

str

Default Value:

None

Flags:

READABLE

The default locale for the WebKit.WebExtension. See WebKit.WebExtension.get_default_locale() for more details.

New in version 2.52.

WebKit.WebExtension.props.display_action_label
Name:

display-action-label

Type:

str

Default Value:

None

Flags:

READABLE

The localized extension action label of the WebKit.WebExtension. See WebKit.WebExtension.get_display_action_label() for more details.

New in version 2.52.

WebKit.WebExtension.props.display_description
Name:

display-description

Type:

str

Default Value:

None

Flags:

READABLE

The localized description of the WebKit.WebExtension. See WebKit.WebExtension.get_display_description() for more details.

New in version 2.52.

WebKit.WebExtension.props.display_name
Name:

display-name

Type:

str

Default Value:

None

Flags:

READABLE

The localized name of the WebKit.WebExtension. See WebKit.WebExtension.get_display_name() for more details.

New in version 2.52.

WebKit.WebExtension.props.display_short_name
Name:

display-short-name

Type:

str

Default Value:

None

Flags:

READABLE

The localized short name of the WebKit.WebExtension. See WebKit.WebExtension.get_display_short_name() for more details.

New in version 2.52.

WebKit.WebExtension.props.display_version
Name:

display-version

Type:

str

Default Value:

None

Flags:

READABLE

The localized display version of the WebKit.WebExtension. See WebKit.WebExtension.get_display_version() for more details.

New in version 2.52.

WebKit.WebExtension.props.has_background_content
Name:

has-background-content

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the WebKit.WebExtension has background content that can run when needed. See WebKit.WebExtension.get_has_background_content() for more details.

New in version 2.52.

WebKit.WebExtension.props.has_commands
Name:

has-commands

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the WebKit.WebExtension includes commands that users can invoke. See WebKit.WebExtension.get_has_commands() for more details.

New in version 2.52.

WebKit.WebExtension.props.has_content_modification_rules
Name:

has-content-modification-rules

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the WebKit.WebExtension includes rules used for content modification or blocking. See webkit_web_extension_get_content_modification_rules() for more details.

New in version 2.52.

WebKit.WebExtension.props.has_injected_content
Name:

has-injected-content

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the WebKit.WebExtension has script or stylesheet content that can be injected into webpages. See WebKit.WebExtension.get_has_injected_content() for more details.

New in version 2.52.

WebKit.WebExtension.props.has_options_page
Name:

has-options-page

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the WebKit.WebExtension has an options page. See WebKit.WebExtension.get_has_options_page() for more details.

New in version 2.52.

WebKit.WebExtension.props.has_override_new_tab_page
Name:

has-override-new-tab-page

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the WebKit.WebExtension provides an alternative to the default new tab page. See WebKit.WebExtension.get_has_override_new_tab_page() for more details.

New in version 2.52.

WebKit.WebExtension.props.has_persistent_background_content
Name:

has-persistent-background-content

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the WebKit.WebExtension has background content that stays in memory as long as the extension is loaded. See WebKit.WebExtension.get_has_persistent_background_content() for more details.

New in version 2.52.

WebKit.WebExtension.props.manifest_version
Name:

manifest-version

Type:

str

Default Value:

None

Flags:

READABLE

The parsed manifest version of the WebKit.WebExtension. See WebKit.WebExtension.get_manifest_version() for more details.

New in version 2.52.

WebKit.WebExtension.props.optional_permissions
Name:

optional-permissions

Type:

[str]

Default Value:

[]

Flags:

READABLE

The set of permissions that the WebKit.WebExtension may need for optional functionality. See WebKit.WebExtension.get_optional_permissions() for more details.

New in version 2.52.

WebKit.WebExtension.props.path
Name:

path

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

A string pointing to the folder containing the extension manifest and resources. See WebKit.WebExtension.get_path() for more details.

New in version 2.52.

WebKit.WebExtension.props.requested_permissions
Name:

requested-permissions

Type:

[str]

Default Value:

[]

Flags:

READABLE

The set of permissions that the WebKit.WebExtension requires for its base functionality. See WebKit.WebExtension.get_requested_permissions() for more details.

New in version 2.52.

WebKit.WebExtension.props.version
Name:

version

Type:

str

Default Value:

None

Flags:

READABLE

The version of the WebKit.WebExtension. See WebKit.WebExtension.get_version() for more details.

New in version 2.52.