WebKit2.WebView

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Buildable->Gtk.Widget Gtk.Container Gtk.Container WebKit2.WebViewBase WebKit2.WebViewBase Gtk.Container->WebKit2.WebViewBase Gtk.Widget->Gtk.Container WebKit2.WebView WebKit2.WebView WebKit2.WebViewBase->WebKit2.WebView

Subclasses:

None

Methods

Inherited:

Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)

Structs:

Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)

class

new ()

class

new_with_context (context)

class

new_with_related_view (web_view)

class

new_with_settings (settings)

class

new_with_user_content_manager (user_content_manager)

call_async_javascript_function (body, length, arguments, world_name, source_uri, cancellable, callback, *user_data)

call_async_javascript_function_finish (result)

can_execute_editing_command (command, cancellable, callback, *user_data)

can_execute_editing_command_finish (result)

can_go_back ()

can_go_forward ()

can_show_mime_type (mime_type)

download_uri (uri)

evaluate_javascript (script, length, world_name, source_uri, cancellable, callback, *user_data)

evaluate_javascript_finish (result)

execute_editing_command (command)

execute_editing_command_with_argument (command, argument)

get_automation_presentation_type ()

get_back_forward_list ()

get_background_color ()

get_camera_capture_state ()

get_context ()

get_custom_charset ()

get_default_content_security_policy ()

get_display_capture_state ()

get_editor_state ()

get_estimated_load_progress ()

get_favicon ()

get_find_controller ()

get_input_method_context ()

get_inspector ()

get_is_muted ()

get_is_web_process_responsive ()

get_main_resource ()

get_microphone_capture_state ()

get_page_id ()

get_session_state ()

get_settings ()

get_snapshot (region, options, cancellable, callback, *user_data)

get_snapshot_finish (result)

get_title ()

get_tls_info ()

get_uri ()

get_user_content_manager ()

get_web_extension_mode ()

get_website_data_manager ()

get_website_policies ()

get_window_properties ()

get_zoom_level ()

go_back ()

go_forward ()

go_to_back_forward_list_item (list_item)

is_controlled_by_automation ()

is_editable ()

is_ephemeral ()

is_loading ()

is_playing_audio ()

load_alternate_html (content, content_uri, base_uri)

load_bytes (bytes, mime_type, encoding, base_uri)

load_html (content, base_uri)

load_plain_text (plain_text)

load_request (request)

load_uri (uri)

reload ()

reload_bypass_cache ()

restore_session_state (state)

run_async_javascript_function_in_world (body, arguments, world_name, cancellable, callback, *user_data)

run_javascript (script, cancellable, callback, *user_data)

run_javascript_finish (result)

run_javascript_from_gresource (resource, cancellable, callback, *user_data)

run_javascript_from_gresource_finish (result)

run_javascript_in_world (script, world_name, cancellable, callback, *user_data)

run_javascript_in_world_finish (result)

save (save_mode, cancellable, callback, *user_data)

save_finish (result)

save_to_file (file, save_mode, cancellable, callback, *user_data)

save_to_file_finish (result)

send_message_to_page (message, cancellable, callback, *user_data)

send_message_to_page_finish (result)

set_background_color (rgba)

set_camera_capture_state (state)

set_cors_allowlist (allowlist)

set_custom_charset (charset)

set_display_capture_state (state)

set_editable (editable)

set_input_method_context (context)

set_is_muted (muted)

set_microphone_capture_state (state)

set_settings (settings)

set_zoom_level (zoom_level)

stop_loading ()

terminate_web_process ()

try_close ()

Virtual Methods

Inherited:

Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10)

do_authenticate (request)

do_close ()

do_context_menu (context_menu, event, hit_test_result)

do_context_menu_dismissed ()

do_decide_policy (decision, type)

do_enter_fullscreen ()

do_insecure_content_detected (event)

do_leave_fullscreen ()

do_load_changed (load_event)

do_load_failed (load_event, failing_uri, error)

do_load_failed_with_tls_errors (failing_uri, certificate, errors)

do_mouse_target_changed (hit_test_result, modifiers)

do_permission_request (permission_request)

do_print_ (print_operation)

do_query_permission_state (query)

do_ready_to_show ()

do_resource_load_started (resource, request)

do_run_as_modal ()

do_run_color_chooser (request)

do_run_file_chooser (request)

do_script_dialog (dialog)

do_show_notification (notification)

do_show_option_menu (menu, event, rectangle)

do_submit_form (request)

do_user_message_received (message)

do_web_process_crashed ()

do_web_process_terminated (reason)

Properties

Inherited:

Gtk.Container (3), Gtk.Widget (39)

Name

Type

Flags

Short Description

automation-presentation-type

WebKit2.AutomationBrowsingContextPresentation

r/w/co

camera-capture-state

WebKit2.MediaCaptureState

r/w

default-content-security-policy

str

r/w/co

display-capture-state

WebKit2.MediaCaptureState

r/w

editable

bool

r/w

estimated-load-progress

float

r

favicon

int

r

is-controlled-by-automation

bool

r/w/co

is-ephemeral

bool

r/w/co

is-loading

bool

r

is-muted

bool

r/w

is-playing-audio

bool

r

is-web-process-responsive

bool

r

microphone-capture-state

WebKit2.MediaCaptureState

r/w

page-id

int

r

related-view

WebKit2.WebView

w/co

settings

WebKit2.Settings

w/c

title

str

r

uri

str

r

user-content-manager

WebKit2.UserContentManager

r/w/co

web-context

WebKit2.WebContext

r/w/co

web-extension-mode

WebKit2.WebExtensionMode

r/w/co

website-policies

WebKit2.WebsitePolicies

r/w/co

zoom-level

float

r/w

Style Properties

Inherited:

Gtk.Widget (17)

Signals

Inherited:

Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)

Name

Short Description

authenticate

This signal is emitted when the user is challenged with HTTP authentication.

close

Emitted when closing a WebKit2.WebView is requested.

context-menu

Emitted when a context menu is about to be displayed to give the application a chance to customize the proposed menu, prevent the menu from being displayed, or build its own context menu.

context-menu-dismissed

Emitted after WebKit2.WebView ::context-menu signal, if the context menu is shown, to notify that the context menu is dismissed.

create

Emitted when the creation of a new WebKit2.WebView is requested.

decide-policy

This signal is emitted when WebKit is requesting the client to decide a policy decision, such as whether to navigate to a page, open a new window or whether or not to download a resource.

enter-fullscreen

Emitted when JavaScript code calls element.webkitRequestFullScreen.

insecure-content-detected

This signal is emitted when insecure content has been detected in a page loaded through a secure connection.

leave-fullscreen

Emitted when the WebKit2.WebView is about to restore its top level window out of its full screen state.

load-changed

Emitted when a load operation in web_view changes.

load-failed

Emitted when an error occurs during a load operation.

load-failed-with-tls-errors

Emitted when a TLS error occurs during a load operation.

mouse-target-changed

This signal is emitted when the mouse cursor moves over an element such as a link, image or a media element.

permission-request

This signal is emitted when WebKit is requesting the client to decide about a permission request, such as allowing the browser to switch to fullscreen mode, sharing its location or similar operations.

print

Emitted when printing is requested on web_view, usually by a JavaScript call, before the print dialog is shown.

query-permission-state

This signal allows the User-Agent to respond to permission requests for powerful features, as specified by the Permissions W3C Specification.

ready-to-show

Emitted after WebKit2.WebView ::create on the newly created WebKit2.WebView when it should be displayed to the user.

resource-load-started

Emitted when a new resource is going to be loaded.

run-as-modal

Emitted after WebKit2.WebView ::ready-to-show on the newly created WebKit2.WebView when JavaScript code calls window.showModalDialog.

run-color-chooser

This signal is emitted when the user interacts with a HTML element, requesting from WebKit to show a dialog to select a color.

run-file-chooser

This signal is emitted when the user interacts with a HTML element, requesting from WebKit to show a dialog to select one or more files to be uploaded.

script-dialog

Emitted when JavaScript code calls window.alert, window.confirm or window.prompt, or when onbeforeunload event is fired.

show-notification

This signal is emitted when a notification should be presented to the user.

show-option-menu

This signal is emitted when a select element in web_view needs to display a dropdown menu.

submit-form

This signal is emitted when a form is about to be submitted.

user-message-received

This signal is emitted when a WebKit2.UserMessage is received from the #WebKitWebPage corresponding to web_view.

web-process-crashed

This signal is emitted when the web process crashes. deprecated

web-process-terminated

This signal is emitted when the web process terminates abnormally due to reason.

Fields

Inherited:

Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)

Name

Type

Access

Description

parent

WebKit2.WebViewBase

r

Class Details

class WebKit2.WebView(**kwargs)
Bases:

WebKit2.WebViewBase

Abstract:

No

Structure:

WebKit2.WebViewClass

The central class of the WPE WebKit and WebKitGTK APIs.

WebKit2.WebView is the central class of the WPE WebKit and WebKitGTK APIs. It is responsible for managing the drawing of the content and forwarding of events. You can load any URI into the WebKit2.WebView or a data string. With WebKit2.Settings you can control various aspects of the rendering and loading of the content.

Note that in WebKitGTK, WebKit2.WebView is scrollable by itself, so you don’t need to embed it in a Gtk.ScrolledWindow.

classmethod new()
Returns:

The newly created WebKit2.WebView widget

Return type:

Gtk.Widget

Creates a new WebKit2.WebView with the default WebKit2.WebContext.

Creates a new WebKit2.WebView with the default WebKit2.WebContext and no WebKit2.UserContentManager associated with it. See also WebKit2.WebView.new_with_context(), WebKit2.WebView.new_with_user_content_manager(), and WebKit2.WebView.new_with_settings().

classmethod new_with_context(context)
Parameters:

context (WebKit2.WebContext) – the WebKit2.WebContext to be used by the WebKit2.WebView

Returns:

The newly created WebKit2.WebView widget

Return type:

Gtk.Widget

Creates a new WebKit2.WebView with the given WebKit2.WebContext.

Creates a new WebKit2.WebView with the given WebKit2.WebContext and no WebKit2.UserContentManager associated with it. See also WebKit2.WebView.new_with_user_content_manager() and WebKit2.WebView.new_with_settings().

Parameters:

web_view (WebKit2.WebView) – the related WebKit2.WebView

Returns:

The newly created WebKit2.WebView widget

Return type:

Gtk.Widget

Creates a new WebKit2.WebView sharing the same web process with web_view.

This method doesn’t have any effect when WebKit2.ProcessModel.SHARED_SECONDARY_PROCESS process model is used, because a single web process is shared for all the web views in the same WebKit2.WebContext. When using WebKit2.ProcessModel.MULTIPLE_SECONDARY_PROCESSES process model, this method should always be used when creating the WebKit2.WebView in the WebKit2.WebView ::create signal. You can also use this method to implement other process models based on WebKit2.ProcessModel.MULTIPLE_SECONDARY_PROCESSES, like for example, sharing the same web process for all the views in the same security domain.

The newly created WebKit2.WebView will also have the same WebKit2.UserContentManager, WebKit2.Settings, and WebKit2.WebsitePolicies as web_view.

New in version 2.4.

classmethod new_with_settings(settings)
Parameters:

settings (WebKit2.Settings) – a WebKit2.Settings

Returns:

The newly created WebKit2.WebView widget

Return type:

Gtk.Widget

Creates a new WebKit2.WebView with the given WebKit2.Settings.

See also WebKit2.WebView.new_with_context(), and WebKit2.WebView.new_with_user_content_manager().

New in version 2.6.

classmethod new_with_user_content_manager(user_content_manager)
Parameters:

user_content_manager (WebKit2.UserContentManager) – a WebKit2.UserContentManager.

Returns:

The newly created WebKit2.WebView widget

Return type:

Gtk.Widget

Creates a new WebKit2.WebView with the given WebKit2.UserContentManager.

The content loaded in the view may be affected by the content injected in the view by the user content manager.

New in version 2.6.

call_async_javascript_function(body, length, arguments, world_name, source_uri, cancellable, callback, *user_data)
Parameters:

Asynchronously call body with arguments in the script world with name world_name of the main frame current context in self. The arguments values must be one of the following types, or contain only the following GLib.Variant types: number, string and dictionary. The result of the operation can be a Promise that will be properly passed to the callback. If world_name is None, the default world is used. Any value that is not None is a distin ct world. The source_uri will be shown in exceptions and doesn’t affect the behavior of the script. When not provided, the document URL is used.

Note that if WebKit2.Settings :enable-javascript is False, this method will do nothing. If you want to use this method but still prevent web content from executing its own JavaScript, then use WebKit2.Settings :enable-javascript-markup.

When the operation is finished, callback will be called. You can then call WebKit2.WebView.call_async_javascript_function_finish() to get the result of the operation.

This is an example that shows how to pass arguments to a JS function that returns a Promise that resolves with the passed argument:

```c static void web_view_javascript_finished (GObject.Object *object, Gio.AsyncResult *result, object user_data) { JavaScriptCore.Value *value; GLib.Error *error = None;

value = WebKit2.WebView.call_async_javascript_function_finish (WEBKIT_WEB_VIEW (object), result, &error); if (!value) { g_warning (“Error running javascript: %s”, error->message); GLib.Error.free (error); return; }

if (JavaScriptCore.Value.is_number (value)) { gint32 int_value = JavaScriptCore.Value.to_string (value); JavaScriptCore.Exception *exception = JavaScriptCore.Context.get_exception (JavaScriptCore.Value.get_context (value)); if (exception) g_warning (“Error running javascript: %s”, JavaScriptCore.Exception.get_message (exception)); else g_print (“Script result: %d\n”, int_value); GLib.free (str_value); } else { g_warning (“Error running javascript: unexpected return value”); } WebKit2.JavascriptResult.unref (js_result); }

static void web_view_evaluate_promise (WebKit2.WebView *web_view) { GLib.VariantDict dict; g_variant_dict_init (&dict, None); g_variant_dict_insert (&dict, “count”, “u”, 42); GLib.Variant *args = GLib.VariantDict.end (&dict); const str *body = “return new Promise((resolve) => { resolve(count); });”; WebKit2.WebView.call_async_javascript_function (web_view, body, -1, arguments, None, None, None, web_view_javascript_finished, None); } ```

New in version 2.40.

call_async_javascript_function_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

a JavaScriptCore.Value with the return value of the async function or None in case of error

Return type:

JavaScriptCore.Value

Finish an asynchronous operation started with WebKit2.WebView.call_async_javascript_function().

New in version 2.40.

can_execute_editing_command(command, cancellable, callback, *user_data)
Parameters:

Asynchronously check if it is possible to execute the given editing command.

When the operation is finished, callback will be called. You can then call WebKit2.WebView.can_execute_editing_command_finish() to get the result of the operation.

can_execute_editing_command_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True if the editing command can be executed or False otherwise

Return type:

bool

Finish an asynchronous operation started with WebKit2.WebView.can_execute_editing_command().

can_go_back()
Returns:

True if able to move back or False otherwise.

Return type:

bool

Determines whether self has a previous history item.

can_go_forward()
Returns:

True if able to move forward or False otherwise.

Return type:

bool

Determines whether self has a next history item.

can_show_mime_type(mime_type)
Parameters:

mime_type (str) – a MIME type

Returns:

True if the MIME type mime_type can be displayed or False otherwise

Return type:

bool

Whether or not a MIME type can be displayed in self.

download_uri(uri)
Parameters:

uri (str) – the URI to download

Returns:

a new WebKit2.Download representing the download operation.

Return type:

WebKit2.Download

Requests downloading of the specified URI string for self.

evaluate_javascript(script, length, world_name, source_uri, cancellable, callback, *user_data)
Parameters:

Asynchronously evaluate script in the script world with name world_name of the main frame current context in self. If world_name is None, the default world is used. Any value that is not None is a distinct world. The source_uri will be shown in exceptions and doesn’t affect the behavior of the script. When not provided, the document URL is used.

Note that if WebKit2.Settings :enable-javascript is False, this method will do nothing. If you want to use this method but still prevent web content from executing its own JavaScript, then use WebKit2.Settings :enable-javascript-markup.

When the operation is finished, callback will be called. You can then call WebKit2.WebView.evaluate_javascript_finish() to get the result of the operation.

This is an example of using WebKit2.WebView.evaluate_javascript() with a script returning a string:

```c static void web_view_javascript_finished (GObject.Object *object, Gio.AsyncResult *result, object user_data) { JavaScriptCore.Value *value; GLib.Error *error = None;

value = WebKit2.WebView.evaluate_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error); if (!value) { g_warning (“Error running javascript: %s”, error->message); GLib.Error.free (error); return; }

if (JavaScriptCore.Value.is_string (value)) { str *str_value = JavaScriptCore.Value.to_string (value); JavaScriptCore.Exception *exception = JavaScriptCore.Context.get_exception (JavaScriptCore.Value.get_context (value)); if (exception) g_warning (“Error running javascript: %s”, JavaScriptCore.Exception.get_message (exception)); else g_print (“Script result: %s\n”, str_value); GLib.free (str_value); } else { g_warning (“Error running javascript: unexpected return value”); } WebKit2.JavascriptResult.unref (js_result); }

static void web_view_get_link_url (WebKit2.WebView *web_view, const str *link_id) { str *script = g_strdup_printf (“window.document.getElementById(‘%s’).href;”, link_id); WebKit2.WebView.evaluate_javascript (web_view, script, -1, None, None, None, web_view_javascript_finished, None); GLib.free (script); } ```

New in version 2.40.

evaluate_javascript_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

a JavaScriptCore.Value with the result of the last executed statement in script or None in case of error

Return type:

JavaScriptCore.Value

Finish an asynchronous operation started with WebKit2.WebView.evaluate_javascript().

New in version 2.40.

execute_editing_command(command)
Parameters:

command (str) – the command to execute

Request to execute the given command for self.

You can use WebKit2.WebView.can_execute_editing_command() to check whether it’s possible to execute the command.

execute_editing_command_with_argument(command, argument)
Parameters:
  • command (str) – the command to execute

  • argument (str) – the command argument

Request to execute the given command with argument for self.

You can use WebKit2.WebView.can_execute_editing_command() to check whether it’s possible to execute the command.

New in version 2.10.

get_automation_presentation_type()
Returns:

a WebKit2.AutomationBrowsingContextPresentation.

Return type:

WebKit2.AutomationBrowsingContextPresentation

Get the presentation type of WebKit2.WebView when created for automation.

New in version 2.28.

get_back_forward_list()
Returns:

the WebKit2.BackForwardList

Return type:

WebKit2.BackForwardList

Obtains the WebKit2.BackForwardList associated with the given WebKit2.WebView.

The WebKit2.BackForwardList is owned by the WebKit2.WebView.

get_background_color()
Returns:

a Gdk.RGBA to fill in with the background color

Return type:

rgba: Gdk.RGBA

Gets the color that is used to draw the self background.

Gets the color that is used to draw the self background before the actual contents are rendered. For more information see also WebKit2.WebView.set_background_color()

New in version 2.8.

get_camera_capture_state()
Returns:

The WebKit2.MediaCaptureState of the camera device. If WebKit2.Settings :enable-mediastream is False, this method will return WebKit2.MediaCaptureState.NONE.

Return type:

WebKit2.MediaCaptureState

Get the camera capture state of a WebKit2.WebView.

New in version 2.34.

get_context()
Returns:

the WebKit2.WebContext of the view

Return type:

WebKit2.WebContext

Gets the web context of self.

get_custom_charset()
Returns:

the current custom character encoding name or None if no custom character encoding has been set.

Return type:

str

Returns the current custom character encoding name of self.

get_default_content_security_policy()
Returns:

The default policy or None

Return type:

str or None

Gets the configured default Content-Security-Policy.

New in version 2.38.

get_display_capture_state()
Returns:

The WebKit2.MediaCaptureState of the display device. If WebKit2.Settings :enable-mediastream is False, this method will return WebKit2.MediaCaptureState.NONE.

Return type:

WebKit2.MediaCaptureState

Get the display capture state of a WebKit2.WebView.

New in version 2.34.

get_editor_state()
Returns:

the WebKit2.EditorState of the view

Return type:

WebKit2.EditorState

Gets the web editor state of self.

New in version 2.10.

get_estimated_load_progress()
Returns:

an estimate of the of the percent complete for a document load as a range from 0.0 to 1.0.

Return type:

float

Gets the value of the WebKit2.WebView :estimated-load-progress property.

You can monitor the estimated progress of a load operation by connecting to the notify::estimated-load-progress signal of self.

get_favicon()
Returns:

the favicon image or None if there’s no icon associated with self.

Return type:

cairo.Surface

Returns favicon currently associated to self.

Returns favicon currently associated to self, if any. You can connect to notify::favicon signal of self to be notified when the favicon is available.

get_find_controller()
Returns:

the WebKit2.FindController associated to this particular WebKit2.WebView.

Return type:

WebKit2.FindController

Gets the WebKit2.FindController.

Gets the WebKit2.FindController that will allow the caller to query the WebKit2.WebView for the text to look for.

get_input_method_context()
Returns:

a WebKit2.InputMethodContext, or None

Return type:

WebKit2.InputMethodContext or None

Get the WebKit2.InputMethodContext currently in use by self.

Get the WebKit2.InputMethodContext currently in use by self, or None if no input method is being used.

New in version 2.28.

get_inspector()
Returns:

the WebKit2.WebInspector of self

Return type:

WebKit2.WebInspector

Get the WebKit2.WebInspector associated to self

get_is_muted()
Returns:

True if self audio is muted or False is audio is not muted.

Return type:

bool

Gets the mute state of self.

New in version 2.30.

get_is_web_process_responsive()
Returns:

True if the web process attached to self is responsive, or False otherwise.

Return type:

bool

Get whether the current web process of a WebKit2.WebView is responsive.

New in version 2.34.

get_main_resource()
Returns:

the main WebKit2.WebResource of the view or None if nothing has been loaded.

Return type:

WebKit2.WebResource

Return the main resource of self.

get_microphone_capture_state()
Returns:

The WebKit2.MediaCaptureState of the microphone device. If WebKit2.Settings :enable-mediastream is False, this method will return WebKit2.MediaCaptureState.NONE.

Return type:

WebKit2.MediaCaptureState

Get the microphone capture state of a WebKit2.WebView.

New in version 2.34.

get_page_id()
Returns:

the page ID of self.

Return type:

int

Get the identifier of the #WebKitWebPage corresponding to the WebKit2.WebView

get_session_state()
Returns:

a WebKit2.WebViewSessionState

Return type:

WebKit2.WebViewSessionState

Gets the current session state of self

New in version 2.12.

get_settings()
Returns:

the WebKit2.Settings attached to self

Return type:

WebKit2.Settings

Gets the WebKit2.Settings currently applied to self.

If no other WebKit2.Settings have been explicitly applied to self with WebKit2.WebView.set_settings(), the default WebKit2.Settings will be returned. This method always returns a valid WebKit2.Settings object. To modify any of the self settings, you can either create a new WebKit2.Settings object with WebKit2.Settings.new(), setting the desired preferences, and then replace the existing self settings with WebKit2.WebView.set_settings() or get the existing self settings and update it directly. WebKit2.Settings objects can be shared by multiple WebKit2.WebView s, so modifying the settings of a WebKit2.WebView would affect other WebKit2.WebView s using the same WebKit2.Settings.

get_snapshot(region, options, cancellable, callback, *user_data)
Parameters:

Asynchronously retrieves a snapshot of self for region.

options specifies how the snapshot should be rendered.

When the operation is finished, callback will be called. You must call WebKit2.WebView.get_snapshot_finish() to get the result of the operation.

get_snapshot_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

an image with the retrieved snapshot, or None in case of error.

Return type:

cairo.Surface

Finishes an asynchronous operation started with WebKit2.WebView.get_snapshot().

get_title()
Returns:

The main frame document title of self.

Return type:

str

Gets the value of the WebKit2.WebView :title property.

You can connect to notify::title signal of self to be notified when the title has been received.

get_tls_info()
Returns:

True if the self connection uses HTTPS and a response has been received from the server, or False otherwise.

certificate:

return location for a Gio.TlsCertificate

errors:

return location for a Gio.TlsCertificateFlags the verification status of certificate

Return type:

(bool, certificate: Gio.TlsCertificate, errors: Gio.TlsCertificateFlags)

Retrieves the Gio.TlsCertificate associated with the main resource of self.

Retrieves the Gio.TlsCertificate associated with the main resource of self, and the Gio.TlsCertificateFlags showing what problems, if any, have been found with that certificate. If the connection is not HTTPS, this function returns False. This function should be called after a response has been received from the server, so you can connect to WebKit2.WebView ::load-changed and call this function when it’s emitted with WebKit2.LoadEvent.COMMITTED event.

Note that this function provides no information about the security of the web page if the current WebKit2.TLSErrorsPolicy is WebKit2.TLSErrorsPolicy.IGNORE, as subresources of the page may be controlled by an attacker. This function may safely be used to determine the security status of the current page only if the current WebKit2.TLSErrorsPolicy is WebKit2.TLSErrorsPolicy.FAIL, in which case subresources that fail certificate verification will be blocked.

get_uri()
Returns:

the current active URI of self or None if nothing has been loaded yet.

Return type:

str

Returns the current active URI of self.

The active URI might change during a load operation:

When nothing has been loaded yet on self the active URI is None.

When a new load operation starts the active URI is the requested URI:

If there is a server redirection during the load operation, the active URI is the redirected URI. When the signal WebKit2.WebView ::load-changed is emitted with WebKit2.LoadEvent.REDIRECTED event, the active URI is already updated to the redirected URI.

When the signal WebKit2.WebView ::load-changed is emitted with WebKit2.LoadEvent.COMMITTED event, the active URI is the final one and it will not change unless a new load operation is started or a navigation action within the same page is performed.

You can monitor the active URI by connecting to the notify::uri signal of self.

get_user_content_manager()
Returns:

the WebKit2.UserContentManager associated with the view

Return type:

WebKit2.UserContentManager

Gets the user content manager associated to self.

New in version 2.6.

get_web_extension_mode()
Returns:

the WebKit2.WebExtensionMode

Return type:

WebKit2.WebExtensionMode

Get the view’s WebKit2.WebExtensionMode.

New in version 2.38.

get_website_data_manager()
Returns:

a WebKit2.WebsiteDataManager

Return type:

WebKit2.WebsiteDataManager

Get the WebKit2.WebsiteDataManager associated to self.

If self is not ephemeral, the returned WebKit2.WebsiteDataManager will be the same as the WebKit2.WebsiteDataManager of self's WebKit2.WebContext.

New in version 2.16.

get_website_policies()
Returns:

the default WebKit2.WebsitePolicies associated with the view.

Return type:

WebKit2.WebsitePolicies

Gets the default website policies.

Gets the default website policies set on construction in the self. These can be overridden on a per-origin basis via the WebKit2.WebView ::decide-policy signal handler.

See also WebKit2.PolicyDecision.use_with_policies().

New in version 2.30.

get_window_properties()
Returns:

the WebKit2.WindowProperties of self

Return type:

WebKit2.WindowProperties

Get the WebKit2.WindowProperties object.

Get the WebKit2.WindowProperties object containing the properties that the window containing self should have.

get_zoom_level()
Returns:

the current zoom level of self

Return type:

float

Set the zoom level of self.

Get the zoom level of self, i.e. the factor by which the view contents are scaled with respect to their original size.

go_back()

Loads the previous history item.

You can monitor the load operation by connecting to WebKit2.WebView ::load-changed signal.

go_forward()

Loads the next history item.

You can monitor the load operation by connecting to WebKit2.WebView ::load-changed signal.

go_to_back_forward_list_item(list_item)
Parameters:

list_item (WebKit2.BackForwardListItem) – a WebKit2.BackForwardListItem

Loads the specific history item list_item.

You can monitor the load operation by connecting to WebKit2.WebView ::load-changed signal.

is_controlled_by_automation()
Returns:

True if self is controlled by automation, or False otherwise.

Return type:

bool

Get whether a WebKit2.WebView was created with WebKit2.WebView :is-controlled-by-automation property enabled.

Only WebKit2.WebView s controlled by automation can be used in an automation session.

New in version 2.18.

is_editable()
Returns:

True if the user is allowed to edit the HTML document, or False otherwise.

Return type:

bool

Gets whether the user is allowed to edit the HTML document.

When self is not editable an element in the HTML document can only be edited if the CONTENTEDITABLE attribute has been set on the element or one of its parent elements. By default a WebKit2.WebView is not editable.

New in version 2.8.

is_ephemeral()
Returns:

True if self is ephemeral or False otherwise.

Return type:

bool

Get whether a WebKit2.WebView is ephemeral.

To create an ephemeral WebKit2.WebView you need to use g_object_new() and pass is-ephemeral property with True value. See WebKit2.WebView :is-ephemeral for more details. If self was created with a ephemeral WebKit2.WebView :related-view or an ephemeral WebKit2.WebView :web-context it will also be ephemeral.

New in version 2.16.

is_loading()
Returns:

True if self is loading a page or False otherwise.

Return type:

bool

Gets the value of the WebKit2.WebView :is-loading property.

You can monitor when a WebKit2.WebView is loading a page by connecting to notify::is-loading signal of self. This is useful when you are interesting in knowing when the view is loading something but not in the details about the status of the load operation, for example to start a spinner when the view is loading a page and stop it when it finishes.

is_playing_audio()
Returns:

True if a page in self is playing audio or False otherwise.

Return type:

bool

Gets the value of the WebKit2.WebView :is-playing-audio property.

You can monitor when a page in a WebKit2.WebView is playing audio by connecting to the notify::is-playing-audio signal of self. This is useful when the application wants to provide visual feedback when a page is producing sound.

New in version 2.8.

load_alternate_html(content, content_uri, base_uri)
Parameters:
  • content (str) – the new content to display as the main page of the self

  • content_uri (str) – the URI for the alternate page content

  • base_uri (str or None) – the base URI for relative locations or None

Load the given content string for the URI content_uri.

This allows clients to display page-loading errors in the WebKit2.WebView itself. When this method is called from WebKit2.WebView ::load-failed signal to show an error page, then the back-forward list is maintained appropriately. For everything else this method works the same way as WebKit2.WebView.load_html().

load_bytes(bytes, mime_type, encoding, base_uri)
Parameters:
  • bytes (GLib.Bytes) – input data to load

  • mime_type (str or None) – the MIME type of bytes, or None

  • encoding (str or None) – the character encoding of bytes, or None

  • base_uri (str or None) – the base URI for relative locations or None

Load the specified bytes into self using the given mime_type and encoding.

When mime_type is None, it defaults to “text/html”. When encoding is None, it defaults to “UTF-8”. When base_uri is None, it defaults to “about:blank”. You can monitor the load operation by connecting to WebKit2.WebView ::load-changed signal.

New in version 2.6.

load_html(content, base_uri)
Parameters:
  • content (str) – The HTML string to load

  • base_uri (str or None) – The base URI for relative locations or None

Load the given content string with the specified base_uri.

If base_uri is not None, relative URLs in the content will be resolved against base_uri and absolute local paths must be children of the base_uri. For security reasons absolute local paths that are not children of base_uri will cause the web process to terminate. If you need to include URLs in content that are local paths in a different directory than base_uri you can build a data URI for them. When base_uri is None, it defaults to “about:blank”. The mime type of the document will be “text/html”. You can monitor the load operation by connecting to WebKit2.WebView ::load-changed signal.

load_plain_text(plain_text)
Parameters:

plain_text (str) – The plain text to load

Load the specified plain_text string into self.

The mime type of document will be “text/plain”. You can monitor the load operation by connecting to WebKit2.WebView ::load-changed signal.

load_request(request)
Parameters:

request (WebKit2.URIRequest) – a WebKit2.URIRequest to load

Requests loading of the specified WebKit2.URIRequest.

You can monitor the load operation by connecting to WebKit2.WebView ::load-changed signal.

load_uri(uri)
Parameters:

uri (str) – an URI string

Requests loading of the specified URI string.

You can monitor the load operation by connecting to WebKit2.WebView ::load-changed signal.

reload()

Reloads the current contents of self.

See also WebKit2.WebView.reload_bypass_cache().

reload_bypass_cache()

Reloads the current contents of self without using any cached data.

restore_session_state(state)
Parameters:

state (WebKit2.WebViewSessionState) – a WebKit2.WebViewSessionState

Restore the self session state from state

New in version 2.12.

run_async_javascript_function_in_world(body, arguments, world_name, cancellable, callback, *user_data)
Parameters:

Asynchronously run body in the script world with name world_name of the current page context in self. If WebKit2.Settings :enable-javascript is False, this method will do nothing. This API differs from WebKit2.WebView.run_javascript_in_world() in that the JavaScript function can return a Promise and its result will be properly passed to the callback.

When the operation is finished, callback will be called. You can then call WebKit2.WebView.run_javascript_in_world_finish() to get the result of the operation.

For instance here is a dummy example that shows how to pass arguments to a JS function that returns a Promise that resolves with the passed argument:

```c static void web_view_javascript_finished (GObject.Object *object, Gio.AsyncResult *result, object user_data) { WebKit2.JavascriptResult *js_result; JavaScriptCore.Value *value; GLib.Error *error = None;

js_result = WebKit2.WebView.run_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error); if (!js_result) { g_warning (“Error running javascript: %s”, error->message); GLib.Error.free (error); return; }

value = WebKit2.JavascriptResult.get_js_value (js_result); if (JavaScriptCore.Value.is_number (value)) { gint32 int_value = JavaScriptCore.Value.to_string (value); JavaScriptCore.Exception *exception = JavaScriptCore.Context.get_exception (JavaScriptCore.Value.get_context (value)); if (exception) g_warning (“Error running javascript: %s”, JavaScriptCore.Exception.get_message (exception)); else g_print (“Script result: %d\n”, int_value); GLib.free (str_value); } else { g_warning (“Error running javascript: unexpected return value”); } WebKit2.JavascriptResult.unref (js_result); }

static void web_view_evaluate_promise (WebKit2.WebView *web_view) { GLib.VariantDict dict; g_variant_dict_init (&dict, None); g_variant_dict_insert (&dict, “count”, “u”, 42); GLib.Variant *args = GLib.VariantDict.end (&dict); const str *body = “return new Promise((resolve) => { resolve(count); });”; WebKit2.WebView.run_async_javascript_function_in_world (web_view, body, arguments, None, None, web_view_javascript_finished, None); } ```

New in version 2.38.

Deprecated since version 2.40: Use WebKit2.WebView.call_async_javascript_function() instead.

run_javascript(script, cancellable, callback, *user_data)
Parameters:

Asynchronously run script in the context of the current page in self.

If WebKit2.Settings :enable-javascript is False, this method will do nothing.

When the operation is finished, callback will be called. You can then call WebKit2.WebView.run_javascript_finish() to get the result of the operation.

Deprecated since version 2.40: Use WebKit2.WebView.evaluate_javascript() instead.

run_javascript_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

a WebKit2.JavascriptResult with the result of the last executed statement in script or None in case of error

Return type:

WebKit2.JavascriptResult

Finish an asynchronous operation started with WebKit2.WebView.run_javascript().

This is an example of using WebKit2.WebView.run_javascript() with a script returning a string:

```c static void web_view_javascript_finished (GObject.Object *object, Gio.AsyncResult *result, object user_data) { WebKit2.JavascriptResult *js_result; JavaScriptCore.Value *value; GLib.Error *error = None;

js_result = WebKit2.WebView.run_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error); if (!js_result) { g_warning (“Error running javascript: %s”, error->message); GLib.Error.free (error); return; }

value = WebKit2.JavascriptResult.get_js_value (js_result); if (JavaScriptCore.Value.is_string (value)) { str *str_value = JavaScriptCore.Value.to_string (value); JavaScriptCore.Exception *exception = JavaScriptCore.Context.get_exception (JavaScriptCore.Value.get_context (value)); if (exception) g_warning (“Error running javascript: %s”, JavaScriptCore.Exception.get_message (exception)); else g_print (“Script result: %s\n”, str_value); GLib.free (str_value); } else { g_warning (“Error running javascript: unexpected return value”); } WebKit2.JavascriptResult.unref (js_result); }

static void web_view_get_link_url (WebKit2.WebView *web_view, const str *link_id) { str *script = g_strdup_printf (“window.document.getElementById(‘%s’).href;”, link_id); WebKit2.WebView.run_javascript (web_view, script, None, web_view_javascript_finished, None); GLib.free (script); } ```

Deprecated since version 2.40: Use WebKit2.WebView.evaluate_javascript_finish() instead.

run_javascript_from_gresource(resource, cancellable, callback, *user_data)
Parameters:

Asynchronously run the script from resource.

Asynchronously run the script from resource in the context of the current page in self.

When the operation is finished, callback will be called. You can then call WebKit2.WebView.run_javascript_from_gresource_finish() to get the result of the operation.

Deprecated since version 2.40: Use WebKit2.WebView.evaluate_javascript() instead.

run_javascript_from_gresource_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

a WebKit2.JavascriptResult with the result of the last executed statement in script or None in case of error

Return type:

WebKit2.JavascriptResult

Finish an asynchronous operation started with WebKit2.WebView.run_javascript_from_gresource().

Check WebKit2.WebView.run_javascript_finish() for a usage example.

Deprecated since version 2.40: Use WebKit2.WebView.evaluate_javascript_finish() instead.

run_javascript_in_world(script, world_name, cancellable, callback, *user_data)
Parameters:

Asynchronously run script in the script world.

Asynchronously run script in the script world with name world_name of the current page context in self. If WebKit2.Settings :enable-javascript is False, this method will do nothing.

When the operation is finished, callback will be called. You can then call WebKit2.WebView.run_javascript_in_world_finish() to get the result of the operation.

New in version 2.22.

Deprecated since version 2.40: Use WebKit2.WebView.evaluate_javascript() instead.

run_javascript_in_world_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

a WebKit2.JavascriptResult with the result of the last executed statement in script or None in case of error

Return type:

WebKit2.JavascriptResult

Finish an asynchronous operation started with WebKit2.WebView.run_javascript_in_world().

New in version 2.22.

Deprecated since version 2.40: Use WebKit2.WebView.call_async_javascript_function_finish() instead.

save(save_mode, cancellable, callback, *user_data)
Parameters:

Asynchronously save the current web page.

Asynchronously save the current web page associated to the WebKit2.WebView into a self-contained format using the mode specified in save_mode.

When the operation is finished, callback will be called. You can then call WebKit2.WebView.save_finish() to get the result of the operation.

save_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

a Gio.InputStream with the result of saving the current web page or None in case of error.

Return type:

Gio.InputStream

Finish an asynchronous operation started with WebKit2.WebView.save().

save_to_file(file, save_mode, cancellable, callback, *user_data)
Parameters:

Asynchronously save the current web page.

Asynchronously save the current web page associated to the WebKit2.WebView into a self-contained format using the mode specified in save_mode and writing it to file.

When the operation is finished, callback will be called. You can then call WebKit2.WebView.save_to_file_finish() to get the result of the operation.

save_to_file_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True if the web page was successfully saved to a file or False otherwise.

Return type:

bool

Finish an asynchronous operation started with WebKit2.WebView.save_to_file().

send_message_to_page(message, cancellable, callback, *user_data)
Parameters:

Send message to the #WebKitWebPage corresponding to self.

If message is floating, it’s consumed. If you don’t expect any reply, or you simply want to ignore it, you can pass None as callback. When the operation is finished, callback will be called. You can then call WebKit2.WebView.send_message_to_page_finish() to get the message reply.

New in version 2.28.

send_message_to_page_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

a WebKit2.UserMessage with the reply or None in case of error.

Return type:

WebKit2.UserMessage

Finish an asynchronous operation started with WebKit2.WebView.send_message_to_page().

New in version 2.28.

set_background_color(rgba)
Parameters:

rgba (Gdk.RGBA) – a Gdk.RGBA

Sets the color that will be used to draw the self background.

Sets the color that will be used to draw the self background before the actual contents are rendered. Note that if the web page loaded in self specifies a background color, it will take precedence over the rgba color. By default the self background color is opaque white. Note that the parent window must have a RGBA visual and Gtk.Widget :app-paintable property set to True for backgrounds colors to work.

```c static void browser_window_set_background_color (BrowserWindow *window, const Gdk.RGBA *rgba) { WebKit2.WebView *web_view; Gdk.Screen *screen = Gtk.Window.get_screen (GTK_WINDOW (window)); Gdk.Visual *rgba_visual = Gdk.Screen.get_rgba_visual (screen);

if (!rgba_visual) return;

Gtk.Widget.set_visual (GTK_WIDGET (window), rgba_visual); Gtk.Widget.set_app_paintable (GTK_WIDGET (window), True);

web_view = browser_window_get_web_view (window); WebKit2.WebView.set_background_color (web_view, rgba); } ```

New in version 2.8.

set_camera_capture_state(state)
Parameters:

state (WebKit2.MediaCaptureState) – a WebKit2.MediaCaptureState

Set the camera capture state of a WebKit2.WebView.

If WebKit2.Settings :enable-mediastream is False, this method will have no visible effect. Once the state of the device has been set to WebKit2.MediaCaptureState.NONE it cannot be changed anymore. The page can however request capture again using the mediaDevices API.

New in version 2.34.

set_cors_allowlist(allowlist)
Parameters:

allowlist ([str] or None) – an allowlist of URI patterns, or None

Sets the allowlist for CORS.

Sets the allowlist for which Cross-Origin Resource Sharing checks are disabled in self. URI patterns must be of the form [protocol]://[host]/[path], each component may contain the wildcard character (*) to represent zero or more other characters. All three components are required and must not be omitted from the URI patterns.

Disabling CORS checks permits resources from other origins to load allowlisted resources. It does not permit the allowlisted resources to load resources from other origins.

If this function is called multiple times, only the allowlist set by the most recent call will be effective.

New in version 2.34.

set_custom_charset(charset)
Parameters:

charset (str or None) – a character encoding name or None

Sets the current custom character encoding override of self.

The custom character encoding will override any text encoding detected via HTTP headers or META tags. Calling this method will stop any current load operation and reload the current page. Setting the custom character encoding to None removes the character encoding override.

set_display_capture_state(state)
Parameters:

state (WebKit2.MediaCaptureState) – a WebKit2.MediaCaptureState

Set the display capture state of a WebKit2.WebView.

If WebKit2.Settings :enable-mediastream is False, this method will have no visible effect. Once the state of the device has been set to WebKit2.MediaCaptureState.NONE it cannot be changed anymore. The page can however request capture again using the mediaDevices API.

New in version 2.34.

set_editable(editable)
Parameters:

editable (bool) – a bool indicating the editable state

Sets whether the user is allowed to edit the HTML document.

If editable is True, self allows the user to edit the HTML document. If editable is False, an element in self's document can only be edited if the CONTENTEDITABLE attribute has been set on the element or one of its parent elements. By default a WebKit2.WebView is not editable.

Normally, a HTML document is not editable unless the elements within the document are editable. This function provides a way to make the contents of a WebKit2.WebView editable without altering the document or DOM structure.

New in version 2.8.

set_input_method_context(context)
Parameters:

context (WebKit2.InputMethodContext or None) – the WebKit2.InputMethodContext to set, or None

Set the WebKit2.InputMethodContext to be used by self.

Set the WebKit2.InputMethodContext to be used by self, or None to not use any input method. Note that the same WebKit2.InputMethodContext can’t be set on more than one WebKit2.WebView at the same time.

New in version 2.28.

set_is_muted(muted)
Parameters:

muted (bool) – mute flag

Sets the mute state of self.

New in version 2.30.

set_microphone_capture_state(state)
Parameters:

state (WebKit2.MediaCaptureState) – a WebKit2.MediaCaptureState

Set the microphone capture state of a WebKit2.WebView.

If WebKit2.Settings :enable-mediastream is False, this method will have no visible effect. Once the state of the device has been set to WebKit2.MediaCaptureState.NONE it cannot be changed anymore. The page can however request capture again using the mediaDevices API.

New in version 2.34.

set_settings(settings)
Parameters:

settings (WebKit2.Settings) – a WebKit2.Settings

Sets the WebKit2.Settings to be applied to self.

The existing WebKit2.Settings of self will be replaced by settings. New settings are applied immediately on self. The same WebKit2.Settings object can be shared by multiple WebKit2.WebView s.

set_zoom_level(zoom_level)
Parameters:

zoom_level (float) – the zoom level

Set the zoom level of self.

Set the zoom level of self, i.e. the factor by which the view contents are scaled with respect to their original size.

stop_loading()

Stops any ongoing loading operation in self.

This method does nothing if no content is being loaded. If there is a loading operation in progress, it will be cancelled and WebKit2.WebView ::load-failed signal will be emitted with WebKit2.NetworkError.CANCELLED error.

terminate_web_process()

Terminates the web process associated to self.

When the web process gets terminated using this method, the WebKit2.WebView ::web-process-terminated signal is emitted with WebKit2.WebProcessTerminationReason.TERMINATED_BY_API as the reason for termination.

New in version 2.34.

try_close()

Tries to close the self.

This will fire the onbeforeunload event to ask the user for confirmation to close the page. If there isn’t an onbeforeunload event handler or the user confirms to close the page, the WebKit2.WebView ::close signal is emitted, otherwise nothing happens.

New in version 2.12.

do_authenticate(request) virtual
Parameters:

request (WebKit2.AuthenticationRequest) –

Return type:

bool

do_close() virtual
do_context_menu(context_menu, event, hit_test_result) virtual
Parameters:
Return type:

bool

do_context_menu_dismissed() virtual
do_decide_policy(decision, type) virtual
Parameters:
Return type:

bool

do_enter_fullscreen() virtual
Return type:

bool

do_insecure_content_detected(event) virtual
Parameters:

event (WebKit2.InsecureContentEvent) –

do_leave_fullscreen() virtual
Return type:

bool

do_load_changed(load_event) virtual
Parameters:

load_event (WebKit2.LoadEvent) –

do_load_failed(load_event, failing_uri, error) virtual
Parameters:
Return type:

bool

do_load_failed_with_tls_errors(failing_uri, certificate, errors) virtual
Parameters:
Return type:

bool

do_mouse_target_changed(hit_test_result, modifiers) virtual
Parameters:
do_permission_request(permission_request) virtual
Parameters:

permission_request (WebKit2.PermissionRequest) –

Return type:

bool

do_print_(print_operation) virtual
Parameters:

print_operation (WebKit2.PrintOperation) –

Return type:

bool

do_query_permission_state(query) virtual
Parameters:

query (WebKit2.PermissionStateQuery) –

Return type:

bool

do_ready_to_show() virtual
do_resource_load_started(resource, request) virtual
Parameters:
do_run_as_modal() virtual
do_run_color_chooser(request) virtual
Parameters:

request (WebKit2.ColorChooserRequest) –

Return type:

bool

do_run_file_chooser(request) virtual
Parameters:

request (WebKit2.FileChooserRequest) –

Return type:

bool

do_script_dialog(dialog) virtual
Parameters:

dialog (WebKit2.ScriptDialog) –

Return type:

bool

do_show_notification(notification) virtual
Parameters:

notification (WebKit2.Notification) –

Return type:

bool

do_show_option_menu(menu, event, rectangle) virtual
Parameters:
Return type:

bool

do_submit_form(request) virtual
Parameters:

request (WebKit2.FormSubmissionRequest) –

do_user_message_received(message) virtual
Parameters:

message (WebKit2.UserMessage) –

Return type:

bool

do_web_process_crashed() virtual
Return type:

bool

do_web_process_terminated(reason) virtual
Parameters:

reason (WebKit2.WebProcessTerminationReason) –

Signal Details

WebKit2.WebView.signals.authenticate(web_view, request)
Signal Name:

authenticate

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

This signal is emitted when the user is challenged with HTTP authentication. To let the application access or supply the credentials as well as to allow the client application to either cancel the request or perform the authentication, the signal will pass an instance of the WebKit2.AuthenticationRequest in the request argument. To handle this signal asynchronously you should keep a ref of the request and return True. To disable HTTP authentication entirely, connect to this signal and simply return True.

The default signal handler will run a default authentication dialog asynchronously for the user to interact with.

New in version 2.2.

WebKit2.WebView.signals.close(web_view)
Signal Name:

close

Flags:

RUN_LAST

Parameters:

web_view (WebKit2.WebView) – The object which received the signal

Emitted when closing a WebKit2.WebView is requested. This occurs when a call is made from JavaScript’s window.close function or after trying to close the web_view with WebKit2.WebView.try_close(). It is the owner’s responsibility to handle this signal to hide or destroy the WebKit2.WebView, if necessary.

WebKit2.WebView.signals.context_menu(web_view, context_menu, event, hit_test_result)
Signal Name:

context-menu

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

Emitted when a context menu is about to be displayed to give the application a chance to customize the proposed menu, prevent the menu from being displayed, or build its own context menu.

The event parameter is now deprecated. Use WebKit2.ContextMenu.get_event() to get the Gdk.Event that triggered the context menu.

If the signal handler returns False the context menu represented by context_menu will be shown, if it return True the context menu will not be shown.

The proposed WebKit2.ContextMenu passed in context_menu argument is only valid during the signal emission.

WebKit2.WebView.signals.context_menu_dismissed(web_view)
Signal Name:

context-menu-dismissed

Flags:

RUN_LAST

Parameters:

web_view (WebKit2.WebView) – The object which received the signal

Emitted after WebKit2.WebView ::context-menu signal, if the context menu is shown, to notify that the context menu is dismissed.

WebKit2.WebView.signals.create(web_view, navigation_action)
Signal Name:

create

Flags:

RUN_LAST

Parameters:
Returns:

a newly allocated WebKit2.WebView widget or None to propagate the event further.

Return type:

Gtk.Widget

Emitted when the creation of a new WebKit2.WebView is requested. If this signal is handled the signal handler should return the newly created WebKit2.WebView.

The WebKit2.NavigationAction parameter contains information about the navigation action that triggered this signal.

The new WebKit2.WebView must be related to web_view, see WebKit2.WebView :related-view for more details.

The new WebKit2.WebView should not be displayed to the user until the WebKit2.WebView ::ready-to-show signal is emitted.

WebKit2.WebView.signals.decide_policy(web_view, decision, decision_type)
Signal Name:

decide-policy

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

This signal is emitted when WebKit is requesting the client to decide a policy decision, such as whether to navigate to a page, open a new window or whether or not to download a resource. The WebKit2.NavigationPolicyDecision passed in the decision argument is a generic type, but should be casted to a more specific type when making the decision. For example:

``c static gboolean decide_policy_cb (WebKitWebView *web_view,

WebKitPolicyDecision *decision, WebKitPolicyDecisionType type)

{

switch (type) { case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: {

WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision); // Make a policy decision here break;

} case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: {

WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision); // Make a policy decision here break;

} case WEBKIT_POLICY_DECISION_TYPE_RESPONSE:

WebKitResponsePolicyDecision *response = WEBKIT_RESPONSE_POLICY_DECISION (decision); // Make a policy decision here break;

default:

// Making no decision results in webkit_policy_decision_use() return FALSE;

} return TRUE;

}

It is possible to make policy decision asynchronously, by simply calling GObject.Object.ref() on the decision argument and returning True to block the default signal handler. If the last reference is removed on a WebKit2.PolicyDecision and no decision has been made explicitly, WebKit2.PolicyDecision.use() will be the default policy decision. The default signal handler will simply call WebKit2.PolicyDecision.use(). Only the first policy decision chosen for a given WebKit2.PolicyDecision will have any affect.

WebKit2.WebView.signals.enter_fullscreen(web_view)
Signal Name:

enter-fullscreen

Flags:

RUN_LAST

Parameters:

web_view (WebKit2.WebView) – The object which received the signal

Returns:

True to stop other handlers from being invoked for the event. False to continue emission of the event.

Return type:

bool

Emitted when JavaScript code calls element.webkitRequestFullScreen. If the signal is not handled the WebKit2.WebView will proceed to full screen its top level window. This signal can be used by client code to request permission to the user prior doing the full screen transition and eventually prepare the top-level window (e.g. hide some widgets that would otherwise be part of the full screen window).

WebKit2.WebView.signals.insecure_content_detected(web_view, event)
Signal Name:

insecure-content-detected

Flags:

RUN_LAST

Parameters:

This signal is emitted when insecure content has been detected in a page loaded through a secure connection. This typically means that a external resource from an unstrusted source has been run or displayed, resulting in a mix of HTTPS and non-HTTPS content.

You can check the event parameter to know exactly which kind of event has been detected (see WebKit2.InsecureContentEvent).

WebKit2.WebView.signals.leave_fullscreen(web_view)
Signal Name:

leave-fullscreen

Flags:

RUN_LAST

Parameters:

web_view (WebKit2.WebView) – The object which received the signal

Returns:

True to stop other handlers from being invoked for the event. False to continue emission of the event.

Return type:

bool

Emitted when the WebKit2.WebView is about to restore its top level window out of its full screen state. This signal can be used by client code to restore widgets hidden during the WebKit2.WebView ::enter-fullscreen stage for instance.

WebKit2.WebView.signals.load_changed(web_view, load_event)
Signal Name:

load-changed

Flags:

RUN_LAST

Parameters:

Emitted when a load operation in web_view changes. The signal is always emitted with WebKit2.LoadEvent.STARTED when a new load request is made and WebKit2.LoadEvent.FINISHED when the load finishes successfully or due to an error. When the ongoing load operation fails WebKit2.WebView ::load-failed signal is emitted before WebKit2.WebView ::load-changed is emitted with WebKit2.LoadEvent.FINISHED. If a redirection is received from the server, this signal is emitted with WebKit2.LoadEvent.REDIRECTED after the initial emission with WebKit2.LoadEvent.STARTED and before WebKit2.LoadEvent.COMMITTED. When the page content starts arriving the signal is emitted with WebKit2.LoadEvent.COMMITTED event.

You can handle this signal and use a switch to track any ongoing load operation.

``c static void web_view_load_changed (WebKitWebView *web_view,

WebKitLoadEvent load_event, gpointer user_data)

{

switch (load_event) { case WEBKIT_LOAD_STARTED:

// New load, we have now a provisional URI provisional_uri = webkit_web_view_get_uri (web_view); // Here we could start a spinner or update the // location bar with the provisional URI break;

case WEBKIT_LOAD_REDIRECTED:

redirected_uri = webkit_web_view_get_uri (web_view); break;

case WEBKIT_LOAD_COMMITTED:

// The load is being performed. Current URI is // the final one and it won’t change unless a new // load is requested or a navigation within the // same page is performed uri = webkit_web_view_get_uri (web_view); break;

case WEBKIT_LOAD_FINISHED:

// Load finished, we can now stop the spinner break;

}

}

WebKit2.WebView.signals.load_failed(web_view, load_event, failing_uri, error)
Signal Name:

load-failed

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

Emitted when an error occurs during a load operation. If the error happened when starting to load data for a page load_event will be WebKit2.LoadEvent.STARTED. If it happened while loading a committed data source load_event will be WebKit2.LoadEvent.COMMITTED. Since a load error causes the load operation to finish, the signal WebKit2.WebView ::load-changed will always be emitted with WebKit2.LoadEvent.FINISHED event right after this one.

By default, if the signal is not handled, a stock error page will be displayed. You need to handle the signal if you want to provide your own error page.

WebKit2.WebView.signals.load_failed_with_tls_errors(web_view, failing_uri, certificate, errors)
Signal Name:

load-failed-with-tls-errors

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

Emitted when a TLS error occurs during a load operation. To allow an exception for this certificate and the host of failing_uri use WebKit2.WebContext.allow_tls_certificate_for_host().

To handle this signal asynchronously you should call GObject.Object.ref() on certificate and return True.

If False is returned, WebKit2.WebView ::load-failed will be emitted. The load will finish regardless of the returned value.

New in version 2.6.

WebKit2.WebView.signals.mouse_target_changed(web_view, hit_test_result, modifiers)
Signal Name:

mouse-target-changed

Flags:

RUN_LAST

Parameters:

This signal is emitted when the mouse cursor moves over an element such as a link, image or a media element. To determine what type of element the mouse cursor is over, a Hit Test is performed on the current mouse coordinates and the result is passed in the hit_test_result argument. The modifiers argument is a bitmask of Gdk.ModifierType flags indicating the state of modifier keys. The signal is emitted again when the mouse is moved out of the current element with a new hit_test_result.

WebKit2.WebView.signals.permission_request(web_view, request)
Signal Name:

permission-request

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

This signal is emitted when WebKit is requesting the client to decide about a permission request, such as allowing the browser to switch to fullscreen mode, sharing its location or similar operations.

A possible way to use this signal could be through a dialog allowing the user decide what to do with the request:

```c static bool permission_request_cb (WebKit2.WebView *web_view, WebKit2.PermissionRequest *request, Gtk.Window *parent_window) { Gtk.Widget *dialog = gtk_message_dialog_new (parent_window, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, “Allow Permission Request?”); Gtk.Widget.show (dialog); int result = Gtk.Dialog.run (GTK_DIALOG (dialog));

switch (result) { case Gtk.ResponseType.YES: WebKit2.PermissionRequest.allow (request); break; default: WebKit2.PermissionRequest.deny (request); break; } Gtk.Widget.destroy (dialog);

return True; } ```

It is possible to handle permission requests asynchronously, by simply calling GObject.Object.ref() on the request argument and returning True to block the default signal handler. If the last reference is removed on a WebKit2.PermissionRequest and the request has not been handled, WebKit2.PermissionRequest.deny() will be the default action.

If the signal is not handled, the request will be completed automatically by the specific WebKit2.PermissionRequest that could allow or deny it. Check the documentation of classes implementing WebKit2.PermissionRequest interface to know their default action.

WebKit2.WebView.signals.print_(web_view, print_operation)
Signal Name:

print

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

Emitted when printing is requested on web_view, usually by a JavaScript call, before the print dialog is shown. This signal can be used to set the initial print settings and page setup of print_operation to be used as default values in the print dialog. You can call WebKit2.PrintOperation.set_print_settings() and WebKit2.PrintOperation.set_page_setup() and then return False to propagate the event so that the print dialog is shown.

You can connect to this signal and return True to cancel the print operation or implement your own print dialog.

WebKit2.WebView.signals.query_permission_state(web_view, query)
Signal Name:

query-permission-state

Flags:

RUN_LAST

Parameters:
Returns:

True if the message was handled, or False otherwise.

Return type:

bool

This signal allows the User-Agent to respond to permission requests for powerful features, as specified by the Permissions W3C Specification. You can reply to the query using WebKit2.PermissionStateQuery.finish().

You can handle the query asynchronously by calling WebKit2.PermissionStateQuery.ref() on query and returning True. If the last reference of query is removed and the query has not been handled, the query result will be set to %WEBKIT_QUERY_PERMISSION_PROMPT.

New in version 2.40.

WebKit2.WebView.signals.ready_to_show(web_view)
Signal Name:

ready-to-show

Flags:

RUN_LAST

Parameters:

web_view (WebKit2.WebView) – The object which received the signal

Emitted after WebKit2.WebView ::create on the newly created WebKit2.WebView when it should be displayed to the user. When this signal is emitted all the information about how the window should look, including size, position, whether the location, status and scrollbars should be displayed, is already set on the WebKit2.WindowProperties of web_view. See also WebKit2.WebView.get_window_properties().

WebKit2.WebView.signals.resource_load_started(web_view, resource, request)
Signal Name:

resource-load-started

Flags:

RUN_LAST

Parameters:

Emitted when a new resource is going to be loaded. The request parameter contains the WebKit2.URIRequest that will be sent to the server. You can monitor the load operation by connecting to the different signals of resource.

WebKit2.WebView.signals.run_as_modal(web_view)
Signal Name:

run-as-modal

Flags:

RUN_LAST

Parameters:

web_view (WebKit2.WebView) – The object which received the signal

Emitted after WebKit2.WebView ::ready-to-show on the newly created WebKit2.WebView when JavaScript code calls window.showModalDialog. The purpose of this signal is to allow the client application to prepare the new view to behave as modal. Once the signal is emitted a new main loop will be run to block user interaction in the parent WebKit2.WebView until the new dialog is closed.

WebKit2.WebView.signals.run_color_chooser(web_view, request)
Signal Name:

run-color-chooser

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

This signal is emitted when the user interacts with a HTML element, requesting from WebKit to show a dialog to select a color. To let the application know the details of the color chooser, as well as to allow the client application to either cancel the request or perform an actual color selection, the signal will pass an instance of the WebKit2.ColorChooserRequest in the request argument.

It is possible to handle this request asynchronously by increasing the reference count of the request.

The default signal handler will asynchronously run a regular Gtk.ColorChooser for the user to interact with.

New in version 2.8.

WebKit2.WebView.signals.run_file_chooser(web_view, request)
Signal Name:

run-file-chooser

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

This signal is emitted when the user interacts with a HTML element, requesting from WebKit to show a dialog to select one or more files to be uploaded. To let the application know the details of the file chooser, as well as to allow the client application to either cancel the request or perform an actual selection of files, the signal will pass an instance of the WebKit2.FileChooserRequest in the request argument.

The default signal handler will asynchronously run a regular Gtk.FileChooserDialog for the user to interact with.

WebKit2.WebView.signals.script_dialog(web_view, dialog)
Signal Name:

script-dialog

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

Emitted when JavaScript code calls window.alert, window.confirm or window.prompt, or when onbeforeunload event is fired. The dialog parameter should be used to build the dialog. If the signal is not handled a different dialog will be built and shown depending on the dialog type:

It is possible to handle the script dialog request asynchronously, by simply caling WebKit2.ScriptDialog.ref() on the dialog argument and calling WebKit2.ScriptDialog.close() when done. If the last reference is removed on a WebKit2.ScriptDialog and the dialog has not been closed, WebKit2.ScriptDialog.close() will be called.

WebKit2.WebView.signals.show_notification(web_view, notification)
Signal Name:

show-notification

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked. False otherwise.

Return type:

bool

This signal is emitted when a notification should be presented to the user. The notification is kept alive until either: 1) the web page cancels it or 2) a navigation happens.

The default handler will emit a notification using libnotify, if built with support for it.

New in version 2.8.

WebKit2.WebView.signals.show_option_menu(web_view, menu, event, rectangle)
Signal Name:

show-option-menu

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

This signal is emitted when a select element in web_view needs to display a dropdown menu. This signal can be used to show a custom menu, using menu to get the details of all items that should be displayed. The area of the element in the WebKit2.WebView is given as rectangle parameter, it can be used to position the menu. If this was triggered by a user interaction, like a mouse click, event parameter provides the Gdk.Event. To handle this signal asynchronously you should keep a ref of the menu.

The event parameter is now deprecated. Use WebKit2.OptionMenu.get_event() to get the Gdk.Event that triggered the dropdown menu.

The default signal handler will pop up a Gtk.Menu.

New in version 2.18.

WebKit2.WebView.signals.submit_form(web_view, request)
Signal Name:

submit-form

Flags:

RUN_LAST

Parameters:

This signal is emitted when a form is about to be submitted. The request argument passed contains information about the text fields of the form. This is typically used to store login information that can be used later to pre-fill the form. The form will not be submitted until WebKit2.FormSubmissionRequest.submit() is called.

It is possible to handle the form submission request asynchronously, by simply calling GObject.Object.ref() on the request argument and calling WebKit2.FormSubmissionRequest.submit() when done to continue with the form submission. If the last reference is removed on a WebKit2.FormSubmissionRequest and the form has not been submitted, WebKit2.FormSubmissionRequest.submit() will be called.

WebKit2.WebView.signals.user_message_received(web_view, message)
Signal Name:

user-message-received

Flags:

RUN_LAST

Parameters:
Returns:

True if the message was handled, or False otherwise.

Return type:

bool

This signal is emitted when a WebKit2.UserMessage is received from the #WebKitWebPage corresponding to web_view. You can reply to the message using WebKit2.UserMessage.send_reply().

You can handle the user message asynchronously by calling GObject.Object.ref() on message and returning True. If the last reference of message is removed and the message has not been replied to, the operation in the #WebKitWebPage will finish with error WebKit2.UserMessageError.MESSAGE.

New in version 2.28.

WebKit2.WebView.signals.web_process_crashed(web_view)
Signal Name:

web-process-crashed

Flags:

RUN_LAST

Parameters:

web_view (WebKit2.WebView) – The object which received the signal

Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

This signal is emitted when the web process crashes.

Deprecated since version 2.20: Use WebKit2.WebView ::web-process-terminated instead.

WebKit2.WebView.signals.web_process_terminated(web_view, reason)
Signal Name:

web-process-terminated

Flags:

RUN_LAST

Parameters:

This signal is emitted when the web process terminates abnormally due to reason.

New in version 2.20.

Property Details

WebKit2.WebView.props.automation_presentation_type
Name:

automation-presentation-type

Type:

WebKit2.AutomationBrowsingContextPresentation

Default Value:

WebKit2.AutomationBrowsingContextPresentation.WINDOW

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The WebKit2.AutomationBrowsingContextPresentation of WebKit2.WebView. This should only be used when creating a new WebKit2.WebView as a response to WebKit2.AutomationSession ::create-web-view signal request. If the new WebView was added to a new tab of current browsing context window WebKit2.AutomationBrowsingContextPresentation.TAB should be used.

New in version 2.28.

WebKit2.WebView.props.camera_capture_state
Name:

camera-capture-state

Type:

WebKit2.MediaCaptureState

Default Value:

WebKit2.MediaCaptureState.NONE

Flags:

READABLE, WRITABLE

Capture state of the camera device. Whenever the user grants a media-request sent by the web page, requesting video capture capabilities (navigator.mediaDevices.getUserMedia({video: true})) this property will be set to WebKit2.MediaCaptureState.ACTIVE.

The application can monitor this property and provide a visual indicator allowing to optionally deactivate or mute the capture device by setting this property respectively to WebKit2.MediaCaptureState.NONE or WebKit2.MediaCaptureState.MUTED.

If the capture state of the device is set to WebKit2.MediaCaptureState.NONE the web-page can still re-request the permission to the user. Permission desision caching is left to the application.

New in version 2.34.

WebKit2.WebView.props.default_content_security_policy
Name:

default-content-security-policy

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The default Content-Security-Policy used by the webview as if it were set by an HTTP header.

This applies to all content loaded including through navigation or via the various webkit_web_view_load_\* APIs. However do note that many WebKit APIs bypass Content-Security-Policy in general such as WebKit2.UserContentManager and WebKit2.WebView.run_javascript().

Policies are additive so if a website sets its own policy it still applies on top of the policy set here.

New in version 2.38.

WebKit2.WebView.props.display_capture_state
Name:

display-capture-state

Type:

WebKit2.MediaCaptureState

Default Value:

WebKit2.MediaCaptureState.NONE

Flags:

READABLE, WRITABLE

Capture state of the display device. Whenever the user grants a media-request sent by the web page, requesting screencasting capabilities (`navigator.mediaDevices.getDisplayMedia() this property will be set to WebKit2.MediaCaptureState.ACTIVE.

The application can monitor this property and provide a visual indicator allowing to optionally deactivate or mute the capture device by setting this property respectively to WebKit2.MediaCaptureState.NONE or WebKit2.MediaCaptureState.MUTED.

If the capture state of the device is set to WebKit2.MediaCaptureState.NONE the web-page can still re-request the permission to the user. Permission desision caching is left to the application.

New in version 2.34.

WebKit2.WebView.props.editable
Name:

editable

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the pages loaded inside WebKit2.WebView are editable. For more information see WebKit2.WebView.set_editable().

New in version 2.8.

WebKit2.WebView.props.estimated_load_progress
Name:

estimated-load-progress

Type:

float

Default Value:

0.0

Flags:

READABLE

An estimate of the percent completion for the current loading operation. This value will range from 0.0 to 1.0 and, once a load completes, will remain at 1.0 until a new load starts, at which point it will be reset to 0.0. The value is an estimate based on the total number of bytes expected to be received for a document, including all its possible subresources and child documents.

WebKit2.WebView.props.favicon
Name:

favicon

Type:

int

Default Value:

None

Flags:

READABLE

The favicon currently associated to the WebKit2.WebView. See WebKit2.WebView.get_favicon() for more details.

WebKit2.WebView.props.is_controlled_by_automation
Name:

is-controlled-by-automation

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Whether the WebKit2.WebView is controlled by automation. This should only be used when creating a new WebKit2.WebView as a response to WebKit2.AutomationSession ::create-web-view signal request.

New in version 2.18.

WebKit2.WebView.props.is_ephemeral
Name:

is-ephemeral

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Whether the WebKit2.WebView is ephemeral. An ephemeral web view never writes website data to the client storage, no matter what WebKit2.WebsiteDataManager its context is using. This is normally used to implement private browsing mode. This is a GObject.ParamFlags.CONSTRUCT_ONLY property, so you have to create an ephemeral WebKit2.WebView and it can’t be changed. The ephemeral WebKit2.WebsiteDataManager created for the WebKit2.WebView will inherit the network settings from the WebKit2.WebContext ‘s WebKit2.WebsiteDataManager. To use different settings you can get the WebKit2.WebsiteDataManager with WebKit2.WebView.get_website_data_manager() and set the new ones. Note that all WebKit2.WebView s created with an ephemeral WebKit2.WebContext will be ephemeral automatically. See also WebKit2.WebContext.new_ephemeral().

New in version 2.16.

WebKit2.WebView.props.is_loading
Name:

is-loading

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the WebKit2.WebView is currently loading a page. This property becomes True as soon as a new load operation is requested and before the WebKit2.WebView ::load-changed signal is emitted with WebKit2.LoadEvent.STARTED and at that point the active URI is the requested one. When the load operation finishes the property is set to False before WebKit2.WebView ::load-changed is emitted with WebKit2.LoadEvent.FINISHED.

WebKit2.WebView.props.is_muted
Name:

is-muted

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the WebKit2.WebView audio is muted. When True, audio is silenced. It may still be playing, i.e. WebKit2.WebView :is-playing-audio may be True.

New in version 2.30.

WebKit2.WebView.props.is_playing_audio
Name:

is-playing-audio

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the WebKit2.WebView is currently playing audio from a page. This property becomes True as soon as web content starts playing any kind of audio. When a page is no longer playing any kind of sound, the property is set back to False.

New in version 2.8.

WebKit2.WebView.props.is_web_process_responsive
Name:

is-web-process-responsive

Type:

bool

Default Value:

True

Flags:

READABLE

Whether the web process currently associated to the WebKit2.WebView is responsive.

New in version 2.34.

WebKit2.WebView.props.microphone_capture_state
Name:

microphone-capture-state

Type:

WebKit2.MediaCaptureState

Default Value:

WebKit2.MediaCaptureState.NONE

Flags:

READABLE, WRITABLE

Capture state of the microphone device. Whenever the user grants a media-request sent by the web page, requesting audio capture capabilities (navigator.mediaDevices.getUserMedia({audio: true})) this property will be set to WebKit2.MediaCaptureState.ACTIVE.

The application can monitor this property and provide a visual indicator allowing to optionally deactivate or mute the capture device by setting this property respectively to WebKit2.MediaCaptureState.NONE or WebKit2.MediaCaptureState.MUTED.

If the capture state of the device is set to WebKit2.MediaCaptureState.NONE the web-page can still re-request the permission to the user. Permission desision caching is left to the application.

New in version 2.34.

WebKit2.WebView.props.page_id
Name:

page-id

Type:

int

Default Value:

0

Flags:

READABLE

The identifier of the #WebKitWebPage corresponding to the WebKit2.WebView.

New in version 2.28.

WebKit2.WebView.props.related_view
Name:

related-view

Type:

WebKit2.WebView

Default Value:

None

Flags:

WRITABLE, CONSTRUCT_ONLY

The related WebKit2.WebView used when creating the view to share the same web process and network session. This property is not readable because the related web view is only valid during the object construction.

New in version 2.4.

WebKit2.WebView.props.settings
Name:

settings

Type:

WebKit2.Settings

Default Value:

None

Flags:

WRITABLE, CONSTRUCT

The WebKit2.Settings of the view.

New in version 2.6.

WebKit2.WebView.props.title
Name:

title

Type:

str

Default Value:

None

Flags:

READABLE

The main frame document title of this WebKit2.WebView. If the title has not been received yet, it will be None.

WebKit2.WebView.props.uri
Name:

uri

Type:

str

Default Value:

None

Flags:

READABLE

The current active URI of the WebKit2.WebView. See WebKit2.WebView.get_uri() for more details.

WebKit2.WebView.props.user_content_manager
Name:

user-content-manager

Type:

WebKit2.UserContentManager

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The WebKit2.UserContentManager of the view.

New in version 2.6.

WebKit2.WebView.props.web_context
Name:

web-context

Type:

WebKit2.WebContext

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The WebKit2.WebContext of the view.

WebKit2.WebView.props.web_extension_mode
Name:

web-extension-mode

Type:

WebKit2.WebExtensionMode

Default Value:

WebKit2.WebExtensionMode.NONE

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

This configures web_view to treat the content as a WebExtension.

Note that this refers to the web standard WebExtensions and not WebKitWebExtensions.

In practice this limits the Content-Security-Policies that are allowed to be set. Some details can be found in Chrome’s documentation.

New in version 2.38.

WebKit2.WebView.props.website_policies
Name:

website-policies

Type:

WebKit2.WebsitePolicies

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The WebKit2.WebsitePolicies for the view.

New in version 2.30.

WebKit2.WebView.props.zoom_level
Name:

zoom-level

Type:

float

Default Value:

1.0

Flags:

READABLE, WRITABLE

The zoom level of the WebKit2.WebView content. See WebKit2.WebView.set_zoom_level() for more details.