Method
WPEWebKitUserContentManagerregister_script_message_handler
Declaration [src]
gboolean
webkit_user_content_manager_register_script_message_handler (
WebKitUserContentManager* manager,
const char* name,
const char* world_name
)
Description [src]
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 WebKitUserContentManager::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");
Registering a script message handler will fail if the requested name has been already registered before.
If NULL
is passed as the world_name
, the default world will be used.
The registered handler can be unregistered by using webkit_user_content_manager_unregister_script_message_handler().
Available since: | 2.40 |
Parameters
name |
const char* |
Name of the script message channel. |
|
The data is owned by the caller of the function. | |
The value is a NUL terminated UTF-8 string. | |
world_name |
const char* |
The name of a |
|
The argument can be NULL . | |
The data is owned by the caller of the function. | |
The value is a NUL terminated UTF-8 string. |