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 |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w/co |
|||
r/w |
|||
r/w/co |
|||
r/w |
|||
r/w |
|||
r |
|||
r |
|||
r/w/co |
|||
r/w/co |
|||
r |
|||
r/w |
|||
r |
|||
r |
|||
r/w |
|||
r |
|||
w/co |
|||
w/c |
|||
r |
|||
r |
|||
r/w/co |
|||
r/w/co |
|||
r/w/co |
|||
r/w/co |
|||
r/w |
Style Properties¶
- Inherited:
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
This signal is emitted when the user is challenged with HTTP authentication. |
|
Emitted when closing a |
|
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. |
|
Emitted after |
|
Emitted when the creation of a new |
|
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. |
|
Emitted when JavaScript code calls element.webkitRequestFullScreen. |
|
Prior to 2.46, this signal was emitted when insecure content was loaded in a secure content. |
|
Emitted when the |
|
Emitted when a load operation in web_view changes. |
|
Emitted when an error occurs during a load operation. |
|
Emitted when a TLS error occurs during a load operation. |
|
This signal is emitted when the mouse cursor moves over an element such as a link, image or a media element. |
|
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. |
|
Emitted when printing is requested on web_view, usually by a JavaScript call, before the print dialog is shown. |
|
This signal allows the User-Agent to respond to permission requests for powerful features, as specified by the Permissions W3C Specification. |
|
Emitted after |
|
Emitted when a new resource is going to be loaded. |
|
Emitted after |
|
This signal is emitted when the user interacts with a HTML element, requesting from WebKit to show a dialog to select a color. |
|
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. |
|
Emitted when JavaScript code calls window.alert, window.confirm or window.prompt, or when onbeforeunload event is fired. |
|
This signal is emitted when a notification should be presented to the user. |
|
This signal is emitted when a select element in web_view needs to display a dropdown menu. |
|
This signal is emitted when a form is about to be submitted. |
|
This signal is emitted when a |
|
This signal is emitted when the web process crashes. |
|
This signal is emitted when the web process terminates abnormally due to reason. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent |
r |
Class Details¶
- class WebKit2.WebView(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
The central class of the WPE WebKit and WebKitGTK APIs.
WebKit2.WebViewis 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 theWebKit2.WebViewor a data string. WithWebKit2.Settingsyou can control various aspects of the rendering and loading of the content.Note that in WebKitGTK,
WebKit2.WebViewis scrollable by itself, so you don’t need to embed it in aGtk.ScrolledWindow.- classmethod new()¶
- Returns:
The newly created
WebKit2.WebViewwidget- Return type:
Creates a new
WebKit2.WebViewwith the defaultWebKit2.WebContext.Creates a new
WebKit2.WebViewwith the defaultWebKit2.WebContextand noWebKit2.UserContentManagerassociated with it. See alsoWebKit2.WebView.new_with_context(),WebKit2.WebView.new_with_user_content_manager(), andWebKit2.WebView.new_with_settings().
- classmethod new_with_context(context)¶
- Parameters:
context (
WebKit2.WebContext) – theWebKit2.WebContextto be used by theWebKit2.WebView- Returns:
The newly created
WebKit2.WebViewwidget- Return type:
Creates a new
WebKit2.WebViewwith the givenWebKit2.WebContext.Creates a new
WebKit2.WebViewwith the givenWebKit2.WebContextand noWebKit2.UserContentManagerassociated with it. See alsoWebKit2.WebView.new_with_user_content_manager() andWebKit2.WebView.new_with_settings().
- Parameters:
web_view (
WebKit2.WebView) – the relatedWebKit2.WebView- Returns:
The newly created
WebKit2.WebViewwidget- Return type:
Creates a new
WebKit2.WebViewsharing the same web process with web_view.This method doesn’t have any effect when
WebKit2.ProcessModel.SHARED_SECONDARY_PROCESSprocess model is used, because a single web process is shared for all the web views in the sameWebKit2.WebContext. When usingWebKit2.ProcessModel.MULTIPLE_SECONDARY_PROCESSESprocess model, this method should always be used when creating theWebKit2.WebViewin theWebKit2.WebView::createsignal. You can also use this method to implement other process models based onWebKit2.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.WebViewwill also have the sameWebKit2.UserContentManager,WebKit2.Settings, andWebKit2.WebsitePoliciesas web_view.New in version 2.4.
- classmethod new_with_settings(settings)¶
- Parameters:
settings (
WebKit2.Settings) – aWebKit2.Settings- Returns:
The newly created
WebKit2.WebViewwidget- Return type:
Creates a new
WebKit2.WebViewwith the givenWebKit2.Settings.See also
WebKit2.WebView.new_with_context(), andWebKit2.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) – aWebKit2.UserContentManager.- Returns:
The newly created
WebKit2.WebViewwidget- Return type:
Creates a new
WebKit2.WebViewwith the givenWebKit2.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:
body (
str) – the function bodylength (
int) – length of body, or -1 if body is a nul-terminated stringarguments (
GLib.VariantorNone) – aGLib.Variantwith formata{sv}storing the function arguments, orNoneworld_name (
strorNone) – the name of a #WebKitScriptWorld orNoneto use the defaultcancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the script finisheduser_data (
objectorNone) – the data to pass to callback function
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.Varianttypes: number, string and dictionary. The result of the operation can be a Promise that will be properly passed to the callback. If world_name isNone, the default world is used. Any value that is notNoneis 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-javascriptisFalse, this method will do nothing. If you want to use this method but still prevent web content from executing its own JavaScript, then useWebKit2.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,objectuser_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”); }GObject.Object.unref(value); }static void web_view_evaluate_promise (
WebKit2.WebView*web_view) {GLib.VariantDictdict; g_variant_dict_init (&dict,None); g_variant_dict_insert (&dict, “count”, “u”, 42);GLib.Variant*args =GLib.VariantDict.end(&dict); conststr*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) – aGio.AsyncResult- Raises:
- Returns:
a
JavaScriptCore.Valuewith the return value of the async function orNonein case of error- Return type:
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:
command (
str) – the command to checkcancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the request is satisfieduser_data (
objectorNone) – the data to pass to callback function
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) – aGio.AsyncResult- Raises:
- Returns:
Trueif the editing command can be executed orFalseotherwise- Return type:
Finish an asynchronous operation started with
WebKit2.WebView.can_execute_editing_command().
- can_go_back()¶
-
Determines whether self has a previous history item.
- can_go_forward()¶
-
Determines whether self has a next history item.
- can_show_mime_type(mime_type)¶
- Parameters:
mime_type (
str) – a MIME type- Returns:
Trueif the MIME type mime_type can be displayed orFalseotherwise- Return type:
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.Downloadrepresenting the download operation.- Return type:
Requests downloading of the specified URI string for self.
- evaluate_javascript(script, length, world_name, source_uri, cancellable, callback, *user_data)¶
- Parameters:
script (
str) – the script to evaluatelength (
int) – length of script, or -1 if script is a nul-terminated stringworld_name (
strorNone) – the name of a #WebKitScriptWorld orNoneto use the defaultcancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the script finisheduser_data (
objectorNone) – the data to pass to callback function
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 notNoneis 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-javascriptisFalse, this method will do nothing. If you want to use this method but still prevent web content from executing its own JavaScript, then useWebKit2.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,objectuser_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”); }GObject.Object.unref(value); }static void web_view_get_link_url (
WebKit2.WebView*web_view, conststr*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) – aGio.AsyncResult- Raises:
- Returns:
a
JavaScriptCore.Valuewith the result of the last executed statement in script orNonein case of error- Return type:
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)¶
-
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:
- Return type:
Get the presentation type of
WebKit2.WebViewwhen created for automation.New in version 2.28.
- get_back_forward_list()¶
- Returns:
- Return type:
Obtains the
WebKit2.BackForwardListassociated with the givenWebKit2.WebView.The
WebKit2.BackForwardListis owned by theWebKit2.WebView.
- get_background_color()¶
-
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.MediaCaptureStateof the camera device. IfWebKit2.Settings:enable-mediastreamisFalse, this method will returnWebKit2.MediaCaptureState.NONE.- Return type:
Get the camera capture state of a
WebKit2.WebView.New in version 2.34.
- get_context()¶
- Returns:
the
WebKit2.WebContextof the view- Return type:
Gets the web context of self.
- get_custom_charset()¶
- Returns:
the current custom character encoding name or
Noneif no custom character encoding has been set.- Return type:
Returns the current custom character encoding name of self.
- get_default_content_security_policy()¶
-
Gets the configured default Content-Security-Policy.
New in version 2.38.
- get_display_capture_state()¶
- Returns:
The
WebKit2.MediaCaptureStateof the display device. IfWebKit2.Settings:enable-mediastreamisFalse, this method will returnWebKit2.MediaCaptureState.NONE.- Return type:
Get the display capture state of a
WebKit2.WebView.New in version 2.34.
- get_editor_state()¶
- Returns:
the
WebKit2.EditorStateof the view- Return type:
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:
Gets the value of the
WebKit2.WebView:estimated-load-progressproperty.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
Noneif there’s no icon associated with self.- Return type:
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.FindControllerassociated to this particularWebKit2.WebView.- Return type:
Gets the
WebKit2.FindController.Gets the
WebKit2.FindControllerthat will allow the caller to query theWebKit2.WebViewfor the text to look for.
- get_input_method_context()¶
- Returns:
- Return type:
Get the
WebKit2.InputMethodContextcurrently in use by self.Get the
WebKit2.InputMethodContextcurrently in use by self, orNoneif no input method is being used.New in version 2.28.
- get_inspector()¶
- Returns:
the
WebKit2.WebInspectorof self- Return type:
Get the
WebKit2.WebInspectorassociated to self
- get_is_muted()¶
-
Gets the mute state of self.
New in version 2.30.
- get_is_web_process_responsive()¶
-
Get whether the current web process of a
WebKit2.WebViewis responsive.New in version 2.34.
- get_main_resource()¶
- Returns:
the main
WebKit2.WebResourceof the view orNoneif nothing has been loaded.- Return type:
Return the main resource of self.
- get_microphone_capture_state()¶
- Returns:
The
WebKit2.MediaCaptureStateof the microphone device. IfWebKit2.Settings:enable-mediastreamisFalse, this method will returnWebKit2.MediaCaptureState.NONE.- Return type:
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:
Get the identifier of the #WebKitWebPage corresponding to the
WebKit2.WebView
- get_session_state()¶
- Returns:
- Return type:
Gets the current session state of self
New in version 2.12.
- get_settings()¶
- Returns:
the
WebKit2.Settingsattached to self- Return type:
Gets the
WebKit2.Settingscurrently applied to self.If no other
WebKit2.Settingshave been explicitly applied to self withWebKit2.WebView.set_settings(), the defaultWebKit2.Settingswill be returned. This method always returns a validWebKit2.Settingsobject. To modify any of the self settings, you can either create a newWebKit2.Settingsobject withWebKit2.Settings.new(), setting the desired preferences, and then replace the existing self settings withWebKit2.WebView.set_settings() or get the existing self settings and update it directly.WebKit2.Settingsobjects can be shared by multipleWebKit2.WebViews, so modifying the settings of aWebKit2.WebViewwould affect otherWebKit2.WebViews using the sameWebKit2.Settings.
- get_snapshot(region, options, cancellable, callback, *user_data)¶
- Parameters:
region (
WebKit2.SnapshotRegion) – theWebKit2.SnapshotRegionfor this snapshotoptions (
WebKit2.SnapshotOptions) –WebKit2.SnapshotOptionsfor the snapshotcancellable (
Gio.CancellableorNone) – aGio.Cancellablecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallback
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) – aGio.AsyncResult- Raises:
- Returns:
an image with the retrieved snapshot, or
Nonein case of error.- Return type:
Finishes an asynchronous operation started with
WebKit2.WebView.get_snapshot().
- get_title()¶
- Returns:
The main frame document title of self.
- Return type:
Gets the value of the
WebKit2.WebView:titleproperty.You can connect to notify::title signal of self to be notified when the title has been received.
- get_tls_info()¶
- Returns:
Trueif the self connection uses HTTPS and a response has been received from the server, orFalseotherwise.- certificate:
return location for a
Gio.TlsCertificate- errors:
return location for a
Gio.TlsCertificateFlagsthe verification status of certificate
- Return type:
(
bool, certificate:Gio.TlsCertificate, errors:Gio.TlsCertificateFlags)
Retrieves the
Gio.TlsCertificateassociated with the main resource of self.Retrieves the
Gio.TlsCertificateassociated with the main resource of self, and theGio.TlsCertificateFlagsshowing 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 toWebKit2.WebView::load-changedand call this function when it’s emitted withWebKit2.LoadEvent.COMMITTEDevent.Note that this function provides no information about the security of the web page if the current
WebKit2.TLSErrorsPolicyisWebKit2.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 currentWebKit2.TLSErrorsPolicyisWebKit2.TLSErrorsPolicy.FAIL, in which case subresources that fail certificate verification will be blocked.
- get_uri()¶
-
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 the load operation was started by
WebKit2.WebView.load_uri(), the requested URI is the given one.If the load operation was started by
WebKit2.WebView.load_html(), the requested URI is “about:blank”.If the load operation was started by
WebKit2.WebView.load_alternate_html(), the requested URI is content URI provided.If the load operation was started by
WebKit2.WebView.go_back() orWebKit2.WebView.go_forward(), the requested URI is the original URI of the previous/next item in theWebKit2.BackForwardListof self.If the load operation was started by
WebKit2.WebView.go_to_back_forward_list_item(), the requested URI is the opriginal URI of the givenWebKit2.BackForwardListItem.
If there is a server redirection during the load operation, the active URI is the redirected URI. When the signal
WebKit2.WebView::load-changedis emitted withWebKit2.LoadEvent.REDIRECTEDevent, the active URI is already updated to the redirected URI.When the signal
WebKit2.WebView::load-changedis emitted withWebKit2.LoadEvent.COMMITTEDevent, 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.UserContentManagerassociated with the view- Return type:
Gets the user content manager associated to self.
New in version 2.6.
- get_web_extension_mode()¶
- Returns:
- Return type:
Get the view’s
WebKit2.WebExtensionMode.New in version 2.38.
- get_website_data_manager()¶
- Returns:
- Return type:
Get the
WebKit2.WebsiteDataManagerassociated to self.If self is not ephemeral, the returned
WebKit2.WebsiteDataManagerwill be the same as theWebKit2.WebsiteDataManagerof self'sWebKit2.WebContext.New in version 2.16.
- get_website_policies()¶
- Returns:
the default
WebKit2.WebsitePoliciesassociated with the view.- Return type:
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-policysignal handler.See also
WebKit2.PolicyDecision.use_with_policies().New in version 2.30.
- get_window_properties()¶
- Returns:
the
WebKit2.WindowPropertiesof self- Return type:
Get the
WebKit2.WindowPropertiesobject.Get the
WebKit2.WindowPropertiesobject containing the properties that the window containing self should have.
- get_zoom_level()¶
- Returns:
the current zoom level of self
- Return type:
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-changedsignal.
- go_forward()¶
Loads the next history item.
You can monitor the load operation by connecting to
WebKit2.WebView::load-changedsignal.
- go_to_back_forward_list_item(list_item)¶
- Parameters:
list_item (
WebKit2.BackForwardListItem) – aWebKit2.BackForwardListItem
Loads the specific history item list_item.
You can monitor the load operation by connecting to
WebKit2.WebView::load-changedsignal.
- is_controlled_by_automation()¶
-
Get whether a
WebKit2.WebViewwas created withWebKit2.WebView:is-controlled-by-automationproperty enabled.Only
WebKit2.WebViews controlled by automation can be used in an automation session.New in version 2.18.
- is_editable()¶
-
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.WebViewis not editable.New in version 2.8.
- is_ephemeral()¶
-
Get whether a
WebKit2.WebViewis ephemeral.To create an ephemeral
WebKit2.WebViewyou need to use g_object_new() and pass is-ephemeral property withTruevalue. SeeWebKit2.WebView:is-ephemeralfor more details. If self was created with a ephemeralWebKit2.WebView:related-viewor an ephemeralWebKit2.WebView:web-contextit will also be ephemeral.New in version 2.16.
- is_loading()¶
-
Gets the value of the
WebKit2.WebView:is-loadingproperty.You can monitor when a
WebKit2.WebViewis 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()¶
-
Gets the value of the
WebKit2.WebView:is-playing-audioproperty.You can monitor when a page in a
WebKit2.WebViewis 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:
Load the given content string for the URI content_uri.
This allows clients to display page-loading errors in the
WebKit2.WebViewitself. When this method is called fromWebKit2.WebView::load-failedsignal to show an error page, then the back-forward list is maintained appropriately. For everything else this method works the same way asWebKit2.WebView.load_html().
- load_bytes(bytes, mime_type, encoding, base_uri)¶
- Parameters:
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 isNone, it defaults to “UTF-8”. When base_uri isNone, it defaults to “about:blank”. You can monitor the load operation by connecting toWebKit2.WebView::load-changedsignal.New in version 2.6.
- load_html(content, base_uri)¶
- Parameters:
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 isNone, it defaults to “about:blank”. The mime type of the document will be “text/html”. You can monitor the load operation by connecting toWebKit2.WebView::load-changedsignal.
- 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-changedsignal.
- load_request(request)¶
- Parameters:
request (
WebKit2.URIRequest) – aWebKit2.URIRequestto load
Requests loading of the specified
WebKit2.URIRequest.You can monitor the load operation by connecting to
WebKit2.WebView::load-changedsignal.
- 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-changedsignal.
- 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) – aWebKit2.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:
body (
str) – the JavaScript function bodyarguments (
GLib.Variant) – aGLib.Variantwith format{&sv}storing the function arguments. Function argument values must be one of the following types, or contain only the followingGLib.Varianttypes: number, string, array, and dictionary.world_name (
strorNone) – the name of a #WebKitScriptWorld, if no name (i.e.None) is provided, the default world is used. Any value that is notNoneis a distinct world.cancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the script finisheduser_data (
objectorNone) – the data to pass to callback function
Asynchronously run body in the script world with name world_name of the current page context in self. If
WebKit2.Settings:enable-javascriptisFalse, this method will do nothing. This API differs fromWebKit2.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,objectuser_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.VariantDictdict; g_variant_dict_init (&dict,None); g_variant_dict_insert (&dict, “count”, “u”, 42);GLib.Variant*args =GLib.VariantDict.end(&dict); conststr*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:
script (
str) – the script to runcancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the script finisheduser_data (
objectorNone) – the data to pass to callback function
Asynchronously run script in the context of the current page in self.
If
WebKit2.Settings:enable-javascriptisFalse, 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) – aGio.AsyncResult- Raises:
- Returns:
a
WebKit2.JavascriptResultwith the result of the last executed statement in script orNonein case of error- Return type:
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,objectuser_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, conststr*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:
resource (
str) – the location of the resource to loadcancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the script finisheduser_data (
objectorNone) – the data to pass to callback function
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) – aGio.AsyncResult- Raises:
- Returns:
a
WebKit2.JavascriptResultwith the result of the last executed statement in script orNonein case of error- Return type:
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:
script (
str) – the script to runworld_name (
str) – the name of a #WebKitScriptWorldcancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the script finisheduser_data (
objectorNone) – the data to pass to callback function
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-javascriptisFalse, 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) – aGio.AsyncResult- Raises:
- Returns:
a
WebKit2.JavascriptResultwith the result of the last executed statement in script orNonein case of error- Return type:
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:
save_mode (
WebKit2.SaveMode) – theWebKit2.SaveModespecifying how the web page should be saved.cancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the request is satisfieduser_data (
objectorNone) – the data to pass to callback function
Asynchronously save the current web page.
Asynchronously save the current web page associated to the
WebKit2.WebViewinto 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) – aGio.AsyncResult- Raises:
- Returns:
a
Gio.InputStreamwith the result of saving the current web page orNonein case of error.- Return type:
Finish an asynchronous operation started with
WebKit2.WebView.save().
- save_to_file(file, save_mode, cancellable, callback, *user_data)¶
- Parameters:
file (
Gio.File) – theGio.Filewhere the current web page should be saved to.save_mode (
WebKit2.SaveMode) – theWebKit2.SaveModespecifying how the web page should be saved.cancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the request is satisfieduser_data (
objectorNone) – the data to pass to callback function
Asynchronously save the current web page.
Asynchronously save the current web page associated to the
WebKit2.WebViewinto 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) – aGio.AsyncResult- Raises:
- Returns:
Trueif the web page was successfully saved to a file orFalseotherwise.- Return type:
Finish an asynchronous operation started with
WebKit2.WebView.save_to_file().
- send_message_to_page(message, cancellable, callback, *user_data)¶
- Parameters:
message (
WebKit2.UserMessage) – aWebKit2.UserMessagecancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – (nullable): AGio.AsyncReadyCallbackto call when the request is satisfied orNoneuser_data (
objectorNone) – the data to pass to callback function
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
Noneas callback. When the operation is finished, callback will be called. You can then callWebKit2.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) – aGio.AsyncResult- Raises:
- Returns:
a
WebKit2.UserMessagewith the reply orNonein case of error.- Return type:
Finish an asynchronous operation started with
WebKit2.WebView.send_message_to_page().New in version 2.28.
- set_background_color(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-paintableproperty set toTruefor 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) – aWebKit2.MediaCaptureState
Set the camera capture state of a
WebKit2.WebView.If
WebKit2.Settings:enable-mediastreamisFalse, this method will have no visible effect. Once the state of the device has been set toWebKit2.MediaCaptureState.NONEit cannot be changed anymore. The page can however request capture again using the mediaDevices API.New in version 2.34.
- set_cors_allowlist(allowlist)¶
-
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)¶
-
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
Noneremoves the character encoding override.
- set_display_capture_state(state)¶
- Parameters:
state (
WebKit2.MediaCaptureState) – aWebKit2.MediaCaptureState
Set the display capture state of a
WebKit2.WebView.If
WebKit2.Settings:enable-mediastreamisFalse, this method will have no visible effect. Once the state of the device has been set toWebKit2.MediaCaptureState.NONEit cannot be changed anymore. The page can however request capture again using the mediaDevices API.New in version 2.34.
- set_editable(editable)¶
-
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 isFalse, 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 aWebKit2.WebViewis 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.WebVieweditable without altering the document or DOM structure.New in version 2.8.
- set_input_method_context(context)¶
- Parameters:
context (
WebKit2.InputMethodContextorNone) – theWebKit2.InputMethodContextto set, orNone
Set the
WebKit2.InputMethodContextto be used by self.Set the
WebKit2.InputMethodContextto be used by self, orNoneto not use any input method. Note that the sameWebKit2.InputMethodContextcan’t be set on more than oneWebKit2.WebViewat 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) – aWebKit2.MediaCaptureState
Set the microphone capture state of a
WebKit2.WebView.If
WebKit2.Settings:enable-mediastreamisFalse, this method will have no visible effect. Once the state of the device has been set toWebKit2.MediaCaptureState.NONEit 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) – aWebKit2.Settings
Sets the
WebKit2.Settingsto be applied to self.The existing
WebKit2.Settingsof self will be replaced by settings. New settings are applied immediately on self. The sameWebKit2.Settingsobject can be shared by multipleWebKit2.WebViews.
- 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-failedsignal will be emitted withWebKit2.NetworkError.CANCELLEDerror.
- terminate_web_process()¶
Terminates the web process associated to self.
When the web process gets terminated using this method, the
WebKit2.WebView::web-process-terminatedsignal is emitted withWebKit2.WebProcessTerminationReason.TERMINATED_BY_APIas 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::closesignal is emitted, otherwise nothing happens.New in version 2.12.
- do_authenticate(request) virtual¶
- Parameters:
request (
WebKit2.AuthenticationRequest) –- Return type:
- do_close() virtual¶
- Parameters:
context_menu (
WebKit2.ContextMenu) –event (
Gdk.Event) –hit_test_result (
WebKit2.HitTestResult) –
- Return type:
- do_decide_policy(decision, type) virtual¶
- Parameters:
decision (
WebKit2.PolicyDecision) –type (
WebKit2.PolicyDecisionType) –
- Return type:
- do_insecure_content_detected(event) virtual¶
- Parameters:
event (
WebKit2.InsecureContentEvent) –
- do_load_changed(load_event) virtual¶
- Parameters:
load_event (
WebKit2.LoadEvent) –
- do_load_failed(load_event, failing_uri, error) virtual¶
- Parameters:
load_event (
WebKit2.LoadEvent) –failing_uri (
str) –error (
GLib.Error) –
- Return type:
- do_load_failed_with_tls_errors(failing_uri, certificate, errors) virtual¶
- Parameters:
failing_uri (
str) –certificate (
Gio.TlsCertificate) –errors (
Gio.TlsCertificateFlags) –
- Return type:
- do_mouse_target_changed(hit_test_result, modifiers) virtual¶
- Parameters:
hit_test_result (
WebKit2.HitTestResult) –modifiers (
int) –
- do_permission_request(permission_request) virtual¶
- Parameters:
permission_request (
WebKit2.PermissionRequest) –- Return type:
- do_print_(print_operation) virtual¶
- Parameters:
print_operation (
WebKit2.PrintOperation) –- Return type:
- do_query_permission_state(query) virtual¶
- Parameters:
query (
WebKit2.PermissionStateQuery) –- Return type:
- do_ready_to_show() virtual¶
- do_resource_load_started(resource, request) virtual¶
- Parameters:
resource (
WebKit2.WebResource) –request (
WebKit2.URIRequest) –
- do_run_as_modal() virtual¶
- do_run_color_chooser(request) virtual¶
- Parameters:
request (
WebKit2.ColorChooserRequest) –- Return type:
- do_run_file_chooser(request) virtual¶
- Parameters:
request (
WebKit2.FileChooserRequest) –- Return type:
- do_script_dialog(dialog) virtual¶
- Parameters:
dialog (
WebKit2.ScriptDialog) –- Return type:
- do_show_notification(notification) virtual¶
- Parameters:
notification (
WebKit2.Notification) –- Return type:
- Parameters:
menu (
WebKit2.OptionMenu) –event (
Gdk.Event) –rectangle (
Gdk.Rectangle) –
- Return type:
- do_submit_form(request) virtual¶
- Parameters:
request (
WebKit2.FormSubmissionRequest) –
- do_user_message_received(message) virtual¶
- Parameters:
message (
WebKit2.UserMessage) –- Return type:
- do_web_process_terminated(reason) virtual¶
- Parameters:
reason (
WebKit2.WebProcessTerminationReason) –
Signal Details¶
- WebKit2.WebView.signals.authenticate(web_view, request)¶
- Signal Name:
authenticate- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalrequest (
WebKit2.AuthenticationRequest) – aWebKit2.AuthenticationRequest
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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.AuthenticationRequestin the request argument. 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.
New in version 2.2.
- WebKit2.WebView.signals.close(web_view)¶
- Signal Name:
close- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signal
Emitted when closing a
WebKit2.WebViewis requested. This occurs when a call is made from JavaScript’s window.close function or after trying to close the web_view withWebKit2.WebView.try_close(). It is the owner’s responsibility to handle this signal to hide or destroy theWebKit2.WebView, if necessary.
- Signal Name:
context-menu- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalcontext_menu (
WebKit2.ContextMenu) – the proposedWebKit2.ContextMenuevent (
Gdk.Event) – theGdk.Eventthat triggered the context menu. Deprecated 2.40.hit_test_result (
WebKit2.HitTestResult) – aWebKit2.HitTestResult
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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.
To customize the proposed menu you can use
WebKit2.ContextMenu.prepend(),WebKit2.ContextMenu.append() orWebKit2.ContextMenu.insert() to add newWebKit2.ContextMenuItems to context_menu,WebKit2.ContextMenu.move_item() to reorder existing items, orWebKit2.ContextMenu.remove() to remove an existing item. The signal handler should returnFalse, and the menu represented by context_menu will be shown.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.To build your own menu, you can remove all items from the proposed menu with
WebKit2.ContextMenu.remove_all(), add your own items and returnFalseso that the menu will be shown. You can also ignore the proposedWebKit2.ContextMenu, build your ownGtk.Menuand returnTrueto prevent the proposed menu from being shown.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.
The event parameter is now deprecated. Use
WebKit2.ContextMenu.get_event() to get theGdk.Eventthat triggered the context menu.If the signal handler returns
Falsethe context menu represented by context_menu will be shown, if it returnTruethe context menu will not be shown.The proposed
WebKit2.ContextMenupassed in context_menu argument is only valid during the signal emission.
- Signal Name:
context-menu-dismissed- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signal
Emitted after
WebKit2.WebView::context-menusignal, 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:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalnavigation_action (
WebKit2.NavigationAction) – aWebKit2.NavigationAction
- Returns:
a newly allocated
WebKit2.WebViewwidget orNoneto propagate the event further.- Return type:
Emitted when the creation of a new
WebKit2.WebViewis requested. If this signal is handled the signal handler should return the newly createdWebKit2.WebView.The
WebKit2.NavigationActionparameter contains information about the navigation action that triggered this signal.The new
WebKit2.WebViewmust be related to web_view, seeWebKit2.WebView:related-viewfor more details.The new
WebKit2.WebViewshould not be displayed to the user until theWebKit2.WebView::ready-to-showsignal is emitted.For creating views as response to automation tools requests, see the
WebKit2.AutomationSession::create-web-viewsignal.
- WebKit2.WebView.signals.decide_policy(web_view, decision, decision_type)¶
- Signal Name:
decide-policy- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signaldecision (
WebKit2.PolicyDecision) – theWebKit2.PolicyDecisiondecision_type (
WebKit2.PolicyDecisionType) – aWebKit2.PolicyDecisionTypedenoting the type of decision
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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.NavigationPolicyDecisionpassed 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 returningTrueto block the default signal handler. If the last reference is removed on aWebKit2.PolicyDecisionand no decision has been made explicitly,WebKit2.PolicyDecision.use() will be the default policy decision. The default signal handler will simply callWebKit2.PolicyDecision.use(). Only the first policy decision chosen for a givenWebKit2.PolicyDecisionwill have any affect.
- WebKit2.WebView.signals.enter_fullscreen(web_view)¶
- Signal Name:
enter-fullscreen- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signal- Returns:
Trueto stop other handlers from being invoked for the event.Falseto continue emission of the event.- Return type:
Emitted when JavaScript code calls element.webkitRequestFullScreen. If the signal is not handled the
WebKit2.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).
- WebKit2.WebView.signals.insecure_content_detected(web_view, event)¶
- Signal Name:
insecure-content-detected- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalevent (
WebKit2.InsecureContentEvent) – theWebKit2.InsecureContentEvent
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.
- WebKit2.WebView.signals.leave_fullscreen(web_view)¶
- Signal Name:
leave-fullscreen- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signal- Returns:
Trueto stop other handlers from being invoked for the event.Falseto continue emission of the event.- Return type:
Emitted when the
WebKit2.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 theWebKit2.WebView::enter-fullscreenstage for instance.
- WebKit2.WebView.signals.load_changed(web_view, load_event)¶
- Signal Name:
load-changed- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalload_event (
WebKit2.LoadEvent) – theWebKit2.LoadEvent
Emitted when a load operation in web_view changes. The signal is always emitted with
WebKit2.LoadEvent.STARTEDwhen a new load request is made andWebKit2.LoadEvent.FINISHEDwhen the load finishes successfully or due to an error. When the ongoing load operation failsWebKit2.WebView::load-failedsignal is emitted beforeWebKit2.WebView::load-changedis emitted withWebKit2.LoadEvent.FINISHED. If a redirection is received from the server, this signal is emitted withWebKit2.LoadEvent.REDIRECTEDafter the initial emission withWebKit2.LoadEvent.STARTEDand beforeWebKit2.LoadEvent.COMMITTED. When the page content starts arriving the signal is emitted withWebKit2.LoadEvent.COMMITTEDevent.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:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalload_event (
WebKit2.LoadEvent) – theWebKit2.LoadEventof the load operationfailing_uri (
str) – the URI that failed to loaderror (
GLib.Error) – theGLib.Errorthat was triggered
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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 beWebKit2.LoadEvent.COMMITTED. Since a load error causes the load operation to finish, the signalWebKit2.WebView::load-changedwill always be emitted withWebKit2.LoadEvent.FINISHEDevent 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:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalfailing_uri (
str) – the URI that failed to loadcertificate (
Gio.TlsCertificate) – aGio.TlsCertificateerrors (
Gio.TlsCertificateFlags) – aGio.TlsCertificateFlagswith the verification status of certificate
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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 returnTrue.If
Falseis returned,WebKit2.WebView::load-failedwill 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:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalhit_test_result (
WebKit2.HitTestResult) – aWebKit2.HitTestResultmodifiers (
int) – a bitmask ofGdk.ModifierType
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.ModifierTypeflags 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:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalrequest (
WebKit2.PermissionRequest) – theWebKit2.PermissionRequest
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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
boolpermission_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);intresult =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 returningTrueto block the default signal handler. If the last reference is removed on aWebKit2.PermissionRequestand 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.PermissionRequestthat could allow or deny it. Check the documentation of classes implementingWebKit2.PermissionRequestinterface to know their default action.
- WebKit2.WebView.signals.print_(web_view, print_operation)¶
- Signal Name:
print- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalprint_operation (
WebKit2.PrintOperation) – theWebKit2.PrintOperationthat will handle the print request
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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() andWebKit2.PrintOperation.set_page_setup() and then returnFalseto propagate the event so that the print dialog is shown.You can connect to this signal and return
Trueto 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:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalquery (
WebKit2.PermissionStateQuery) – theWebKit2.PermissionStateQuery
- Returns:
- Return type:
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 returningTrue. 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:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signal
Emitted after
WebKit2.WebView::createon the newly createdWebKit2.WebViewwhen 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 theWebKit2.WindowPropertiesof web_view. See alsoWebKit2.WebView.get_window_properties().
- WebKit2.WebView.signals.resource_load_started(web_view, resource, request)¶
- Signal Name:
resource-load-started- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalresource (
WebKit2.WebResource) – aWebKit2.WebResourcerequest (
WebKit2.URIRequest) – aWebKit2.URIRequest
Emitted when a new resource is going to be loaded. The request parameter contains the
WebKit2.URIRequestthat 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:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signal
Emitted after
WebKit2.WebView::ready-to-showon the newly createdWebKit2.WebViewwhen 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 parentWebKit2.WebViewuntil the new dialog is closed.
- WebKit2.WebView.signals.run_color_chooser(web_view, request)¶
- Signal Name:
run-color-chooser- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalrequest (
WebKit2.ColorChooserRequest) – aWebKit2.ColorChooserRequest
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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.ColorChooserRequestin 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.ColorChooserfor 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:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalrequest (
WebKit2.FileChooserRequest) – aWebKit2.FileChooserRequest
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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.FileChooserRequestin the request argument.The default signal handler will asynchronously run a regular
Gtk.FileChooserDialogfor the user to interact with.
- WebKit2.WebView.signals.script_dialog(web_view, dialog)¶
- Signal Name:
script-dialog- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signaldialog (
WebKit2.ScriptDialog) – theWebKit2.ScriptDialogto show
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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:
WebKit2.ScriptDialogType.ALERT: message dialog with a single Close button.WebKit2.ScriptDialogType.CONFIRM: message dialog with OK and Cancel buttons.WebKit2.ScriptDialogType.PROMPT: message dialog with OK and Cancel buttons and a text entry with the default text.WebKit2.ScriptDialogType.BEFORE_UNLOAD_CONFIRM: message dialog with Stay and Leave buttons.
It is possible to handle the script dialog request asynchronously, by simply caling
WebKit2.ScriptDialog.ref() on the dialog argument and callingWebKit2.ScriptDialog.close() when done. If the last reference is removed on aWebKit2.ScriptDialogand 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:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalnotification (
WebKit2.Notification) – aWebKit2.Notification
- Returns:
Trueto stop other handlers from being invoked.Falseotherwise.- Return type:
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.
- Signal Name:
show-option-menu- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalmenu (
WebKit2.OptionMenu) – theWebKit2.OptionMenuevent (
Gdk.Event) – theGdk.Eventthat triggered the menu, orNone. Deprecated 2.40rectangle (
Gdk.Rectangle) – the option element area
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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.WebViewis 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 theGdk.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 theGdk.Eventthat 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:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalrequest (
WebKit2.FormSubmissionRequest) – aWebKit2.FormSubmissionRequest
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 callingWebKit2.FormSubmissionRequest.submit() when done to continue with the form submission. If the last reference is removed on aWebKit2.FormSubmissionRequestand 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:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalmessage (
WebKit2.UserMessage) – theWebKit2.UserMessagereceived
- Returns:
- Return type:
This signal is emitted when a
WebKit2.UserMessageis received from the #WebKitWebPage corresponding to web_view. You can reply to the message usingWebKit2.UserMessage.send_reply().You can handle the user message asynchronously by calling
GObject.Object.ref() on message and returningTrue. If the last reference of message is removed and the message has not been replied to, the operation in the #WebKitWebPage will finish with errorWebKit2.UserMessageError.MESSAGE.New in version 2.28.
- WebKit2.WebView.signals.web_process_crashed(web_view)¶
- Signal Name:
web-process-crashed- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signal- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
This signal is emitted when the web process crashes.
Deprecated since version 2.20: Use
WebKit2.WebView::web-process-terminatedinstead.
- WebKit2.WebView.signals.web_process_terminated(web_view, reason)¶
- Signal Name:
web-process-terminated- Flags:
- Parameters:
web_view (
WebKit2.WebView) – The object which received the signalreason (
WebKit2.WebProcessTerminationReason) – the aWebKit2.WebProcessTerminationReason
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:
- Default Value:
- Flags:
The
WebKit2.AutomationBrowsingContextPresentationofWebKit2.WebView. This should only be used when creating a newWebKit2.WebViewas a response toWebKit2.AutomationSession::create-web-viewsignal request. If the new WebView was added to a new tab of current browsing context windowWebKit2.AutomationBrowsingContextPresentation.TABshould be used.New in version 2.28.
- WebKit2.WebView.props.camera_capture_state¶
- Name:
camera-capture-state- Type:
- Default Value:
- Flags:
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 toWebKit2.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.NONEorWebKit2.MediaCaptureState.MUTED.If the capture state of the device is set to
WebKit2.MediaCaptureState.NONEthe 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:
- Default Value:
- Flags:
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.UserContentManagerandWebKit2.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:
- Default Value:
- Flags:
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.NONEorWebKit2.MediaCaptureState.MUTED.If the capture state of the device is set to
WebKit2.MediaCaptureState.NONEthe 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¶
-
Whether the pages loaded inside
WebKit2.WebVieware editable. For more information seeWebKit2.WebView.set_editable().New in version 2.8.
- WebKit2.WebView.props.estimated_load_progress¶
-
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¶
-
The favicon currently associated to the
WebKit2.WebView. SeeWebKit2.WebView.get_favicon() for more details.
- WebKit2.WebView.props.is_controlled_by_automation¶
- Name:
is-controlled-by-automation- Type:
- Default Value:
- Flags:
Whether the
WebKit2.WebViewis controlled by automation tools (e.g. WebDriver, Selenium). This is required for views returned as a response toWebKit2.AutomationSession::create-web-viewsignal, alongside any view you want to control during an automation session.As a
GObject.ParamFlags.CONSTRUCT_ONLY, you need to set it during construction and it can’t be modified.If
WebKit2.WebView:related-viewis also passed during construction,WebKit2.WebView:is-controlled-by-automationignores its own parameter and inherits directly from the related viewWebKit2.WebView:is-controlled-by-automationproperty. This is the recommended way when creating new views as a response to theWebKit2.WebView::createsignal. For example, as response to JavaScriptwindow.open()calls during an automation session.New in version 2.18.
- WebKit2.WebView.props.is_ephemeral¶
- Name:
is-ephemeral- Type:
- Default Value:
- Flags:
Whether the
WebKit2.WebViewis ephemeral. An ephemeral web view never writes website data to the client storage, no matter whatWebKit2.WebsiteDataManagerits context is using. This is normally used to implement private browsing mode. This is aGObject.ParamFlags.CONSTRUCT_ONLYproperty, so you have to create an ephemeralWebKit2.WebViewand it can’t be changed. The ephemeralWebKit2.WebsiteDataManagercreated for theWebKit2.WebViewwill inherit the network settings from theWebKit2.WebContext‘sWebKit2.WebsiteDataManager. To use different settings you can get theWebKit2.WebsiteDataManagerwithWebKit2.WebView.get_website_data_manager() and set the new ones. Note that allWebKit2.WebViews created with an ephemeralWebKit2.WebContextwill be ephemeral automatically. See alsoWebKit2.WebContext.new_ephemeral().New in version 2.16.
- WebKit2.WebView.props.is_loading¶
-
Whether the
WebKit2.WebViewis currently loading a page. This property becomesTrueas soon as a new load operation is requested and before theWebKit2.WebView::load-changedsignal is emitted withWebKit2.LoadEvent.STARTEDand at that point the active URI is the requested one. When the load operation finishes the property is set toFalsebeforeWebKit2.WebView::load-changedis emitted withWebKit2.LoadEvent.FINISHED.
- WebKit2.WebView.props.is_muted¶
-
Whether the
WebKit2.WebViewaudio is muted. WhenTrue, audio is silenced. It may still be playing, i.e.WebKit2.WebView:is-playing-audiomay beTrue.New in version 2.30.
- WebKit2.WebView.props.is_playing_audio¶
-
Whether the
WebKit2.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.New in version 2.8.
- WebKit2.WebView.props.is_web_process_responsive¶
-
Whether the web process currently associated to the
WebKit2.WebViewis responsive.New in version 2.34.
- WebKit2.WebView.props.microphone_capture_state¶
- Name:
microphone-capture-state- Type:
- Default Value:
- Flags:
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 toWebKit2.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.NONEorWebKit2.MediaCaptureState.MUTED.If the capture state of the device is set to
WebKit2.MediaCaptureState.NONEthe 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¶
-
The identifier of the #WebKitWebPage corresponding to the
WebKit2.WebView.New in version 2.28.
- Name:
related-view- Type:
- Default Value:
- Flags:
The related
WebKit2.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.New in version 2.4.
- WebKit2.WebView.props.settings¶
- Name:
settings- Type:
- Default Value:
- Flags:
The
WebKit2.Settingsof the view.New in version 2.6.
- WebKit2.WebView.props.title¶
-
The main frame document title of this
WebKit2.WebView. If the title has not been received yet, it will beNone.
- WebKit2.WebView.props.uri¶
-
The current active URI of the
WebKit2.WebView. SeeWebKit2.WebView.get_uri() for more details.
- WebKit2.WebView.props.user_content_manager¶
- Name:
user-content-manager- Type:
- Default Value:
- Flags:
The
WebKit2.UserContentManagerof the view.New in version 2.6.
- WebKit2.WebView.props.web_context¶
- Name:
web-context- Type:
- Default Value:
- Flags:
The
WebKit2.WebContextof the view.
- WebKit2.WebView.props.web_extension_mode¶
- Name:
web-extension-mode- Type:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
The
WebKit2.WebsitePoliciesfor the view.New in version 2.30.
- WebKit2.WebView.props.zoom_level¶
-
The zoom level of the
WebKit2.WebViewcontent. SeeWebKit2.WebView.set_zoom_level() for more details.