UserContentManager

Using a #WebKitUserContentManager user CSS style sheets can be set to be injected in the web pages loaded by a #WebKitWebView, by webkit_user_content_manager_add_style_sheet().

To use a #WebKitUserContentManager, it must be created using webkit_user_content_manager_new(), and then passed to webkit_web_view_new_with_user_content_manager(). User style sheets can be created with webkit_user_style_sheet_new().

User style sheets can be added and removed at any time, but they will affect the web pages loaded afterwards.

Constructors

this
this(WebKitUserContentManager* webKitUserContentManager, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this()

Creates a new user content manager.

Members

Functions

addFilter
void addFilter(UserContentFilter filter)

Adds a #WebKitUserContentFilter to the given #WebKitUserContentManager. The same #WebKitUserContentFilter can be reused with multiple #WebKitUserContentManager instances.

addOnScriptMessageReceived
gulong addOnScriptMessageReceived(void delegate(JavascriptResult, UserContentManager) dlg, ConnectFlags connectFlags)

This signal is emitted when JavaScript in a web view calls <code>window.webkit.messageHandlers.&lt;name&gt;.postMessage()</code>, after registering <code>&lt;name&gt;</code> using webkit_user_content_manager_register_script_message_handler()

addScript
void addScript(UserScript script)

Adds a #WebKitUserScript to the given #WebKitUserContentManager. The same #WebKitUserScript can be reused with multiple #WebKitUserContentManager instances.

addStyleSheet
void addStyleSheet(UserStyleSheet stylesheet)

Adds a #WebKitUserStyleSheet to the given #WebKitUserContentManager. The same #WebKitUserStyleSheet can be reused with multiple #WebKitUserContentManager instances.

getStruct
void* getStruct()

the main Gtk struct as a void*

getUserContentManagerStruct
WebKitUserContentManager* getUserContentManagerStruct(bool transferOwnership)

Get the main Gtk struct

registerScriptMessageHandler
bool registerScriptMessageHandler(string name)

Registers a new user script message handler. After it is registered, scripts can use window.webkit.messageHandlers.&lt;name&gt;.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:

registerScriptMessageHandlerInWorld
bool registerScriptMessageHandlerInWorld(string name, string worldName)

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

removeAllFilters
void removeAllFilters()

Removes all content filters from the given #WebKitUserContentManager.

removeAllScripts
void removeAllScripts()

Removes all user scripts from the given #WebKitUserContentManager

removeAllStyleSheets
void removeAllStyleSheets()

Removes all user style sheets from the given #WebKitUserContentManager.

removeFilter
void removeFilter(UserContentFilter filter)

Removes a filter from the given #WebKitUserContentManager.

removeFilterById
void removeFilterById(string filterId)

Removes a filter from the given #WebKitUserContentManager given the identifier of a #WebKitUserContentFilter as returned by webkit_user_content_filter_get_identifier().

unregisterScriptMessageHandler
void unregisterScriptMessageHandler(string name)

Unregisters a previously registered message handler.

unregisterScriptMessageHandlerInWorld
void unregisterScriptMessageHandlerInWorld(string name, string worldName)

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

Static functions

getType
GType getType()

Variables

webKitUserContentManager
WebKitUserContentManager* webKitUserContentManager;

the main Gtk struct

Meta