WebView
Object Hierarchy:
Description:
[ CCode ( type_id = "webkit_web_view_get_type ()" ) ]
public class WebView : WebViewBase, Accessible, Buildable, ConstraintTarget
public class WebView : WebViewBase, 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.
Namespace: WebKit
Package: webkitgtk-6.0
Content:
Properties:
- public AutomationBrowsingContextPresentation automation_presentation_type { get; construct; }
The AutomationBrowsingContextPresentation of WebView.
- public MediaCaptureState camera_capture_state { get; set; }
Capture state of the camera device.
- public string default_content_security_policy { get; construct; }
The default Content-Security-Policy used by the webview as if it were set by an HTTP header.
- public MediaCaptureState display_capture_state { get; set; }
Capture state of the display device.
- public bool editable { get; set; }
Whether the pages loaded inside WebView are editable.
- public double estimated_load_progress { get; }
An estimate of the percent completion for the current loading operation.
- public Texture favicon { get; }
The favicon currently associated to the WebView.
- public bool is_controlled_by_automation { get; construct; }
Whether the WebView is controlled by automation.
- public bool is_loading { get; }
Whether the WebView is currently loading a page.
- public bool is_muted { get; set; }
Whether the WebView audio is muted.
- public bool is_playing_audio { get; }
Whether the WebView is currently playing audio from a page.
- public bool is_web_process_responsive { get; }
Whether the web process currently associated to the WebView is responsive.
- public MediaCaptureState microphone_capture_state { get; set; }
Capture state of the microphone device.
- public NetworkSession network_session { get; construct; }
The NetworkSession of the view
- public uint64 page_id { get; }
The identifier of the
WebKitWebPage
corresponding to the WebView. - public WebView related_view { construct; }
The related WebView used when creating the view to share the same web process and network session.
- public Settings settings { set construct; }
The Settings of the view.
- public string title { get; }
The main frame document title of this WebView.
- public string uri { get; }
The current active URI of the WebView.
- public UserContentManager user_content_manager { get; construct; }
The UserContentManager of the view.
- public WebContext web_context { owned get; construct; }
The WebContext of the view.
- public WebExtensionMode web_extension_mode { get; construct; }
This configures
web_view
to treat the content as a WebExtension. - public WebsitePolicies website_policies { get; construct; }
The WebsitePolicies for the view.
- public double zoom_level { get; set; }
The zoom level of the WebView content.
Creation methods:
- public WebView ()
Creates a new WebView with the default WebContext.
Methods:
- public async Value call_async_javascript_function (string body, ssize_t length, Variant? arguments, string? world_name, string? source_uri, Cancellable? cancellable = null) throws Error
Asynchronously call
body
witharguments
in the script world with nameworld_name
of the main frame current context in this. - public async bool can_execute_editing_command (string command, Cancellable? cancellable = null) throws Error
Asynchronously check if it is possible to execute the given editing command.
- public bool can_go_back ()
Determines whether this has a previous history item.
- public bool can_go_forward ()
Determines whether this has a next history item.
- public bool can_show_mime_type (string mime_type)
Whether or not a MIME type can be displayed in this.
- public Download download_uri (string uri)
Requests downloading of the specified URI string for this.
- public async Value evaluate_javascript (string script, ssize_t length, string? world_name, string? source_uri, Cancellable? cancellable = null) throws Error
Asynchronously evaluate
script
in the script world with nameworld_name
of the main frame current context in this. - public void execute_editing_command (string command)
Request to execute the given
command
for this. - public void execute_editing_command_with_argument (string command, string argument)
Request to execute the given
command
withargument
for this. - public AutomationBrowsingContextPresentation get_automation_presentation_type ()
Get the presentation type of WebView when created for automation.
- public unowned BackForwardList get_back_forward_list ()
Obtains the BackForwardList associated with the given WebView .
- public RGBA get_background_color ()
Gets the color that is used to draw the this background.
- public MediaCaptureState get_camera_capture_state ()
Get the camera capture state of a WebView.
- public unowned WebContext get_context ()
Gets the web context of this.
- public unowned string get_custom_charset ()
Returns the current custom character encoding name of this.
- public unowned string? get_default_content_security_policy ()
Gets the configured default Content-Security-Policy.
- public MediaCaptureState get_display_capture_state ()
Get the display capture state of a WebView.
- public unowned EditorState get_editor_state ()
Gets the web editor state of this.
- public double get_estimated_load_progress ()
Gets the value of the estimated_load_progress property.
- public unowned Texture get_favicon ()
Returns favicon currently associated to this .
- public unowned FindController get_find_controller ()
Gets the FindController.
- public unowned InputMethodContext? get_input_method_context ()
Get the InputMethodContext currently in use by this.
- public unowned WebInspector get_inspector ()
Get the WebInspector associated to this
- public bool get_is_muted ()
Gets the mute state of this.
- public bool get_is_web_process_responsive ()
Get whether the current web process of a WebView is responsive.
- public unowned WebResource get_main_resource ()
Return the main resource of this.
- public MediaCaptureState get_microphone_capture_state ()
Get the microphone capture state of a WebView.
- public unowned NetworkSession get_network_session ()
Get the NetworkSession associated to this.
- public uint64 get_page_id ()
Get the identifier of the
WebKitWebPage
corresponding to the WebView - public WebViewSessionState get_session_state ()
Gets the current session state of this
- public unowned Settings get_settings ()
Gets the Settings currently applied to this.
- public async Texture get_snapshot (SnapshotRegion region, SnapshotOptions options, Cancellable? cancellable = null) throws Error
Asynchronously retrieves a snapshot of this for
region
. - public unowned string get_title ()
Gets the value of the title property.
- public bool get_tls_info (out unowned TlsCertificate certificate, out TlsCertificateFlags errors)
Retrieves the TlsCertificate associated with the main resource of this.
- public unowned string get_uri ()
Returns the current active URI of this.
- public unowned UserContentManager get_user_content_manager ()
Gets the user content manager associated to this .
- public WebExtensionMode get_web_extension_mode ()
Get the view's WebExtensionMode.
- public unowned WebsitePolicies get_website_policies ()
Gets the default website policies.
- public unowned WindowProperties get_window_properties ()
Get the WindowProperties object.
- public double get_zoom_level ()
Set the zoom level of this.
- public void go_back ()
Loads the previous history item.
- public void go_forward ()
Loads the next history item.
- public void go_to_back_forward_list_item (BackForwardListItem list_item)
Loads the specific history item
list_item
. - public bool is_editable ()
Gets whether the user is allowed to edit the HTML document.
- public void load_alternate_html (string content, string content_uri, string? base_uri)
Load the given
content
string for the URIcontent_uri
. - public void load_bytes (Bytes bytes, string? mime_type, string? encoding, string? base_uri)
Load the specified
bytes
into this using the givenmime_type
andencoding
. - public void load_html (string content, string? base_uri)
Load the given
content
string with the specifiedbase_uri
. - public void load_plain_text (string plain_text)
Load the specified
plain_text
string into this. - public void load_request (URIRequest request)
Requests loading of the specified URIRequest.
- public void load_uri (string uri)
Requests loading of the specified URI string.
- public void reload ()
Reloads the current contents of this.
- public void reload_bypass_cache ()
Reloads the current contents of this without using any cached data.
- public void restore_session_state (WebViewSessionState state)
Restore the this session state from
state
- public async InputStream save (SaveMode save_mode, Cancellable? cancellable = null) throws Error
Asynchronously save the current web page.
- public async bool save_to_file (File file, SaveMode save_mode, Cancellable? cancellable = null) throws Error
Asynchronously save the current web page.
- public async UserMessage send_message_to_page (UserMessage message, Cancellable? cancellable = null) throws Error
Send
message
to theWebKitWebPage
corresponding to this. - public void set_background_color (RGBA rgba)
Sets the color that will be used to draw the this background.
- public void set_camera_capture_state (MediaCaptureState state)
Set the camera capture state of a WebView.
- public void set_cors_allowlist (string[]? allowlist)
Sets the
allowlist
for CORS. - public void set_custom_charset (string? charset)
Sets the current custom character encoding override of this.
- public void set_display_capture_state (MediaCaptureState state)
Set the display capture state of a WebView.
- public void set_editable (bool editable)
Sets whether the user is allowed to edit the HTML document.
- public void set_input_method_context (InputMethodContext? context)
Set the InputMethodContext to be used by this.
- public void set_is_muted (bool muted)
Sets the mute state of this.
- public void set_microphone_capture_state (MediaCaptureState state)
Set the microphone capture state of a WebView.
- public void set_settings (Settings settings)
Sets the Settings to be applied to this.
- public void set_zoom_level (double zoom_level)
Set the zoom level of this.
- public virtual bool show_option_menu (OptionMenu menu, Rectangle rectangle)
- public void stop_loading ()
Stops any ongoing loading operation in this .
- public void terminate_web_process ()
Terminates the web process associated to this .
- public void try_close ()
Tries to close the this.
- public virtual bool web_process_crashed ()
Signals:
- public virtual signal bool authenticate (AuthenticationRequest request)
This signal is emitted when the user is challenged with HTTP authentication.
- public virtual signal void close ()
Emitted when closing a WebView is requested.
- public virtual signal bool context_menu (ContextMenu context_menu, HitTestResult hit_test_result)
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.
- public virtual signal void context_menu_dismissed ()
Emitted after context_menu signal, if the context menu is shown, to notify that the context menu is dismissed.
- public signal Widget create (NavigationAction navigation_action)
Emitted when the creation of a new WebView is requested.
- public virtual signal bool decide_policy (PolicyDecision decision, PolicyDecisionType 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.
- public virtual signal bool enter_fullscreen ()
Emitted when JavaScript code calls <function>element.
- public virtual signal void insecure_content_detected (InsecureContentEvent event)
This signal is emitted when insecure content has been detected in a page loaded through a secure connection.
- public virtual signal bool leave_fullscreen ()
Emitted when the WebView is about to restore its top level window out of its full screen state.
- public virtual signal void load_changed (LoadEvent load_event)
Emitted when a load operation in
web_view
changes. - public virtual signal bool load_failed (LoadEvent load_event, string failing_uri, Error error)
Emitted when an error occurs during a load operation.
- public virtual signal bool load_failed_with_tls_errors (string failing_uri, TlsCertificate certificate, TlsCertificateFlags errors)
Emitted when a TLS error occurs during a load operation.
- public virtual signal void mouse_target_changed (HitTestResult hit_test_result, uint modifiers)
This signal is emitted when the mouse cursor moves over an element such as a link, image or a media element.
- public signal bool on_show_option_menu (OptionMenu menu, Rectangle rectangle)
This signal is emitted when a select element in
web_view
needs to display a dropdown menu. - public virtual signal bool permission_request (PermissionRequest permission_request)
This signal is emitted when WebKit is requesting the client to decide about a permission request, such as allowing the browser to switch to fullscreen mode, sharing its location or similar operations.
- public virtual signal bool print (PrintOperation print_operation)
Emitted when printing is requested on
web_view
, usually by a JavaScript call, before the print dialog is shown. - public virtual signal bool query_permission_state (PermissionStateQuery query)
This signal allows the User-Agent to respond to permission requests for powerful features, as specified by the Permissions W3C Specification.
- public virtual signal void ready_to_show ()
Emitted after create on the newly created WebView when it should be displayed to the user.
- public virtual signal void resource_load_started (WebResource resource, URIRequest request)
Emitted when a new resource is going to be loaded.
- public virtual signal void run_as_modal ()
Emitted after ready_to_show on the newly created WebView when JavaScript code calls <function>window.
- public virtual signal bool run_color_chooser (ColorChooserRequest request)
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.
- public virtual signal bool run_file_chooser (FileChooserRequest request)
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.
- public virtual signal bool script_dialog (ScriptDialog dialog)
Emitted when JavaScript code calls <function>window.
- public virtual signal bool show_notification (Notification notification)
This signal is emitted when a notification should be presented to the user.
- public virtual signal void submit_form (FormSubmissionRequest request)
This signal is emitted when a form is about to be submitted.
- public virtual signal bool user_message_received (UserMessage message)
This signal is emitted when a UserMessage is received from the
WebKitWebPage
corresponding toweb_view
. - public virtual signal void web_process_terminated (WebProcessTerminationReason reason)
This signal is emitted when the web process terminates abnormally due to
reason
.
Inherited Members:
All known members inherited from class Gtk.Widget
- action_set_enabled
- activate
- activate_action
- activate_action_variant
- activate_default
- add_binding
- add_binding_action
- add_binding_signal
- add_controller
- add_css_class
- add_mnemonic_label
- add_shortcut
- add_tick_callback
- allocate
- allocate_size
- bind_template_callback_full
- bind_template_child_full
- can_focus
- can_target
- child_focus
- compute_bounds
- compute_expand
- compute_expand_internal
- compute_point
- compute_transform
- contains
- create_pango_context
- create_pango_layout
- css_changed
- css_classes
- css_name
- cursor
- destroy
- direction_changed
- dispose_template
- error_bell
- focus
- focus_on_click
- focusable
- get_accessible_role
- get_activate_signal
- get_allocated_baseline
- get_allocated_height
- get_allocated_width
- get_allocation
- get_ancestor
- get_baseline
- get_can_focus
- get_can_target
- get_child_visible
- get_clipboard
- get_color
- get_css_classes
- get_css_name
- get_cursor
- get_default_direction
- get_direction
- get_display
- get_first_child
- get_focus_child
- get_focus_on_click
- get_focusable
- get_font_map
- get_font_options
- get_frame_clock
- get_halign
- get_has_tooltip
- get_height
- get_hexpand
- get_hexpand_set
- get_last_child
- get_layout_manager
- get_layout_manager_type
- get_mapped
- get_margin_bottom
- get_margin_end
- get_margin_start
- get_margin_top
- get_name
- get_native
- get_next_sibling
- get_opacity
- get_overflow
- get_pango_context
- get_parent
- get_preferred_size
- get_prev_sibling
- get_primary_clipboard
- get_realized
- get_receives_default
- get_request_mode
- get_root
- get_scale_factor
- get_sensitive
- get_settings
- get_size
- get_size_request
- get_state_flags
- get_style_context
- get_template_child
- get_tooltip_markup
- get_tooltip_text
- get_valign
- get_vexpand
- get_vexpand_set
- get_visible
- get_width
- grab_focus
- halign
- has_css_class
- has_default
- has_focus
- has_tooltip
- has_visible_focus
- height_request
- hexpand
- hexpand_set
- hide
- in_destruction
- init_template
- insert_action_group
- insert_after
- insert_before
- install_action
- install_property_action
- is_ancestor
- is_drawable
- is_focus
- is_sensitive
- is_visible
- keynav_failed
- layout_manager
- list_mnemonic_labels
- map
- margin_bottom
- margin_end
- margin_start
- margin_top
- measure
- mnemonic_activate
- move_focus
- name
- observe_children
- observe_controllers
- opacity
- overflow
- parent
- pick
- query_action
- query_tooltip
- queue_allocate
- queue_draw
- queue_resize
- realize
- receives_default
- remove_controller
- remove_css_class
- remove_mnemonic_label
- remove_tick_callback
- root
- scale_factor
- sensitive
- set_accessible_role
- set_activate_signal
- set_activate_signal_from_name
- set_can_focus
- set_can_target
- set_child_visible
- set_css_classes
- set_css_name
- set_cursor
- set_cursor_from_name
- set_default_direction
- set_direction
- set_focus_child
- set_focus_on_click
- set_focusable
- set_font_map
- set_font_options
- set_halign
- set_has_tooltip
- set_hexpand
- set_hexpand_set
- set_layout_manager
- set_layout_manager_type
- set_margin_bottom
- set_margin_end
- set_margin_start
- set_margin_top
- set_name
- set_opacity
- set_overflow
- set_parent
- set_receives_default
- set_sensitive
- set_size_request
- set_state_flags
- set_template
- set_template_from_resource
- set_template_scope
- set_tooltip_markup
- set_tooltip_text
- set_valign
- set_vexpand
- set_vexpand_set
- set_visible
- should_layout
- show
- size_allocate
- snapshot
- snapshot_child
- state_flags_changed
- system_setting_changed
- tooltip_markup
- tooltip_text
- translate_coordinates
- trigger_tooltip_query
- unmap
- unparent
- unrealize
- unroot
- unset_state_flags
- valign
- vexpand
- vexpand_set
- visible
- width_request
All known members inherited from class GLib.Object
All known members inherited from interface Gtk.Accessible
All known members inherited from interface Gtk.Buildable