pub trait WebExtensionExt: 'static {
fn page(&self, page_id: u64) -> Option<WebPage>;
fn send_message_to_context<P: FnOnce(Result<UserMessage, Error>) + 'static>(
&self,
message: &impl IsA<UserMessage>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
);
fn send_message_to_context_future(
&self,
message: &impl IsA<UserMessage> + Clone + 'static
) -> Pin<Box_<dyn Future<Output = Result<UserMessage, Error>> + 'static>>;
fn connect_page_created<F: Fn(&Self, &WebPage) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_user_message_received<F: Fn(&Self, &UserMessage) + 'static>(
&self,
f: F
) -> SignalHandlerId;
}
Expand description
Required Methods
sourcefn send_message_to_context<P: FnOnce(Result<UserMessage, Error>) + 'static>(
&self,
message: &impl IsA<UserMessage>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn send_message_to_context<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 WebKitWebContext
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 calback
.
When the operation is finished, callback
will be called. You can then call
webkit_web_extension_send_message_to_context_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_context_future(
&self,
message: &impl IsA<UserMessage> + Clone + 'static
) -> Pin<Box_<dyn Future<Output = Result<UserMessage, Error>> + 'static>>
fn send_message_to_context_future(
&self,
message: &impl IsA<UserMessage> + Clone + 'static
) -> Pin<Box_<dyn Future<Output = Result<UserMessage, Error>> + 'static>>
v2_28
only.sourcefn connect_page_created<F: Fn(&Self, &WebPage) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_page_created<F: Fn(&Self, &WebPage) + 'static>(
&self,
f: F
) -> SignalHandlerId
sourcefn connect_user_message_received<F: Fn(&Self, &UserMessage) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_user_message_received<F: Fn(&Self, &UserMessage) + 'static>(
&self,
f: F
) -> SignalHandlerId
v2_28
only.This signal is emitted when a UserMessage
is received from the
WebKitWebContext
corresponding to extension
. Messages sent by WebKitWebContext
are always broadcasted to all WebExtension
s and they can’t be
replied to. Calling UserMessageExt::send_reply()
will do nothing.
message
the UserMessage
received