Trait webkit2gtk_webextension::prelude::WebPageExt
source · [−]pub trait WebPageExt: 'static {
Show 13 methods
fn dom_document(&self) -> Option<DOMDocument>;
fn editor(&self) -> Option<WebEditor>;
fn id(&self) -> u64;
fn main_frame(&self) -> Option<Frame>;
fn uri(&self) -> Option<GString>;
fn send_message_to_view<P: FnOnce(Result<UserMessage, Error>) + 'static>(
&self,
message: &impl IsA<UserMessage>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
);
fn send_message_to_view_future(
&self,
message: &impl IsA<UserMessage> + Clone + 'static
) -> Pin<Box_<dyn Future<Output = Result<UserMessage, Error>> + 'static>>;
fn connect_console_message_sent<F: Fn(&Self, &ConsoleMessage) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_context_menu<F: Fn(&Self, &ContextMenu, &WebHitTestResult) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_document_loaded<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_send_request<F: Fn(&Self, &URIRequest, Option<&URIResponse>) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_user_message_received<F: Fn(&Self, &UserMessage) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
Expand description
Required Methods
sourcefn dom_document(&self) -> Option<DOMDocument>
fn dom_document(&self) -> Option<DOMDocument>
Get the DOMDocument
currently loaded in self
Returns
the DOMDocument
currently loaded, or None
if no document is currently loaded.
sourcefn main_frame(&self) -> Option<Frame>
fn main_frame(&self) -> Option<Frame>
v2_26
only.sourcefn send_message_to_view<P: FnOnce(Result<UserMessage, Error>) + 'static>(
&self,
message: &impl IsA<UserMessage>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn send_message_to_view<P: FnOnce(Result<UserMessage, Error>) + 'static>(
&self,
message: &impl IsA<UserMessage>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
v2_28
only.Send message
to the WebKitWebView
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 None
as callback
.
When the operation is finished, callback
will be called. You can then call
webkit_web_page_send_message_to_view_finish()
to get the message reply.
message
cancellable
a gio::Cancellable
or None
to ignore
callback
(nullable): A GAsyncReadyCallback
to call when the request is satisfied or None
sourcefn send_message_to_view_future(
&self,
message: &impl IsA<UserMessage> + Clone + 'static
) -> Pin<Box_<dyn Future<Output = Result<UserMessage, Error>> + 'static>>
fn send_message_to_view_future(
&self,
message: &impl IsA<UserMessage> + Clone + 'static
) -> Pin<Box_<dyn Future<Output = Result<UserMessage, Error>> + 'static>>
v2_28
only.sourcefn connect_console_message_sent<F: Fn(&Self, &ConsoleMessage) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_console_message_sent<F: Fn(&Self, &ConsoleMessage) + 'static>(
&self,
f: F
) -> SignalHandlerId
v2_12
only.Emitted when a message is sent to the console. This can be a message
produced by the use of JavaScript console API, a JavaScript exception,
a security error or other errors, warnings, debug or log messages.
The console_message
contains information of the message.
console_message
the ConsoleMessage
v2_8
only.Emitted before a context menu is displayed in the UI Process to
give the application a chance to customize the proposed menu,
build its own context menu or pass user data to the UI Process.
This signal is useful when the information available in the UI Process
is not enough to build or customize the context menu, for example, to
add menu entries depending on the DOMNode
at the coordinates of the
hit_test_result
. Otherwise, it’s recommended to use WebKitWebView::context-menu
signal instead.
context_menu
the proposed ContextMenu
hit_test_result
Returns
true
if the proposed context_menu
has been modified, or false
otherwise.
sourcefn connect_document_loaded<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_document_loaded<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
This signal is emitted when the DOM document of a WebPage
has been
loaded.
You can wait for this signal to get the DOM document with
dom_document()
.
sourcefn connect_send_request<F: Fn(&Self, &URIRequest, Option<&URIResponse>) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_send_request<F: Fn(&Self, &URIRequest, Option<&URIResponse>) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
This signal is emitted when request
is about to be sent to
the server. This signal can be used to modify the URIRequest
that will be sent to the server. You can also cancel the resource load
operation by connecting to this signal and returning true
.
In case of a server redirection this signal is
emitted again with the request
argument containing the new
request to be sent to the server due to the redirection and the
redirected_response
parameter containing the response
received by the server for the initial request.
Modifications to the URIRequest
and its associated
SoupMessageHeaders
will be taken into account when the request
is sent over the network.
request
redirected_response
a URIResponse
, or None
Returns
true
to stop other handlers from being invoked for the event.
false
to continue emission of the event.
sourcefn connect_user_message_received<F: Fn(&Self, &UserMessage) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_user_message_received<F: Fn(&Self, &UserMessage) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
v2_28
only.This signal is emitted when a UserMessage
is received from the
WebKitWebView
corresponding to web_page
. You can reply to the message
using UserMessageExt::send_reply()
.
You can handle the user message asynchronously by calling g_object_ref()
on
message
and returning true
. If the last reference of message
is removed
and the message has been replied, the operation in the WebKitWebView
will
finish with error UserMessageError::UserMessageUnhandledMessage
.
message
the UserMessage
received