pub trait UserContentManagerExt: 'static {
Show 15 methods fn add_filter(&self, filter: &UserContentFilter); fn add_script(&self, script: &UserScript); fn add_style_sheet(&self, stylesheet: &UserStyleSheet); fn register_script_message_handler(&self, name: &str) -> bool; fn register_script_message_handler_in_world(
        &self,
        name: &str,
        world_name: &str
    ) -> bool; fn remove_all_filters(&self); fn remove_all_scripts(&self); fn remove_all_style_sheets(&self); fn remove_filter(&self, filter: &UserContentFilter); fn remove_filter_by_id(&self, filter_id: &str); fn remove_script(&self, script: &UserScript); fn remove_style_sheet(&self, stylesheet: &UserStyleSheet); fn unregister_script_message_handler(&self, name: &str); fn unregister_script_message_handler_in_world(
        &self,
        name: &str,
        world_name: &str
    ); fn connect_script_message_received<F: Fn(&Self, &JavascriptResult) + 'static>(
        &self,
        detail: Option<&str>,
        f: F
    ) -> SignalHandlerId;
}
Available on crate feature v2_6 only.
Expand description

Trait containing all UserContentManager methods.

Implementors

UserContentManager

Required Methods

Available on crate feature v2_24 only.

Adds a UserContentFilter to the given UserContentManager.

The same UserContentFilter can be reused with multiple UserContentManager instances.

Filters need to be saved and loaded from UserContentFilterStore.

filter

A UserContentFilter

Adds a UserScript to the given UserContentManager.

The same UserScript can be reused with multiple UserContentManager instances.

script

A UserScript

Adds a UserStyleSheet to the given UserContentManager.

The same UserStyleSheet can be reused with multiple UserContentManager instances.

stylesheet

A UserStyleSheet

Available on crate feature v2_8 only.

Registers a new user script message handler.

After it is registered, scripts can use window.webkit.messageHandlers..postMessage(value) to send messages. Those messages are received by connecting handlers to the signal::UserContentManager::script-message-received signal. The handler name is used as the detail of the signal. To avoid race conditions between registering the handler name, and starting to receive the signals, it is recommended to connect to the signal before registering the handler name:

⚠️ The following code is in c ⚠️

WebKitWebView *view = webkit_web_view_new ();
WebKitUserContentManager *manager = webkit_web_view_get_user_content_manager ();
g_signal_connect (manager, "script-message-received::foobar",
                  G_CALLBACK (handle_script_message), NULL);
webkit_user_content_manager_register_script_message_handler (manager, "foobar");

Registering a script message handler will fail if the requested name has been already registered before.

name

Name of the script message channel

Returns

true if message handler was registered successfully, or false otherwise.

Available on crate feature v2_22 only.

Registers a new user script message handler in script world.

Registers a new user script message handler in script world with name world_name. See register_script_message_handler() for full description.

Registering a script message handler will fail if the requested name has been already registered before.

name

Name of the script message channel

world_name

the name of a WebKitScriptWorld

Returns

true if message handler was registered successfully, or false otherwise.

Available on crate feature v2_24 only.

Removes all content filters from the given UserContentManager.

Removes all user scripts from the given UserContentManager

See also remove_script().

Removes all user style sheets from the given UserContentManager.

Available on crate feature v2_24 only.

Removes a filter from the given UserContentManager.

Since 2.24

filter

A UserContentFilter

Available on crate feature v2_26 only.

Removes a filter by the given identifier.

Removes a filter from the given UserContentManager given the identifier of a UserContentFilter as returned by UserContentFilter::identifier().

filter_id

Filter identifier

Available on crate feature v2_32 only.

Removes a UserScript from the given UserContentManager.

See also remove_all_scripts().

script

A UserScript

Available on crate feature v2_32 only.
Available on crate feature v2_8 only.

Unregisters a previously registered message handler.

Note that this does not disconnect handlers for the signal::UserContentManager::script-message-received signal; they will be kept connected, but the signal will not be emitted unless the handler name is registered again.

See also register_script_message_handler().

name

Name of the script message channel

Available on crate feature v2_22 only.

Unregisters a previously registered message handler in script world with name world_name.

Note that this does not disconnect handlers for the signal::UserContentManager::script-message-received signal; they will be kept connected, but the signal will not be emitted unless the handler name is registered again.

See also register_script_message_handler_in_world().

name

Name of the script message channel

world_name

the name of a WebKitScriptWorld

Available on crate feature v2_8 only.

This signal is emitted when JavaScript in a web view calls <code>window.webkit.messageHandlers.<name>.postMessage()</code>, after registering <code>``<name>``</code> using register_script_message_handler()

js_result

the JavascriptResult holding the value received from the JavaScript world.

Implementors