It derives from <GObject>.
Manages user-defined content which affects web pages.
Using a <WebKitUserContentManager> user
CSS style sheets can be set to be injected in the web pages loaded by a
<WebKitWebView>, by user-content-manager:add-style-sheet.
To use a <WebKitUserContentManager>, it
must be created using user-content-manager:new, and then used to construct a
<WebKitWebView>. User style sheets can be created
with user-style-sheet:new.
User style sheets can be added and removed at any time, but they will affect the web pages loaded afterwards.
Adds a <WebKitUserContentFilter> to the
given <WebKitUserContentManager>.
The same <WebKitUserContentFilter> can
be reused with multiple
<WebKitUserContentManager> instances.
Filters need to be saved and loaded from
<WebKitUserContentFilterStore>.
Passed: a <WebKitUserContentManager>.
Passed: a <WebKitUserContentFilter>.
Adds a <WebKitUserScript> to the given
<WebKitUserContentManager>.
The same <WebKitUserScript> can be reused with
multiple <WebKitUserContentManager>
instances.
Passed: a <WebKitUserContentManager>.
Passed: a <WebKitUserScript>.
Adds a <WebKitUserStyleSheet> to the given
<WebKitUserContentManager>.
The same <WebKitUserStyleSheet> can be
reused with multiple
<WebKitUserContentManager> instances.
Passed: a <WebKitUserContentManager>.
Passed: a <WebKitUserStyleSheet>.
Creates a new user content manager.
Returned: a <WebKitUserContentManager>.
Registers a new user script message handler in script world with name world-name.
Different from user-content-manager:register-script-message-handler?,
when using this function to register the handler, the connected signal
is script-message-with-reply-received, and a reply provided by the user
is expected. Otherwise, the user will receive a default undefined
value.
If #f is passed as the world-name, the default world will
be used. See user-content-manager:register-script-message-handler?
for full description.
Registering a script message handler will fail if the requested name has been already registered before.
The registered handler can be unregistered by using
user-content-manager:unregister-script-message-handler.
Passed: a <WebKitUserContentManager>.
Passed: a string.
Name of the script message channel
Passed, or left out: a string, or #f.
the name of a WebKitScriptWorld
Returned: a boolean.
#t if message handler was registered successfully, or #f
otherwise.
Registers a new user script message handler in script world.
After it is registered, scripts can use
window.webkit.messageHandlers.<name>.postMessage(value) to send
messages. Those messages are received by connecting handlers to the
user-content-manager: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:
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", "world");
Registering a script message handler will fail if the requested name has been already registered before.
If #f is passed as the world-name, the default world will
be used.
The registered handler can be unregistered by using
user-content-manager:unregister-script-message-handler.
Passed: a <WebKitUserContentManager>.
Passed: a string.
Name of the script message channel
Passed, or left out: a string, or #f.
the name of a WebKitScriptWorld
Returned: a boolean.
#t if message handler was registered successfully, or #f
otherwise.
Removes all content filters from the given
<WebKitUserContentManager>.
Passed: a <WebKitUserContentManager>.
Removes all user scripts from the given
<WebKitUserContentManager>
See also user-content-manager:remove-script.
Passed: a <WebKitUserContentManager>.
Removes all user style sheets from the given
<WebKitUserContentManager>.
Passed: a <WebKitUserContentManager>.
Removes a filter from the given
<WebKitUserContentManager>.
Since 2.24
Passed: a <WebKitUserContentManager>.
Passed: a <WebKitUserContentFilter>.
Removes a filter by the given identifier.
Removes a filter from the given
<WebKitUserContentManager> given the
identifier of a
<WebKitUserContentFilter> as returned by
user-content-filter:get-identifier.
Passed: a <WebKitUserContentManager>.
Passed: a string.
Filter identifier
Removes a <WebKitUserScript> from the given
<WebKitUserContentManager>.
See also user-content-manager:remove-all-scripts.
Passed: a <WebKitUserContentManager>.
Passed: a <WebKitUserScript>.
Removes a <WebKitUserStyleSheet> from the
given <WebKitUserContentManager>.
See also user-content-manager:remove-all-style-sheets.
Passed: a <WebKitUserContentManager>.
Passed: a <WebKitUserStyleSheet>.
Unregisters a previously registered message handler in script world with
name world-name. If #f is passed as the world-name,
the default world will be used.
Note that this does not disconnect handlers for the
user-content-manager: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 user-content-manager:register-script-message-handler?.
Passed: a <WebKitUserContentManager>.
Passed: a string.
Name of the script message channel
Passed, or left out: a string, or #f.
the name of a WebKitScriptWorld
Connect a handler with (connect object
user-content-manager:script-message-received handler). It is called as
(handler self value).
This signal is emitted when JavaScript in a web view calls
<code>window.webkit.messageHandlers.<name>.postMessage()</code>,
after registering <code><name></code> using
user-content-manager:register-script-message-handler?
Passed: a <WebKitUserContentManager>.
Passed: a <JSCValue>.
the value received from the JavaScript world.
Connect a handler with (connect object
user-content-manager:script-message-with-reply-received handler). It
is called as (handler self value reply) ⇒ %return.
This signal is emitted when JavaScript in a web view calls
<code>window.webkit.messageHandlers.<name>.postMessage()</code>,
after registering <code><name></code> using
user-content-manager:register-script-message-handler-with-reply?
The given reply can be used to send a return value with
script-message-reply:return-value or an error message
with script-message-reply:return-error-message. If
none of them are called, an automatic reply with an undefined value will
be sent.
It is possible to handle the reply asynchronously, by simply calling
object:ref on the reply and
returning #t.
Passed: a <WebKitUserContentManager>.
Passed: a <JSCValue>.
the value received from the JavaScript world.
Passed: a <WebKitScriptMessageReply>.
the <WebKitScriptMessageReply> to send
the reply to the script message.
Returned: a boolean.
#t to stop other handlers from being invoked for the event.
#f to propagate the event further.