WebView
Object Hierarchy:
Description:
[ CCode ( type_id = "webkit_web_view_get_type ()" ) ]
public class WebView : WebViewBase, Implementor, Buildable
public class WebView : WebViewBase, Implementor, Buildable
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: webkit2gtk-4.1
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 void* 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_ephemeral { get; construct; }
Whether the WebView is ephemeral.
- 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 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.
- public WebView.with_context (WebContext context)
Creates a new WebView with the given WebContext.
- public WebView.with_related_view (WebView web_view)
Creates a new WebView sharing the same web process with
web_view
. - public WebView.with_settings (Settings settings)
Creates a new WebView with the given Settings.
- public WebView.with_user_content_manager (UserContentManager user_content_manager)
Creates a new WebView with the given UserContentManager.
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 Surface 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 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 Surface 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 WebsiteDataManager get_website_data_manager ()
Get the WebsiteDataManager associated to this .
- 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 void run_async_javascript_function_in_world (string body, Variant arguments, string world_name, Cancellable? cancellable = null)
Asynchronously run
body
in the script world with nameworld_name
of the current page context in this. - public async JavascriptResult run_javascript (string script, Cancellable? cancellable = null) throws Error
Asynchronously run
script
in the context of the current page in this. - public async JavascriptResult run_javascript_from_gresource (string resource, Cancellable? cancellable = null) throws Error
Asynchronously run the script from
resource
. - public async JavascriptResult run_javascript_in_world (string script, string world_name, Cancellable? cancellable = null) throws Error
Asynchronously run
script
in the script world. - 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, Event event, 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.
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, Event event, 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, Event event, 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 bool web_process_crashed ()
This signal is emitted when the web process crashes.
- 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.Container
All known members inherited from class Gtk.Widget
- accel_closures_changed
- activate
- add_accelerator
- add_device_events
- add_events
- add_mnemonic_label
- add_tick_callback
- adjust_baseline_allocation
- adjust_baseline_request
- adjust_size_allocation
- adjust_size_request
- app_paintable
- bind_template_callback_full
- bind_template_child_full
- button_press_event
- button_release_event
- can_activate_accel
- can_default
- can_focus
- child_focus
- child_notify
- class_path
- composite_child
- composited_changed
- compute_expand
- compute_expand_internal
- configure_event
- create_pango_context
- create_pango_layout
- damage_event
- delete_event
- destroy
- destroy_event
- destroyed
- device_is_shadowed
- direction_changed
- dispatch_child_properties_changed
- double_buffered
- drag_begin
- drag_data_delete
- drag_data_get
- drag_data_received
- drag_drop
- drag_end
- drag_failed
- drag_leave
- drag_motion
- draw
- draw_to_cairo_context
- ensure_style
- enter_notify_event
- error_bell
- event
- event_after
- events
- expand
- find_style_property
- focus
- focus_in_event
- focus_on_click
- focus_out_event
- freeze_child_notify
- get_accessible
- get_action_group
- get_allocated_baseline
- get_allocated_height
- get_allocated_size
- get_allocated_width
- get_allocation
- get_ancestor
- get_app_paintable
- get_can_default
- get_can_focus
- get_child_requisition
- get_child_visible
- get_clip
- get_clipboard
- get_composite_name
- get_css_name
- get_default_direction
- get_default_style
- get_device_enabled
- get_device_events
- get_direction
- get_display
- get_double_buffered
- get_events
- get_focus_on_click
- get_font_map
- get_font_options
- get_frame_clock
- get_halign
- get_has_tooltip
- get_has_window
- get_hexpand
- get_hexpand_set
- get_mapped
- get_margin_bottom
- get_margin_end
- get_margin_left
- get_margin_right
- get_margin_start
- get_margin_top
- get_modifier_mask
- get_modifier_style
- get_no_show_all
- get_opacity
- get_pango_context
- get_parent
- get_parent_window
- get_path
- get_pointer
- get_preferred_height
- get_preferred_height_and_baseline_for_width
- get_preferred_height_for_width
- get_preferred_height_for_width_internal
- get_preferred_height_internal
- get_preferred_size
- get_preferred_width
- get_preferred_width_for_height
- get_preferred_width_for_height_internal
- get_preferred_width_internal
- get_realized
- get_receives_default
- get_request_mode
- get_requisition
- get_root_window
- get_scale_factor
- get_screen
- get_sensitive
- get_settings
- get_size_request
- get_state
- get_state_flags
- get_style
- get_style_context
- get_support_multidevice
- get_template_child
- get_tooltip_markup
- get_tooltip_text
- get_tooltip_window
- get_toplevel
- get_valign
- get_valign_with_baseline
- get_vexpand
- get_vexpand_set
- get_visible
- get_visual
- get_window
- grab_broken_event
- grab_default
- grab_focus
- grab_notify
- halign
- has_default
- has_focus
- has_grab
- has_rc_style
- has_screen
- has_tooltip
- has_visible_focus
- height_request
- hexpand
- hexpand_set
- hide
- hide_on_delete
- hierarchy_changed
- in_destruction
- init_template
- input_shape_combine_region
- insert_action_group
- install_style_property
- install_style_property_parser
- intersect
- is_ancestor
- is_composited
- is_drawable
- is_focus
- is_sensitive
- is_toplevel
- is_visible
- key_press_event
- key_release_event
- keynav_failed
- leave_notify_event
- list_accel_closures
- list_action_prefixes
- list_mnemonic_labels
- list_style_properties
- map
- map_event
- margin
- margin_bottom
- margin_end
- margin_left
- margin_right
- margin_start
- margin_top
- mnemonic_activate
- modify_base
- modify_bg
- modify_cursor
- modify_fg
- modify_font
- modify_style
- modify_text
- motion_notify_event
- move_focus
- name
- no_show_all
- opacity
- override_background_color
- override_color
- override_cursor
- override_font
- override_symbolic_color
- parent
- parent_set
- path
- pop_composite_child
- popup_menu
- property_notify_event
- proximity_in_event
- proximity_out_event
- push_composite_child
- query_tooltip
- queue_allocate
- queue_compute_expand
- queue_draw
- queue_draw_area
- queue_draw_region
- queue_resize
- queue_resize_no_redraw
- realize
- receives_default
- region_intersect
- register_window
- remove_accelerator
- remove_mnemonic_label
- remove_tick_callback
- render_icon
- render_icon_pixbuf
- reparent
- reset_rc_styles
- reset_style
- scale_factor
- screen_changed
- scroll_event
- selection_clear_event
- selection_get
- selection_notify_event
- selection_received
- selection_request_event
- send_expose
- send_focus_change
- sensitive
- set_accel_path
- set_accessible_role
- set_accessible_type
- set_allocation
- set_app_paintable
- set_can_default
- set_can_focus
- set_child_visible
- set_clip
- set_composite_name
- set_connect_func
- set_css_name
- set_default_direction
- set_device_enabled
- set_device_events
- set_direction
- set_double_buffered
- set_events
- set_focus_on_click
- set_font_map
- set_font_options
- set_halign
- set_has_tooltip
- set_has_window
- set_hexpand
- set_hexpand_set
- set_mapped
- set_margin_bottom
- set_margin_end
- set_margin_left
- set_margin_right
- set_margin_start
- set_margin_top
- set_no_show_all
- set_opacity
- set_parent
- set_parent_window
- set_realized
- set_receives_default
- set_redraw_on_allocate
- set_sensitive
- set_size_request
- set_state
- set_state_flags
- set_style
- set_support_multidevice
- set_template
- set_template_from_resource
- set_tooltip_markup
- set_tooltip_text
- set_tooltip_window
- set_valign
- set_vexpand
- set_vexpand_set
- set_visible
- set_visual
- set_window
- shape_combine_region
- show
- show_all
- show_help
- show_now
- size_allocate
- size_allocate_with_baseline
- size_request
- state_changed
- state_flags_changed
- style
- style_attach
- style_get
- style_get_property
- style_get_valist
- style_set
- style_updated
- thaw_child_notify
- tooltip_markup
- tooltip_text
- touch_event
- translate_coordinates
- trigger_tooltip_query
- unmap
- unmap_event
- unparent
- unrealize
- unregister_window
- unset_state_flags
- valign
- vexpand
- vexpand_set
- visibility_notify_event
- visible
- width_request
- window_state_event
All known members inherited from class GLib.Object
All known members inherited from interface Atk.Implementor
All known members inherited from interface Gtk.Buildable