WebView#
Superclasses: WebViewBase, Widget, InitiallyUnowned, Object
Implemented Interfaces: Accessible, Buildable, ConstraintTarget
The central class of the WPE WebKit and WebKitGTK APIs.
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 WebView or
a data string. With Settings you can control various aspects
of the rendering and loading of the content.
Note that in WebKitGTK, WebView is scrollable by itself, so
you don’t need to embed it in a ScrolledWindow.
Constructors#
- class WebView
- classmethod new() Widget#
Creates a new
WebViewwith the defaultWebContext.Creates a new
WebViewwith the defaultWebContextand noUserContentManagerassociated with it. See also webkit_web_view_new_with_context(), webkit_web_view_new_with_user_content_manager(), and webkit_web_view_new_with_settings().
Methods#
- class WebView
- async call_async_javascript_function(self, body: str, length: int, arguments: Variant | None = None, world_name: str | None = None, source_uri: str | None = None) Value#
This is the awaitable version of
call_async_javascript_function().Added in version 2.40.
- Parameters:
body – the function body
length – length of
body, or -1 ifbodyis a nul-terminated stringarguments – a
Variantwith formata{sv}storing the function arguments, orNoneworld_name – the name of a
WebKitScriptWorldorNoneto use the defaultsource_uri – the source URI
- call_async_javascript_function(body: str, length: int, arguments: Variant | None = None, world_name: str | None = None, source_uri: str | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Asynchronously call
bodywithargumentsin the script world with nameworld_nameof the main frame current context inweb_view. Theargumentsvalues must be one of the following types, or contain only the following GVariant types: number, string and dictionary. The result of the operation can be a Promise that will be properly passed to the callback. Ifworld_nameisNone, the default world is used. Any value that is notNoneis a distin ct world. Thesource_uriwill be shown in exceptions and doesn’t affect the behavior of the script. When not provided, the document URL is used.Note that if
Settings:enable-javascript isFalse, this method will do nothing. If you want to use this method but still prevent web content from executing its own JavaScript, then useSettings:enable-javascript-markup.When the operation is finished,
callbackwill be called. You can then callcall_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:
static void web_view_javascript_finished (GObject *object, GAsyncResult *result, gpointer user_data) { JSCValue *value; GError *error = NULL; value = webkit_web_view_call_async_javascript_function_finish (WEBKIT_WEB_VIEW (object), result, &error); if (!value) { g_warning ("Error running javascript: %s", error->message); g_error_free (error); return; } if (jsc_value_is_number (value)) { gint32 int_value = jsc_value_to_string (value); JSCException *exception = jsc_context_get_exception (jsc_value_get_context (value)); if (exception) g_warning ("Error running javascript: %s", jsc_exception_get_message (exception)); else g_print ("Script result: %d\n", int_value); g_free (str_value); } else { g_warning ("Error running javascript: unexpected return value"); } g_object_unref (value); } static void web_view_evaluate_promise (WebKitWebView *web_view) { GVariantDict dict; g_variant_dict_init (&dict, NULL); g_variant_dict_insert (&dict, "count", "u", 42); GVariant *args = g_variant_dict_end (&dict); const gchar *body = "return new Promise((resolve) => { resolve(count); });"; webkit_web_view_call_async_javascript_function (web_view, body, -1, arguments, NULL, NULL, NULL, web_view_javascript_finished, NULL); }
Added in version 2.40.
- Parameters:
body – the function body
length – length of
body, or -1 ifbodyis a nul-terminated stringarguments – a
Variantwith formata{sv}storing the function arguments, orNoneworld_name – the name of a
WebKitScriptWorldorNoneto use the defaultsource_uri – the source URI
cancellable – a
CancellableorNoneto ignorecallback – a
AsyncReadyCallbackto call when the script finisheduser_data – the data to pass to callback function
- call_async_javascript_function_finish(result: AsyncResult) Value#
Finish an asynchronous operation started with
call_async_javascript_function().Added in version 2.40.
- Parameters:
result – a
AsyncResult
- async can_execute_editing_command(self, command: str) bool#
This is the awaitable version of
can_execute_editing_command().- Parameters:
command – the command to check
- can_execute_editing_command(command: str, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Asynchronously check if it is possible to execute the given editing command.
When the operation is finished,
callbackwill be called. You can then callcan_execute_editing_command_finish()to get the result of the operation.- Parameters:
command – the command to check
cancellable – a
CancellableorNoneto ignorecallback – a
AsyncReadyCallbackto call when the request is satisfieduser_data – the data to pass to callback function
- can_execute_editing_command_finish(result: AsyncResult) bool#
Finish an asynchronous operation started with
can_execute_editing_command().- Parameters:
result – a
AsyncResult
- can_show_mime_type(mime_type: str) bool#
Whether or not a MIME type can be displayed in
web_view.- Parameters:
mime_type – a MIME type
- do_authenticate(self, request: AuthenticationRequest) bool#
- Parameters:
request
- Parameters:
context_menu
hit_test_result
- do_decide_policy(self, decision: PolicyDecision, type: PolicyDecisionType) bool#
- Parameters:
decision
type
- do_insecure_content_detected(self, event: InsecureContentEvent) None#
- Parameters:
event
- do_load_failed(self, load_event: LoadEvent, failing_uri: str, error: GError) bool#
- Parameters:
load_event
failing_uri
error
- do_load_failed_with_tls_errors(self, failing_uri: str, certificate: TlsCertificate, errors: TlsCertificateFlags) bool#
- Parameters:
failing_uri
certificate
errors
- do_mouse_target_changed(self, hit_test_result: HitTestResult, modifiers: int) None#
- Parameters:
hit_test_result
modifiers
- do_permission_request(self, permission_request: PermissionRequest) bool#
- Parameters:
permission_request
- do_print_(self, print_operation: PrintOperation) bool#
- Parameters:
print_operation
- do_query_permission_state(self, query: PermissionStateQuery) bool#
- Parameters:
query
- do_resource_load_started(self, resource: WebResource, request: URIRequest) None#
- Parameters:
resource
request
- do_run_color_chooser(self, request: ColorChooserRequest) bool#
- Parameters:
request
- do_run_file_chooser(self, request: FileChooserRequest) bool#
- Parameters:
request
- do_script_dialog(self, dialog: ScriptDialog) bool#
- Parameters:
dialog
- do_show_notification(self, notification: Notification) bool#
- Parameters:
notification
- Parameters:
menu
rectangle
- do_submit_form(self, request: FormSubmissionRequest) None#
- Parameters:
request
- do_user_message_received(self, message: UserMessage) bool#
- Parameters:
message
- do_web_process_terminated(self, reason: WebProcessTerminationReason) None#
- Parameters:
reason
- download_uri(uri: str) Download#
Requests downloading of the specified URI string for
web_view.- Parameters:
uri – the URI to download
- async evaluate_javascript(self, script: str, length: int, world_name: str | None = None, source_uri: str | None = None) Value#
This is the awaitable version of
evaluate_javascript().Added in version 2.40.
- Parameters:
script – the script to evaluate
length – length of
script, or -1 ifscriptis a nul-terminated stringworld_name – the name of a
WebKitScriptWorldorNoneto use the defaultsource_uri – the source URI
- evaluate_javascript(script: str, length: int, world_name: str | None = None, source_uri: str | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Asynchronously evaluate
scriptin the script world with nameworld_nameof the main frame current context inweb_view. Ifworld_nameisNone, the default world is used. Any value that is notNoneis a distinct world. Thesource_uriwill be shown in exceptions and doesn’t affect the behavior of the script. When not provided, the document URL is used.Note that if
Settings:enable-javascript isFalse, this method will do nothing. If you want to use this method but still prevent web content from executing its own JavaScript, then useSettings:enable-javascript-markup.When the operation is finished,
callbackwill be called. You can then callevaluate_javascript_finish()to get the result of the operation.This is an example of using
evaluate_javascript()with a script returning a string:static void web_view_javascript_finished (GObject *object, GAsyncResult *result, gpointer user_data) { JSCValue *value; GError *error = NULL; value = webkit_web_view_evaluate_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error); if (!value) { g_warning ("Error running javascript: %s", error->message); g_error_free (error); return; } if (jsc_value_is_string (value)) { gchar *str_value = jsc_value_to_string (value); JSCException *exception = jsc_context_get_exception (jsc_value_get_context (value)); if (exception) g_warning ("Error running javascript: %s", jsc_exception_get_message (exception)); else g_print ("Script result: %s\n", str_value); g_free (str_value); } else { g_warning ("Error running javascript: unexpected return value"); } g_object_unref (value); } static void web_view_get_link_url (WebKitWebView *web_view, const gchar *link_id) { gchar *script = g_strdup_printf ("window.document.getElementById('%s').href;", link_id); webkit_web_view_evaluate_javascript (web_view, script, -1, NULL, NULL, NULL, web_view_javascript_finished, NULL); g_free (script); }
Added in version 2.40.
- Parameters:
script – the script to evaluate
length – length of
script, or -1 ifscriptis a nul-terminated stringworld_name – the name of a
WebKitScriptWorldorNoneto use the defaultsource_uri – the source URI
cancellable – a
CancellableorNoneto ignorecallback – a
AsyncReadyCallbackto call when the script finisheduser_data – the data to pass to callback function
- evaluate_javascript_finish(result: AsyncResult) Value#
Finish an asynchronous operation started with
evaluate_javascript().Added in version 2.40.
- Parameters:
result – a
AsyncResult
- execute_editing_command(command: str) None#
Request to execute the given
commandforweb_view.You can use
can_execute_editing_command()to check whether it’s possible to execute the command.- Parameters:
command – the command to execute
- execute_editing_command_with_argument(command: str, argument: str) None#
Request to execute the given
commandwithargumentforweb_view.You can use
can_execute_editing_command()to check whether it’s possible to execute the command.Added in version 2.10.
- Parameters:
command – the command to execute
argument – the command argument
- get_automation_presentation_type() AutomationBrowsingContextPresentation#
Get the presentation type of
WebViewwhen created for automation.Added in version 2.28.
- get_back_forward_list() BackForwardList#
Obtains the
BackForwardListassociated with the givenWebView.The
BackForwardListis owned by theWebView.
- get_background_color() RGBA#
Gets the color that is used to draw the
web_viewbackground.Gets the color that is used to draw the
web_viewbackground before the actual contents are rendered. For more information see alsoset_background_color()Added in version 2.8.
- get_camera_capture_state() MediaCaptureState#
Get the camera capture state of a
WebView.Added in version 2.34.
- get_context() WebContext#
Gets the web context of
web_view.
- get_default_content_security_policy() str | None#
Gets the configured default Content-Security-Policy.
Added in version 2.38.
- get_display_capture_state() MediaCaptureState#
Get the display capture state of a
WebView.Added in version 2.34.
- get_editor_state() EditorState#
Gets the web editor state of
web_view.Added in version 2.10.
- get_estimated_load_progress() float#
Gets the value of the
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
web_view.
- get_favicon() Texture#
Returns favicon currently associated to
web_view.Returns favicon currently associated to
web_view, if any. You can connect to notify::favicon signal ofweb_viewto be notified when the favicon is available.
- get_find_controller() FindController#
Gets the
FindController.Gets the
FindControllerthat will allow the caller to query theWebViewfor the text to look for.
- get_input_method_context() InputMethodContext | None#
Get the
InputMethodContextcurrently in use byweb_view.Get the
InputMethodContextcurrently in use byweb_view, orNoneif no input method is being used.Added in version 2.28.
- get_inspector() WebInspector#
Get the
WebInspectorassociated toweb_view
- get_is_web_process_responsive() bool#
Get whether the current web process of a
WebViewis responsive.Added in version 2.34.
- get_main_resource() WebResource#
Return the main resource of
web_view.
- get_microphone_capture_state() MediaCaptureState#
Get the microphone capture state of a
WebView.Added in version 2.34.
- get_network_session() NetworkSession#
Get the
NetworkSessionassociated toweb_view.Added in version 2.40.
- get_session_state() WebViewSessionState#
Gets the current session state of
web_viewAdded in version 2.12.
- get_settings() Settings#
Gets the
Settingscurrently applied toweb_view.If no other
Settingshave been explicitly applied toweb_viewwithset_settings(), the defaultSettingswill be returned. This method always returns a validSettingsobject. To modify any of theweb_viewsettings, you can either create a newSettingsobject withnew(), setting the desired preferences, and then replace the existingweb_viewsettings withset_settings()or get the existingweb_viewsettings and update it directly.Settingsobjects can be shared by multipleWebView<!– –>s, so modifying the settings of aWebViewwould affect otherWebView<!– –>s using the sameSettings.
- async get_snapshot(self, region: SnapshotRegion, options: SnapshotOptions) Texture#
This is the awaitable version of
get_snapshot().- Parameters:
region – the
SnapshotRegionfor this snapshotoptions –
SnapshotOptionsfor the snapshot
- get_snapshot(region: SnapshotRegion, options: SnapshotOptions, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Asynchronously retrieves a snapshot of
web_viewforregion.optionsspecifies how the snapshot should be rendered.When the operation is finished,
callbackwill be called. You must callget_snapshot_finish()to get the result of the operation.- Parameters:
region – the
SnapshotRegionfor this snapshotoptions –
SnapshotOptionsfor the snapshotcancellable – a
Cancellablecallback – a
AsyncReadyCallbackuser_data – user data
- get_snapshot_finish(result: AsyncResult) Texture#
Finishes an asynchronous operation started with
get_snapshot(), producing an image of the snapshot using the BGRA8888 pixel format.- Parameters:
result – a
AsyncResult
- get_theme_color() tuple[bool, RGBA]#
Gets the theme color that is specified by the content in the
web_view. If theweb_viewdoesn’t have a theme color it will fill thergbawith transparent black content.Added in version 2.50.
- get_title() str#
Gets the value of the
WebView:title property.You can connect to notify::title signal of
web_viewto be notified when the title has been received.
- get_tls_info() tuple[bool, TlsCertificate, TlsCertificateFlags]#
Retrieves the
TlsCertificateassociated with the main resource ofweb_view.Retrieves the
TlsCertificateassociated with the main resource ofweb_view, and theTlsCertificateFlagsshowing what problems, if any, have been found with that certificate. If the connection is not HTTPS, this function returnsFalse. This function should be called after a response has been received from the server, so you can connect toWebView::load-changed and call this function when it’s emitted withCOMMITTEDevent.Note that this function provides no information about the security of the web page if the current
TLSErrorsPolicyisIGNORE, 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 currentTLSErrorsPolicyisFAIL, in which case subresources that fail certificate verification will be blocked.
- get_uri() str#
Returns the current active URI of
web_view.The active URI might change during a load operation:
<orderedlist> <listitem><para>
When nothing has been loaded yet on
web_viewthe active URI isNone.</para></listitem> <listitem><para>
When a new load operation starts the active URI is the requested URI: <itemizedlist> <listitem><para>
If the load operation was started by
load_uri(), the requested URI is the given one.</para></listitem> <listitem><para>
If the load operation was started by
load_html(), the requested URI is “about:blank”.</para></listitem> <listitem><para>
If the load operation was started by
load_alternate_html(), the requested URI is content URI provided.</para></listitem> <listitem><para>
If the load operation was started by
go_back()orgo_forward(), the requested URI is the original URI of the previous/next item in theBackForwardListofweb_view.</para></listitem> <listitem><para>
If the load operation was started by
go_to_back_forward_list_item(), the requested URI is the opriginal URI of the givenBackForwardListItem.</para></listitem> </itemizedlist>
</para></listitem> <listitem><para>
If there is a server redirection during the load operation, the active URI is the redirected URI. When the signal
WebView::load-changed is emitted withREDIRECTEDevent, the active URI is already updated to the redirected URI.</para></listitem> <listitem><para>
</para></listitem> </orderedlist>
You can monitor the active URI by connecting to the notify::uri signal of
web_view.
- get_user_content_manager() UserContentManager#
Gets the user content manager associated to
web_view.Added in version 2.6.
- get_web_extension_mode() WebExtensionMode#
Get the view’s
WebExtensionMode.Added in version 2.38.
- get_website_policies() WebsitePolicies#
Gets the default website policies.
Gets the default website policies set on construction in the
web_view. These can be overridden on a per-origin basis via theWebView::decide-policy signal handler.See also
use_with_policies().Added in version 2.30.
- get_window_properties() WindowProperties#
Get the
WindowPropertiesobject.Get the
WindowPropertiesobject containing the properties that the window containingweb_viewshould have.
- get_zoom_level() float#
Set the zoom level of
web_view.Get the zoom level of
web_view, i.e. the factor by which the view contents are scaled with respect to their original size.
- go_back() None#
Loads the previous history item.
You can monitor the load operation by connecting to
WebView::load-changed signal.
- go_forward() None#
Loads the next history item.
You can monitor the load operation by connecting to
WebView::load-changed signal.
- go_to_back_forward_list_item(list_item: BackForwardListItem) None#
Loads the specific history item
list_item.You can monitor the load operation by connecting to
WebView::load-changed signal.- Parameters:
list_item – a
BackForwardListItem
- is_controlled_by_automation() bool#
Get whether a
WebViewwas created withWebView:is-controlled-by-automation property enabled.Only
WebView<!– –>s controlled by automation can be used in an automation session.Added in version 2.18.
- is_editable() bool#
Gets whether the user is allowed to edit the HTML document.
When
web_viewis 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 aWebViewis not editable.Added in version 2.8.
- is_immersive_mode_enabled() bool#
Gets whether
web_viewis in immersive mode.An immersive session is a mode in which the user is presented with a fully immersive XR experience (such as VR or AR), typically rendered via a headset.
Note that if WebXR is disabled or OPENXR is not used, this API always returns
False.Added in version 2.52.
- is_loading() bool#
Gets the value of the
WebView:is-loading property.You can monitor when a
WebViewis loading a page by connecting to notify::is-loading signal ofweb_view. 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() bool#
Gets the value of the
WebView:is-playing-audio property.You can monitor when a page in a
WebViewis playing audio by connecting to the notify::is-playing-audio signal ofweb_view. This is useful when the application wants to provide visual feedback when a page is producing sound.Added in version 2.8.
- leave_immersive_mode() None#
Requests to leave the immersive mode this
WebViewis in.Users interact with web content to start XR sessions, and can typically end the sessions themselves, but applications might need to end a session on their own based on application or platform logic.
Note that if WebXR is disabled, or if it is enabled but the
web_viewis not in immersive mode, this API does nothing. See alsois_immersive_mode_enabled().Added in version 2.52.
- load_alternate_html(content: str, content_uri: str, base_uri: str | None = None) None#
Load the given
contentstring for the URIcontent_uri.This allows clients to display page-loading errors in the
WebViewitself. When this method is called fromWebView::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 asload_html().- Parameters:
content – the new content to display as the main page of the
web_viewcontent_uri – the URI for the alternate page content
base_uri – the base URI for relative locations or
None
- load_bytes(bytes: Bytes, mime_type: str | None = None, encoding: str | None = None, base_uri: str | None = None) None#
Load the specified
bytesintoweb_viewusing the givenmime_typeandencoding.When
mime_typeisNone, it defaults to “text/html”. WhenencodingisNone, it defaults to “UTF-8”. Whenbase_uriisNone, it defaults to “about:blank”. You can monitor the load operation by connecting toWebView::load-changed signal.Added in version 2.6.
- Parameters:
bytes – input data to load
mime_type – the MIME type of
bytes, orNoneencoding – the character encoding of
bytes, orNonebase_uri – the base URI for relative locations or
None
- load_html(content: str, base_uri: str | None = None) None#
Load the given
contentstring with the specifiedbase_uri.If
base_uriis notNone, relative URLs in thecontentwill be resolved againstbase_uriand absolute local paths must be children of thebase_uri. For security reasons absolute local paths that are not children ofbase_uriwill cause the web process to terminate. If you need to include URLs incontentthat are local paths in a different directory thanbase_uriyou can build a data URI for them. Whenbase_uriisNone, it defaults to “about:blank”. The mime type of the document will be “text/html”. You can monitor the load operation by connecting toWebView::load-changed signal.- Parameters:
content – The HTML string to load
base_uri – The base URI for relative locations or
None
- load_plain_text(plain_text: str) None#
Load the specified
plain_textstring intoweb_view.The mime type of document will be “text/plain”. You can monitor the load operation by connecting to
WebView::load-changed signal.- Parameters:
plain_text – The plain text to load
- load_request(request: URIRequest) None#
Requests loading of the specified
URIRequest.You can monitor the load operation by connecting to
WebView::load-changed signal.- Parameters:
request – a
URIRequestto load
- load_uri(uri: str) None#
Requests loading of the specified URI string.
You can monitor the load operation by connecting to
WebView::load-changed signal.- Parameters:
uri – an URI string
- reload() None#
Reloads the current contents of
web_view.See also
reload_bypass_cache().
- restore_session_state(state: WebViewSessionState) None#
Restore the
web_viewsession state fromstateAdded in version 2.12.
- Parameters:
state – a
WebViewSessionState
- async save(self, save_mode: SaveMode) InputStream#
This is the awaitable version of
save().- Parameters:
save_mode – the
SaveModespecifying how the web page should be saved.
- save(save_mode: SaveMode, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Asynchronously save the current web page.
Asynchronously save the current web page associated to the
WebViewinto a self-contained format using the mode specified insave_mode.When the operation is finished,
callbackwill be called. You can then callsave_finish()to get the result of the operation.- Parameters:
save_mode – the
SaveModespecifying how the web page should be saved.cancellable – a
CancellableorNoneto ignorecallback – a
AsyncReadyCallbackto call when the request is satisfieduser_data – the data to pass to callback function
- save_finish(result: AsyncResult) InputStream#
Finish an asynchronous operation started with
save().- Parameters:
result – a
AsyncResult
- async save_to_file(self, file: File, save_mode: SaveMode) bool#
This is the awaitable version of
save_to_file().
- save_to_file(file: File, save_mode: SaveMode, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Asynchronously save the current web page.
Asynchronously save the current web page associated to the
WebViewinto a self-contained format using the mode specified insave_modeand writing it tofile.When the operation is finished,
callbackwill be called. You can then callsave_to_file_finish()to get the result of the operation.- Parameters:
file – the
Filewhere the current web page should be saved to.save_mode – the
SaveModespecifying how the web page should be saved.cancellable – a
CancellableorNoneto ignorecallback – a
AsyncReadyCallbackto call when the request is satisfieduser_data – the data to pass to callback function
- save_to_file_finish(result: AsyncResult) bool#
Finish an asynchronous operation started with
save_to_file().- Parameters:
result – a
AsyncResult
- async send_message_to_page(self, message: UserMessage) UserMessage#
This is the awaitable version of
send_message_to_page().Added in version 2.28.
- Parameters:
message – a
UserMessage
- send_message_to_page(message: UserMessage, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Send
messageto theWebKitWebPagecorresponding toweb_view.If
messageis floating, it’s consumed. If you don’t expect any reply, or you simply want to ignore it, you can passNoneascallback. When the operation is finished,callbackwill be called. You can then callsend_message_to_page_finish()to get the message reply.Added in version 2.28.
- Parameters:
message – a
UserMessagecancellable – a
CancellableorNoneto ignorecallback – (nullable): A
AsyncReadyCallbackto call when the request is satisfied orNoneuser_data – the data to pass to callback function
- send_message_to_page_finish(result: AsyncResult) UserMessage#
Finish an asynchronous operation started with
send_message_to_page().Added in version 2.28.
- Parameters:
result – a
AsyncResult
- set_background_color(rgba: RGBA) None#
Sets the color that will be used to draw the
web_viewbackground.Sets the color that will be used to draw the
web_viewbackground before the actual contents are rendered. Note that if the web page loaded inweb_viewspecifies a background color, it will take precedence over thergbacolor. By default theweb_viewbackground color is opaque white.Added in version 2.8.
- Parameters:
rgba – a
RGBA
- set_camera_capture_state(state: MediaCaptureState) None#
Set the camera capture state of a
WebView.If
Settings:enable-mediastream isFalse, this method will have no visible effect. Once the state of the device has been set toNONEit cannot be changed anymore. The page can however request capture again using the mediaDevices API.Added in version 2.34.
- Parameters:
state – a
MediaCaptureState
- set_cors_allowlist(allowlist: list[str] | None = None) None#
Sets the
allowlistfor CORS.Sets the
allowlistfor which Cross-Origin Resource Sharing checks are disabled inweb_view. 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.
Added in version 2.34.
- Parameters:
allowlist – an allowlist of URI patterns, or
None
- set_custom_charset(charset: str | None = None) None#
Sets the current custom character encoding override of
web_view.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
Noneremoves the character encoding override.- Parameters:
charset – a character encoding name or
None
- set_display_capture_state(state: MediaCaptureState) None#
Set the display capture state of a
WebView.If
Settings:enable-mediastream isFalse, this method will have no visible effect. Once the state of the device has been set toNONEit cannot be changed anymore. The page can however request capture again using the mediaDevices API.Added in version 2.34.
- Parameters:
state – a
MediaCaptureState
- set_editable(editable: bool) None#
Sets whether the user is allowed to edit the HTML document.
If
editableisTrue,web_viewallows the user to edit the HTML document. IfeditableisFalse, an element inweb_view's document can only be edited if the CONTENTEDITABLE attribute has been set on the element or one of its parent elements. By default aWebViewis 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
WebVieweditable without altering the document or DOM structure.Added in version 2.8.
- Parameters:
editable – a
gbooleanindicating the editable state
- set_input_method_context(context: InputMethodContext | None = None) None#
Set the
InputMethodContextto be used byweb_view.Set the
InputMethodContextto be used byweb_view, orNoneto not use any input method. Note that the sameInputMethodContextcan’t be set on more than oneWebViewat the same time.Added in version 2.28.
- Parameters:
context – the
InputMethodContextto set, orNone
- set_is_muted(muted: bool) None#
Sets the mute state of
web_view.Added in version 2.30.
- Parameters:
muted – mute flag
- set_microphone_capture_state(state: MediaCaptureState) None#
Set the microphone capture state of a
WebView.If
Settings:enable-mediastream isFalse, this method will have no visible effect. Once the state of the device has been set toNONEit cannot be changed anymore. The page can however request capture again using the mediaDevices API.Added in version 2.34.
- Parameters:
state – a
MediaCaptureState
- set_settings(settings: Settings) None#
Sets the
Settingsto be applied toweb_view.The existing
Settingsofweb_viewwill be replaced bysettings. New settings are applied immediately onweb_view. The sameSettingsobject can be shared by multipleWebView<!– –>s.- Parameters:
settings – a
Settings
- set_zoom_level(zoom_level: float) None#
Set the zoom level of
web_view.Set the zoom level of
web_view, i.e. the factor by which the view contents are scaled with respect to their original size.- Parameters:
zoom_level – the zoom level
- stop_loading() None#
Stops any ongoing loading operation in
web_view.This method does nothing if no content is being loaded. If there is a loading operation in progress, it will be cancelled and
WebView::load-failed signal will be emitted withCANCELLEDerror.
- terminate_web_process() None#
Terminates the web process associated to
web_view.When the web process gets terminated using this method, the
WebView::web-process-terminated signal is emitted withTERMINATED_BY_APIas the reason for termination.Added in version 2.34.
- try_close() None#
Tries to close the
web_view.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
WebView::close signal is emitted, otherwise nothing happens.Added in version 2.12.
Properties#
- class WebView
- props.automation_presentation_type: AutomationBrowsingContextPresentation#
The
AutomationBrowsingContextPresentationofWebView. This should only be used when creating a newWebViewas a response toAutomationSession::create-web-view signal request. If the new WebView was added to a new tab of current browsing context windowTABshould be used.Added in version 2.28.
- props.camera_capture_state: MediaCaptureState#
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 toACTIVE.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
NONEorMUTED.If the capture state of the device is set to
NONEthe web-page can still re-request the permission to the user. Permission desision caching is left to the application.Added in version 2.34.
- props.default_content_security_policy: str#
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 asUserContentManagerand webkit_web_view_run_javascript().Policies are additive so if a website sets its own policy it still applies on top of the policy set here.
Added in version 2.38.
- props.display_capture_state: MediaCaptureState#
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 :const:`~gi.repository.WebKit.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
NONEorMUTED.If the capture state of the device is set to
NONEthe web-page can still re-request the permission to the user. Permission desision caching is left to the application.Added in version 2.34.
- props.editable: bool#
Whether the pages loaded inside
WebVieware editable. For more information seeset_editable().Added in version 2.8.
- props.estimated_load_progress: float#
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.
- props.favicon: Texture#
The favicon currently associated to the
WebView. Seeget_favicon()for more details.
- props.is_controlled_by_automation: bool#
Whether the
WebViewis controlled by automation tools (e.g. WebDriver, Selenium). This is required for views returned as a response toAutomationSession::create-web-view signal, alongside any view you want to control during an automation session.As a %G_PARAM_CONSTRUCT_ONLY, you need to set it during construction and it can’t be modified.
If
WebView:related-view is also passed during construction,WebView:is-controlled-by-automation ignores its own parameter and inherits directly from the related viewWebView:is-controlled-by-automation property. This is the recommended way when creating new views as a response to theWebView::create signal. For example, as response to JavaScriptwindow.open()calls during an automation session.Added in version 2.18.
- props.is_immersive_mode_enabled: bool#
Whether the
WebViewis in immersive mode.Added in version 2.52.
- props.is_loading: bool#
Whether the
WebViewis currently loading a page. This property becomesTrueas soon as a new load operation is requested and before theWebView::load-changed signal is emitted withSTARTEDand at that point the active URI is the requested one. When the load operation finishes the property is set toFalsebeforeWebView::load-changed is emitted withFINISHED.
- props.is_muted: bool#
Whether the
WebViewaudio is muted. WhenTrue, audio is silenced. It may still be playing, i.e.WebView:is-playing-audio may beTrue.Added in version 2.30.
- props.is_playing_audio: bool#
Whether the
WebViewis currently playing audio from a page. This property becomesTrueas 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 toFalse.Added in version 2.8.
- props.is_web_process_responsive: bool#
Whether the web process currently associated to the
WebViewis responsive.Added in version 2.34.
- props.microphone_capture_state: MediaCaptureState#
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 toACTIVE.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
NONEorMUTED.If the capture state of the device is set to
NONEthe web-page can still re-request the permission to the user. Permission desision caching is left to the application.Added in version 2.34.
- props.network_session: NetworkSession#
The
NetworkSessionof the viewAdded in version 2.40.
- props.page_id: int#
The identifier of the
WebKitWebPagecorresponding to theWebView.Added in version 2.28.
The related
WebViewused 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.Added in version 2.4.
- props.title: str#
The main frame document title of this
WebView. If the title has not been received yet, it will beNone.
- props.user_content_manager: UserContentManager#
The
UserContentManagerof the view.Added in version 2.6.
- props.web_context: WebContext#
The
WebContextof the view.
- props.web_extension_mode: WebExtensionMode#
This configures
web_viewto 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.
Added in version 2.38.
- props.website_policies: WebsitePolicies#
The
WebsitePoliciesfor the view.Added in version 2.30.
- props.zoom_level: float#
The zoom level of the
WebViewcontent. Seeset_zoom_level()for more details.
Signals#
- class WebView.signals
- authenticate(request: AuthenticationRequest) 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
AuthenticationRequestin therequestargument. To handle this signal asynchronously you should keep a ref of the request and returnTrue. To disable HTTP authentication entirely, connect to this signal and simply returnTrue.The default signal handler will run a default authentication dialog asynchronously for the user to interact with.
Added in version 2.2.
- Parameters:
request – a
AuthenticationRequest
- close() None#
Emitted when closing a
WebViewis requested. This occurs when a call is made from JavaScript’s <function>window.close</function> function or after trying to close theweb_viewwithtry_close(). It is the owner’s responsibility to handle this signal to hide or destroy theWebView, if necessary.
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. <itemizedlist> <listitem><para>
To customize the proposed menu you can use
prepend(),append()orinsert()to add newContextMenuItem<!– –>s tocontext_menu,move_item()to reorder existing items, orremove()to remove an existing item. The signal handler should returnFalse, and the menu represented bycontext_menuwill be shown.</para></listitem> <listitem><para>
To prevent the menu from being displayed you can just connect to this signal and return
Trueso that the proposed menu will not be shown.</para></listitem> <listitem><para>
To build your own menu, you can remove all items from the proposed menu with
remove_all(), add your own items and returnFalseso that the menu will be shown. You can also ignore the proposedContextMenu, build your ownGtkMenuand returnTrueto prevent the proposed menu from being shown.</para></listitem> <listitem><para>
If you just want the default menu to be shown always, simply don’t connect to this signal because showing the proposed context menu is the default behaviour.
</para></listitem> </itemizedlist>
If the signal handler returns
Falsethe context menu represented bycontext_menuwill be shown, if it returnTruethe context menu will not be shown.The proposed
ContextMenupassed incontext_menuargument is only valid during the signal emission.- Parameters:
context_menu – the proposed
ContextMenuhit_test_result – a
HitTestResult
Emitted after
WebView::context-menu signal, if the context menu is shown, to notify that the context menu is dismissed.
- create(navigation_action: NavigationAction) Widget#
Emitted when the creation of a new
WebViewis requested. If this signal is handled the signal handler should return the newly createdWebView.The
NavigationActionparameter contains information about the navigation action that triggered this signal.The new
WebViewmust be related toweb_view, seeWebView:related-view for more details.The new
WebViewshould not be displayed to the user until theWebView::ready-to-show signal is emitted.For creating views as response to automation tools requests, see the
AutomationSession::create-web-view signal.- Parameters:
navigation_action – a
NavigationAction
- decide_policy(decision: PolicyDecision, decision_type: PolicyDecisionType) 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
NavigationPolicyDecisionpassed in thedecisionargument is a generic type, but should be casted to a more specific type when making the decision. For example: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
ref()on thedecisionargument and returningTrueto block the default signal handler. If the last reference is removed on aPolicyDecisionand no decision has been made explicitly,use()will be the default policy decision. The default signal handler will simply calluse(). Only the first policy decision chosen for a givenPolicyDecisionwill have any affect.- Parameters:
decision – the
PolicyDecisiondecision_type – a
PolicyDecisionTypedenoting the type ofdecision
- enter_fullscreen() bool#
Emitted when JavaScript code calls <function>element.webkitRequestFullScreen</function>. If the signal is not handled the
WebViewwill 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).
- insecure_content_detected(event: InsecureContentEvent) None#
Prior to 2.46, this signal was emitted when insecure content was loaded in a secure content. Since 2.46, this signal is generally no longer emitted.
Deprecated since version 2.46: Please do not use it in newly written code
- Parameters:
event – the
InsecureContentEvent
- leave_fullscreen() bool#
Emitted when the
WebViewis 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 theWebView::enter-fullscreen stage for instance.
- load_changed(load_event: LoadEvent) None#
Emitted when a load operation in
web_viewchanges. The signal is always emitted withSTARTEDwhen a new load request is made andFINISHEDwhen the load finishes successfully or due to an error. When the ongoing load operation failsWebView::load-failed signal is emitted beforeWebView::load-changed is emitted withFINISHED. If a redirection is received from the server, this signal is emitted withREDIRECTEDafter the initial emission withSTARTEDand beforeCOMMITTED. When the page content starts arriving the signal is emitted withCOMMITTEDevent.You can handle this signal and use a switch to track any ongoing load operation.
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; } }
- Parameters:
load_event – the
LoadEvent
- load_failed(load_event: LoadEvent, failing_uri: str, error: GError) bool#
Emitted when an error occurs during a load operation. If the error happened when starting to load data for a page
load_eventwill beSTARTED. If it happened while loading a committed data sourceload_eventwill beCOMMITTED. Since a load error causes the load operation to finish, the signal WebKitWebView::load-changed will always be emitted withFINISHEDevent 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.
- load_failed_with_tls_errors(failing_uri: str, certificate: TlsCertificate, errors: TlsCertificateFlags) bool#
Emitted when a TLS error occurs during a load operation. To allow an exception for this
certificateand the host offailing_uriuse webkit_web_context_allow_tls_certificate_for_host().To handle this signal asynchronously you should call
ref()oncertificateand returnTrue.If
Falseis returned,WebView::load-failed will be emitted. The load will finish regardless of the returned value.Added in version 2.6.
- Parameters:
failing_uri – the URI that failed to load
certificate – a
TlsCertificateerrors – a
TlsCertificateFlagswith the verification status ofcertificate
- mouse_target_changed(hit_test_result: HitTestResult, modifiers: int) None#
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_resultargument. Themodifiersargument is a bitmask ofModifierTypeflags indicating the state of modifier keys. The signal is emitted again when the mouse is moved out of the current element with a newhit_test_result.- Parameters:
hit_test_result – a
HitTestResultmodifiers – a bitmask of
ModifierType
- permission_request(request: PermissionRequest) 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:
static gboolean permission_request_cb (WebKitWebView *web_view, WebKitPermissionRequest *request, GtkWindow *parent_window) { GtkWidget *dialog = gtk_message_dialog_new (parent_window, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Allow Permission Request?"); gtk_widget_show (dialog); gint result = gtk_dialog_run (GTK_DIALOG (dialog)); switch (result) { case GTK_RESPONSE_YES: webkit_permission_request_allow (request); break; default: webkit_permission_request_deny (request); break; } gtk_widget_destroy (dialog); return TRUE; }
It is possible to handle permission requests asynchronously, by simply calling
ref()on therequestargument and returningTrueto block the default signal handler. If the last reference is removed on aPermissionRequestand the request has not been handled,deny()will be the default action.If the signal is not handled, the
requestwill be completed automatically by the specificPermissionRequestthat could allow or deny it. Check the documentation of classes implementingPermissionRequestinterface to know their default action.- Parameters:
request – the
PermissionRequest
- print_(print_operation: PrintOperation) bool#
- Parameters:
print_operation
- query_permission_state(query: PermissionStateQuery) 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
finish().You can handle the query asynchronously by calling
ref()onqueryand returningTrue. If the last reference ofqueryis removed and the query has not been handled, the query result will be set to %WEBKIT_QUERY_PERMISSION_PROMPT.Added in version 2.40.
- Parameters:
query – the
PermissionStateQuery
- ready_to_show() None#
Emitted after
WebView::create on the newly createdWebViewwhen 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 theWindowPropertiesofweb_view. See alsoget_window_properties().
- resource_load_started(resource: WebResource, request: URIRequest) None#
Emitted when a new resource is going to be loaded. The
requestparameter contains theURIRequestthat will be sent to the server. You can monitor the load operation by connecting to the different signals ofresource.- Parameters:
resource – a
WebResourcerequest – a
URIRequest
- run_as_modal() None#
Emitted after
WebView::ready-to-show on the newly createdWebViewwhen JavaScript code calls <function>window.showModalDialog</function>. 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 parentWebViewuntil the new dialog is closed.
- run_color_chooser(request: ColorChooserRequest) bool#
This signal is emitted when the user interacts with a <input type=’color’ /> 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
ColorChooserRequestin therequestargument.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
ColorChooserfor the user to interact with.Added in version 2.8.
- Parameters:
request – a
ColorChooserRequest
- run_file_chooser(request: FileChooserRequest) bool#
This signal is emitted when the user interacts with a <input type=’file’ /> 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
FileChooserRequestin therequestargument.The default signal handler will asynchronously run a regular
GtkFileChooserDialogfor the user to interact with.- Parameters:
request – a
FileChooserRequest
- script_dialog(dialog: ScriptDialog) bool#
Emitted when JavaScript code calls <function>window.alert</function>, <function>window.confirm</function> or <function>window.prompt</function>, or when <function>onbeforeunload</function> event is fired. The
dialogparameter 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: <itemizedlist> <listitem><para>ALERT: message dialog with a single Close button.</para></listitem> <listitem><para>
CONFIRM: message dialog with OK and Cancel buttons.</para></listitem> <listitem><para>
PROMPT: message dialog with OK and Cancel buttons and a text entry with the default text.</para></listitem> <listitem><para>
BEFORE_UNLOAD_CONFIRM: message dialog with Stay and Leave buttons.</para></listitem> </itemizedlist>
It is possible to handle the script dialog request asynchronously, by simply caling
ref()on thedialogargument and callingclose()when done. If the last reference is removed on aScriptDialogand the dialog has not been closed,close()will be called.- Parameters:
dialog – the
ScriptDialogto show
- show_notification(notification: Notification) bool#
This signal is emitted when a notification should be presented to the user. The
notificationis 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.
Added in version 2.8.
- Parameters:
notification – a
Notification
This signal is emitted when a select element in
web_viewneeds to display a dropdown menu. This signal can be used to show a custom menu, usingmenuto get the details of all items that should be displayed. The area of the element in theWebViewis given asrectangleparameter, it can be used to position the menu. To handle this signal asynchronously you should keep a ref of themenu.The default signal handler will pop up a
GtkMenu.Added in version 2.18.
- Parameters:
menu – the
OptionMenurectangle – the option element area
- submit_form(request: FormSubmissionRequest) None#
This signal is emitted when a form is about to be submitted. The
requestargument 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 untilsubmit()is called.It is possible to handle the form submission request asynchronously, by simply calling
ref()on therequestargument and callingsubmit()when done to continue with the form submission. If the last reference is removed on aFormSubmissionRequestand the form has not been submitted,submit()will be called.- Parameters:
request – a
FormSubmissionRequest
- user_message_received(message: UserMessage) bool#
This signal is emitted when a
UserMessageis received from theWebKitWebPagecorresponding toweb_view. You can reply to the message usingsend_reply().You can handle the user message asynchronously by calling
ref()onmessageand returningTrue. If the last reference ofmessageis removed and the message has not been replied to, the operation in theWebKitWebPagewill finish with errorMESSAGE.Added in version 2.28.
- Parameters:
message – the
UserMessagereceived
- web_process_terminated(reason: WebProcessTerminationReason) None#
This signal is emitted when the web process terminates abnormally due to
reason.Added in version 2.20.
- Parameters:
reason – the a
WebProcessTerminationReason
Virtual Methods#
- class WebView
- do_authenticate(request: AuthenticationRequest) bool#
- Parameters:
request
- do_context_menu(context_menu: ContextMenu, hit_test_result: HitTestResult) bool#
- Parameters:
context_menu
hit_test_result
- do_decide_policy(decision: PolicyDecision, type: PolicyDecisionType) bool#
- Parameters:
decision
type
- do_insecure_content_detected(event: InsecureContentEvent) None#
- Parameters:
event
- do_load_failed(load_event: LoadEvent, failing_uri: str, error: GError) bool#
- Parameters:
load_event
failing_uri
error
- do_load_failed_with_tls_errors(failing_uri: str, certificate: TlsCertificate, errors: TlsCertificateFlags) bool#
- Parameters:
failing_uri
certificate
errors
- do_mouse_target_changed(hit_test_result: HitTestResult, modifiers: int) None#
- Parameters:
hit_test_result
modifiers
- do_permission_request(permission_request: PermissionRequest) bool#
- Parameters:
permission_request
- do_print_(print_operation: PrintOperation) bool#
- Parameters:
print_operation
- do_query_permission_state(query: PermissionStateQuery) bool#
- Parameters:
query
- do_resource_load_started(resource: WebResource, request: URIRequest) None#
- Parameters:
resource
request
- do_run_color_chooser(request: ColorChooserRequest) bool#
- Parameters:
request
- do_run_file_chooser(request: FileChooserRequest) bool#
- Parameters:
request
- do_script_dialog(dialog: ScriptDialog) bool#
- Parameters:
dialog
- do_show_notification(notification: Notification) bool#
- Parameters:
notification
- do_show_option_menu(menu: OptionMenu, rectangle: Rectangle) bool#
- Parameters:
menu
rectangle
- do_submit_form(request: FormSubmissionRequest) None#
- Parameters:
request
- do_user_message_received(message: UserMessage) bool#
- Parameters:
message
- do_web_process_terminated(reason: WebProcessTerminationReason) None#
- Parameters:
reason