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

Trait containing all WebExtension methods.

Implementors

WebExtension

Required Methods

Get the web page of the given page_id.

page_id

the identifier of the WebPage to get

Returns

the WebPage for the given page_id, or None if the identifier doesn’t correspond to an existing web page.

Available on crate feature 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

a UserMessage

cancellable

a gio::Cancellable or None to ignore

callback

(nullable): A GAsyncReadyCallback to call when the request is satisfied or None

Available on crate feature v2_28 only.

This signal is emitted when a new WebPage is created in the Web Process.

web_page

the WebPage created

Available on crate feature 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 WebExtensions and they can’t be replied to. Calling UserMessageExt::send_reply() will do nothing.

message

the UserMessage received

Implementors