webkitwebprocessextension.c.types

C types for webkitwebprocessextension6 library

Types 34

Enum values used to denote the various levels of console messages.

Info = 0Information message.
Log = 1Log message.
Warning = 2Warning message.
Error = 3Error message.
Debug = 4Debug message.

Enum values used to denote the various sources of console messages.

Javascript = 0Message produced by JavaScript.
Network = 1Network messages.
ConsoleApi = 2Messages produced by console API.
Security = 3Security messages.
Other = 4Other messages.

Enum values used to denote the stock actions for #WebKitContextMenuItem<!-- -->s

NoAction = 0No action, used by separator menu items.
OpenLink = 1Open current link.
OpenLinkInNewWindow = 2Open current link in a new window.
DownloadLinkToDisk = 3Download link destination.
CopyLinkToClipboard = 4Copy link location to the clipboard.
OpenImageInNewWindow = 5Open current image in a new window.
DownloadImageToDisk = 6Download current image.
CopyImageToClipboard = 7Copy current image to the clipboard.
CopyImageUrlToClipboard = 8Copy current image location to the clipboard.
OpenFrameInNewWindow = 9Open current frame in a new window.
GoBack = 10Load the previous history item.
GoForward = 11Load the next history item.
Stop = 12Stop any ongoing loading operation.
Reload = 13Reload the contents of current view.
Copy = 14Copy current selection the clipboard.
Cut = 15Cut current selection to the clipboard.
Paste = 16Paste clipboard contents.
Delete = 17Delete current selection.
SelectAll = 18Select all text.
InputMethods = 19Input methods menu.
Unicode = 20Unicode menu.
SpellingGuess = 21A proposed replacement for a misspelled word.
NoGuessesFound = 22An indicator that spellchecking found no proposed replacements.
IgnoreSpelling = 23Causes the spellchecker to ignore the word for this session.
LearnSpelling = 24Causes the spellchecker to add the word to the dictionary.
IgnoreGrammar = 25Ignore grammar.
FontMenu = 26Font options menu.
Bold = 27Bold.
Italic = 28Italic.
Underline = 29Underline.
Outline = 30Outline.
InspectElement = 31Open current element in the inspector.
OpenVideoInNewWindow = 32Open current video element in a new window.
OpenAudioInNewWindow = 33Open current audio element in a new window.
CopyVideoLinkToClipboard = 34Copy video link location in to the clipboard.
CopyAudioLinkToClipboard = 35Copy audio link location in to the clipboard.
ToggleMediaControls = 36Enable or disable media controls.
ToggleMediaLoop = 37Enable or disable media loop.
EnterVideoFullscreen = 38Show current video element in fullscreen mode.
MediaPlay = 39Play current media element.
MediaPause = 40Pause current media element.
MediaMute = 41Mute current media element.
DownloadVideoToDisk = 42Download video to disk. Since 2.2
DownloadAudioToDisk = 43Download audio to disk. Since 2.2
InsertEmoji = 44Insert an emoji. Since 2.26
PasteAsPlainText = 45Paste clipboard contents as plain text. Since 2.30
Custom = 10000Custom action defined by applications.

Enum values with flags representing the context of a #WebKitHitTestResult.

Document = 2anywhere in the document.
Link = 4a hyperlink element.
Image = 8an image element.
Media = 16a video or audio element.
Editable = 32an editable element
Scrollbar = 64a scrollbar element.
Selection = 128a selected element. Since 2.8

Enum values used to denote errors happening when sending user messages.

UserMessageUnhandledMessage = 0The message was not handled by the receiver.

Represents the context menu in a #WebKitWebView.

#WebKitContextMenu represents a context menu containing #WebKitContextMenuItem<!-- -->s in a #WebKitWebView.

When a #WebKitWebView is about to display the context menu, it emits the #WebKitWebView::context-menu signal, which has the #WebKitContextMenu as an argument. You can modify it, adding new submenus that you can create with [webkitwebprocessextension.context_menu.ContextMenu.new_], adding new #WebKitContextMenuItem<!-- -->s with [webkitwebprocessextension.context_menu.ContextMenu.prepend], [webkitwebprocessextension.context_menu.ContextMenu.append] or [webkitwebprocessextension.context_menu.ContextMenu.insert], maybe after having removed the existing ones with [webkitwebprocessextension.context_menu.ContextMenu.removeAll].

Fields
GObjectClass parentClass

One item of a #WebKitContextMenu.

The #WebKitContextMenu is composed of #WebKitContextMenuItem<!-- -->s. These items can be created from a #GtkAction, from a #WebKitContextMenuAction or from a #WebKitContextMenuAction and a label. These #WebKitContextMenuAction<!-- -->s denote stock actions for the items. You can also create separators and submenus.

A web page frame.

Each [webkitwebprocessextension.web_page.WebPage] has at least one main frame, and can have any number of subframes.

Fields
GObjectClass parentClass

Result of a Hit Test.

A Hit Test is an operation to get context information about a given point in a #WebKitWebView. #WebKitHitTestResult represents the result of a Hit Test. It provides context information about what is at the coordinates of the Hit Test, such as if there's a link, an image or a media.

You can get the context of the HitTestResult with [webkitwebprocessextension.hit_test_result.HitTestResult.getContext] that returns a bitmask of #WebKitHitTestResultContext flags. You can also use [webkitwebprocessextension.hit_test_result.HitTestResult.contextIsLink], [webkitwebprocessextension.hit_test_result.HitTestResult.contextIsImage] and [webkitwebprocessextension.hit_test_result.HitTestResult.contextIsMedia] to determine whether there's a link, image or a media element at the coordinates of the Hit Test. Note that it's possible that several #WebKitHitTestResultContext flags are active at the same time, for example if there's a link containing an image.

When the mouse is moved over a #WebKitWebView a Hit Test is performed for the mouse coordinates and #WebKitWebView::mouse-target-changed signal is emitted with a #WebKitHitTestResult.

Fields
GObjectClass parentClass
Fields
GObjectClass parentClass

Represents a URI request.

A #WebKitURIRequest can be created with a URI using the [webkitwebprocessextension.urirequest.URIRequest.new_] method, and you can get the URI of an existing request with the [webkitwebprocessextension.urirequest.URIRequest.getUri] one.

Fields
GObjectClass parentClass

Represents an URI response.

A #WebKitURIResponse contains information such as the URI, the status code, the content length, the mime type, the HTTP status or the suggested filename.

Fields
GObjectClass parentClass

Message that can be sent between the UI process and web process extensions.

A WebKitUserMessage is a message that can be used for the communication between the UI process and web process extensions. A WebKitUserMessage always has a name, and it can also include parameters and UNIX file descriptors. Messages can be sent from a #WebKitWebContext to all web process extensions, from a web process extension to its corresponding #WebKitWebContext, and from a #WebKitWebView to its corresponding #WebKitWebPage (and vice versa). One to one messages can be replied to directly with [webkitwebprocessextension.user_message.UserMessage.sendReply].

Access to editing capabilities of a #WebKitWebPage.

The WebKitWebEditor provides access to various editing capabilities of a #WebKitWebPage such as a possibility to react to the current selection in #WebKitWebPage.

Fields
GObjectClass parentClass

Form manager of a #WebKitWebPage in a #WebKitScriptWorld

Fields
GObject parent

Result of a Hit Test (Web Process Extensions).

WebKitWebHitTestResult extends #WebKitHitTestResult to provide information about the #WebKitDOMNode in the coordinates of the Hit Test.

A loaded web page.

Fields
GObjectClass parentClass

Represents an extension of the web process.

WebKitWebProcessExtension is a loadable module for the web process. It allows you to execute code in the web process and being able to use the DOM API, to change any request or to inject custom JavaScript code, for example.

To create a WebKitWebProcessExtension you should write a module with an initialization function that could be either webkit_web_process_extension_initialize() with prototype #WebKitWebProcessExtensionInitializeFunction or webkit_web_process_extension_initialize_with_user_data() with prototype #WebKitWebProcessExtensionInitializeWithUserDataFunction. This function has to be public and it has to use the #G_MODULE_EXPORT macro. It is called when the web process is initialized.

static void
web_page_created_callback (WebKitWebProcessExtension *extension,
                          WebKitWebPage             *web_page,
                          gpointer                   user_data)
{
   g_print ("Page %d created for %s\n",
            webkit_web_page_get_id (web_page),
            webkit_web_page_get_uri (web_page));
}

G_MODULE_EXPORT void
webkit_web_process_extension_initialize (WebKitWebProcessExtension *extension)
{
   g_signal_connect (extension, "page-created",
                     G_CALLBACK (web_page_created_callback),
                     NULL);
}

The previous piece of code shows a trivial example of an extension that notifies when a #WebKitWebPage is created.

WebKit has to know where it can find the created WebKitWebProcessExtension. To do so you should use the webkit_web_context_set_web_extensions_directory() function. The signal #WebKitWebContext::initialize-web-extensions is the recommended place to call it.

To provide the initialization data used by the webkit_web_process_extension_initialize_with_user_data() function, you have to call webkit_web_context_set_web_extensions_initialization_user_data() with the desired data as parameter. You can see an example of this in the following piece of code:

#define WEB_EXTENSIONS_DIRECTORY // ...

static void
initialize_web_extensions (WebKitWebContext *context,
                          gpointer          user_data)
{
 // Web Extensions get a different ID for each Web Process
 static guint32 unique_id = 0;

 webkit_web_context_set_web_extensions_directory (
    context, WEB_EXTENSIONS_DIRECTORY);
 webkit_web_context_set_web_extensions_initialization_user_data (
    context, g_variant_new_uint32 (unique_id++));
}

int main (int argc, char **argv)
{
 g_signal_connect (webkit_web_context_get_default (),
                  "initialize-web-extensions",
                   G_CALLBACK (initialize_web_extensions),
                   NULL);

 GtkWidget *view = webkit_web_view_new ();

 // ...
}