pub trait WebViewDelegate {
Show 30 methods
// Provided methods
fn notify_url_changed(&self, _webview: WebView, _url: Url) { ... }
fn notify_page_title_changed(
&self,
_webview: WebView,
_title: Option<String>,
) { ... }
fn notify_status_text_changed(
&self,
_webview: WebView,
_status: Option<String>,
) { ... }
fn notify_focus_changed(&self, _webview: WebView, _focused: bool) { ... }
fn notify_load_status_changed(&self, _webview: WebView, _status: LoadStatus) { ... }
fn notify_cursor_changed(&self, _webview: WebView, _: Cursor) { ... }
fn notify_favicon_url_changed(&self, _webview: WebView, _: Url) { ... }
fn notify_new_frame_ready(&self, _webview: WebView) { ... }
fn notify_history_changed(&self, _webview: WebView, _: Vec<Url>, _: usize) { ... }
fn notify_closed(&self, _webview: WebView) { ... }
fn notify_keyboard_event(&self, _webview: WebView, _: KeyboardEvent) { ... }
fn notify_crashed(
&self,
_webview: WebView,
_reason: String,
_backtrace: Option<String>,
) { ... }
fn notify_media_session_event(
&self,
_webview: WebView,
_event: MediaSessionEvent,
) { ... }
fn notify_fullscreen_state_changed(&self, _webview: WebView, _: bool) { ... }
fn request_navigation(
&self,
_webview: WebView,
_navigation_request: NavigationRequest,
) { ... }
fn request_unload(
&self,
_webview: WebView,
_unload_request: AllowOrDenyRequest,
) { ... }
fn request_move_to(&self, _webview: WebView, _: DeviceIntPoint) { ... }
fn request_resize_to(&self, _webview: WebView, _: DeviceIntSize) { ... }
fn request_open_auxiliary_webview(
&self,
_parent_webview: WebView,
) -> Option<WebView> { ... }
fn request_permission(&self, _webview: WebView, _: PermissionRequest) { ... }
fn request_authentication(
&self,
_webview: WebView,
_authentication_request: AuthenticationRequest,
) { ... }
fn show_simple_dialog(&self, _webview: WebView, dialog: SimpleDialog) { ... }
fn show_context_menu(
&self,
_webview: WebView,
result_sender: IpcSender<ContextMenuResult>,
_: Option<String>,
_: Vec<String>,
) { ... }
fn show_bluetooth_device_dialog(
&self,
_webview: WebView,
_: Vec<String>,
response_sender: IpcSender<Option<String>>,
) { ... }
fn show_file_selection_dialog(
&self,
_webview: WebView,
_filter_pattern: Vec<FilterPattern>,
_allow_select_mutiple: bool,
response_sender: IpcSender<Option<Vec<PathBuf>>>,
) { ... }
fn show_ime(
&self,
_webview: WebView,
_type: InputMethodType,
_text: Option<(String, i32)>,
_multiline: bool,
_position: DeviceIntRect,
) { ... }
fn hide_ime(&self, _webview: WebView) { ... }
fn play_gamepad_haptic_effect(
&self,
_webview: WebView,
_: usize,
_: GamepadHapticEffectType,
_: IpcSender<bool>,
) { ... }
fn stop_gamepad_haptic_effect(
&self,
_webview: WebView,
_: usize,
_: IpcSender<bool>,
) { ... }
fn load_web_resource(&self, _webview: WebView, _load: WebResourceLoad) { ... }
}
Provided Methods§
Sourcefn notify_url_changed(&self, _webview: WebView, _url: Url)
fn notify_url_changed(&self, _webview: WebView, _url: Url)
The URL of the currently loaded page in this WebView
has changed. The new
URL can accessed via WebView::url
.
Sourcefn notify_page_title_changed(&self, _webview: WebView, _title: Option<String>)
fn notify_page_title_changed(&self, _webview: WebView, _title: Option<String>)
The page title of the currently loaded page in this WebView
has changed. The new
title can accessed via WebView::page_title
.
Sourcefn notify_status_text_changed(&self, _webview: WebView, _status: Option<String>)
fn notify_status_text_changed(&self, _webview: WebView, _status: Option<String>)
The status text of the currently loaded page in this WebView
has changed. The new
status text can accessed via WebView::status_text
.
Sourcefn notify_focus_changed(&self, _webview: WebView, _focused: bool)
fn notify_focus_changed(&self, _webview: WebView, _focused: bool)
This WebView
has either become focused or lost focus. Whether or not the
WebView
is focused can be accessed via WebView::focused
.
Sourcefn notify_load_status_changed(&self, _webview: WebView, _status: LoadStatus)
fn notify_load_status_changed(&self, _webview: WebView, _status: LoadStatus)
The LoadStatus
of the currently loading or loaded page in this WebView
has changed. The new
status can accessed via WebView::load_status
.
Sourcefn notify_cursor_changed(&self, _webview: WebView, _: Cursor)
fn notify_cursor_changed(&self, _webview: WebView, _: Cursor)
The Cursor
of the currently loaded page in this WebView
has changed. The new
cursor can accessed via WebView::cursor
.
Sourcefn notify_favicon_url_changed(&self, _webview: WebView, _: Url)
fn notify_favicon_url_changed(&self, _webview: WebView, _: Url)
The favicon Url
of the currently loaded page in this WebView
has changed. The new
favicon Url
can accessed via WebView::favicon_url
.
Sourcefn notify_new_frame_ready(&self, _webview: WebView)
fn notify_new_frame_ready(&self, _webview: WebView)
Notify the embedder that it needs to present a new frame.
Sourcefn notify_history_changed(&self, _webview: WebView, _: Vec<Url>, _: usize)
fn notify_history_changed(&self, _webview: WebView, _: Vec<Url>, _: usize)
The history state has changed.
Sourcefn notify_closed(&self, _webview: WebView)
fn notify_closed(&self, _webview: WebView)
Sourcefn notify_keyboard_event(&self, _webview: WebView, _: KeyboardEvent)
fn notify_keyboard_event(&self, _webview: WebView, _: KeyboardEvent)
A keyboard event has been sent to Servo, but remains unprocessed. This allows the
embedding application to handle key events while first letting the WebView
have an opportunity to handle it first. Apart from builtin keybindings, page
content may expose custom keybindings as well.
Sourcefn notify_crashed(
&self,
_webview: WebView,
_reason: String,
_backtrace: Option<String>,
)
fn notify_crashed( &self, _webview: WebView, _reason: String, _backtrace: Option<String>, )
A pipeline in the webview panicked. First string is the reason, second one is the backtrace.
Sourcefn notify_media_session_event(
&self,
_webview: WebView,
_event: MediaSessionEvent,
)
fn notify_media_session_event( &self, _webview: WebView, _event: MediaSessionEvent, )
Notifies the embedder about media session events (i.e. when there is metadata for the active media session, playback state changes…).
Sourcefn notify_fullscreen_state_changed(&self, _webview: WebView, _: bool)
fn notify_fullscreen_state_changed(&self, _webview: WebView, _: bool)
A notification that the WebView
has entered or exited fullscreen mode. This is an
opportunity for the embedder to transition the containing window into or out of fullscreen
mode and to show or hide extra UI elements. Regardless of how the notification is handled,
the page will enter or leave fullscreen state internally according to the Fullscreen
API.
Whether or not to allow a WebView
to load a URL in its main frame or one of its
nested <iframe>
s. NavigationRequest
s are accepted by default.
Sourcefn request_unload(&self, _webview: WebView, _unload_request: AllowOrDenyRequest)
fn request_unload(&self, _webview: WebView, _unload_request: AllowOrDenyRequest)
Whether or not to allow a WebView
to unload a Document
in its main frame or one
of its nested <iframe>
s. By default, unloads are allowed.
Sourcefn request_move_to(&self, _webview: WebView, _: DeviceIntPoint)
fn request_move_to(&self, _webview: WebView, _: DeviceIntPoint)
Move the window to a point
Sourcefn request_resize_to(&self, _webview: WebView, _: DeviceIntSize)
fn request_resize_to(&self, _webview: WebView, _: DeviceIntSize)
Resize the window to size
Sourcefn request_open_auxiliary_webview(
&self,
_parent_webview: WebView,
) -> Option<WebView>
fn request_open_auxiliary_webview( &self, _parent_webview: WebView, ) -> Option<WebView>
Whether or not to allow script to open a new WebView
. If not handled by the
embedder, these requests are automatically denied.
Sourcefn request_permission(&self, _webview: WebView, _: PermissionRequest)
fn request_permission(&self, _webview: WebView, _: PermissionRequest)
Content in a WebView
is requesting permission to access a feature requiring
permission from the user. The embedder should allow or deny the request, either by
reading a cached value or querying the user for permission via the user interface.
fn request_authentication( &self, _webview: WebView, _authentication_request: AuthenticationRequest, )
Sourcefn show_simple_dialog(&self, _webview: WebView, dialog: SimpleDialog)
fn show_simple_dialog(&self, _webview: WebView, dialog: SimpleDialog)
Show the user a simple dialog (alert()
, confirm()
,
or prompt()
). Since their messages are controlled by web content, they should be presented to the user in a
way that makes them impossible to mistake for browser UI.
TODO: This API needs to be reworked to match the new model of how responses are sent.
Show a context menu to the user
Sourcefn show_bluetooth_device_dialog(
&self,
_webview: WebView,
_: Vec<String>,
response_sender: IpcSender<Option<String>>,
)
fn show_bluetooth_device_dialog( &self, _webview: WebView, _: Vec<String>, response_sender: IpcSender<Option<String>>, )
Open dialog to select bluetooth device. TODO: This API needs to be reworked to match the new model of how responses are sent.
Sourcefn show_file_selection_dialog(
&self,
_webview: WebView,
_filter_pattern: Vec<FilterPattern>,
_allow_select_mutiple: bool,
response_sender: IpcSender<Option<Vec<PathBuf>>>,
)
fn show_file_selection_dialog( &self, _webview: WebView, _filter_pattern: Vec<FilterPattern>, _allow_select_mutiple: bool, response_sender: IpcSender<Option<Vec<PathBuf>>>, )
Open file dialog to select files. Set boolean flag to true allows to select multiple files.
Sourcefn show_ime(
&self,
_webview: WebView,
_type: InputMethodType,
_text: Option<(String, i32)>,
_multiline: bool,
_position: DeviceIntRect,
)
fn show_ime( &self, _webview: WebView, _type: InputMethodType, _text: Option<(String, i32)>, _multiline: bool, _position: DeviceIntRect, )
Request to present an IME to the user when an editable element is focused.
If type
is InputMethodType::Text
, then the text
parameter specifies
the pre-existing text content and the zero-based index into the string
of the insertion point.
Sourcefn hide_ime(&self, _webview: WebView)
fn hide_ime(&self, _webview: WebView)
Request to hide the IME when the editable element is blurred.
Sourcefn play_gamepad_haptic_effect(
&self,
_webview: WebView,
_: usize,
_: GamepadHapticEffectType,
_: IpcSender<bool>,
)
fn play_gamepad_haptic_effect( &self, _webview: WebView, _: usize, _: GamepadHapticEffectType, _: IpcSender<bool>, )
Request to play a haptic effect on a connected gamepad.
Sourcefn stop_gamepad_haptic_effect(
&self,
_webview: WebView,
_: usize,
_: IpcSender<bool>,
)
fn stop_gamepad_haptic_effect( &self, _webview: WebView, _: usize, _: IpcSender<bool>, )
Request to stop a haptic effect on a connected gamepad.
Sourcefn load_web_resource(&self, _webview: WebView, _load: WebResourceLoad)
fn load_web_resource(&self, _webview: WebView, _load: WebResourceLoad)
Triggered when this WebView
will load a web (HTTP/HTTPS) resource. The load may be
intercepted and alternate contents can be loaded by the client by calling
WebResourceLoad::intercept
. If not handled, the load will continue as normal.
Note: This delegate method is called for all resource loads associated with a WebView
.
For loads not associated with a WebView
, such as those for service workers, Servo
will call crate::ServoDelegate::load_web_resource
.