gi-webkit2-4.0.29: WebKit2 bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.WebKit2.Objects.UserContentManager

Description

Manages user-defined content which affects web pages.

Using a UserContentManager user CSS style sheets can be set to be injected in the web pages loaded by a WebView, by userContentManagerAddStyleSheet.

To use a UserContentManager, it must be created using userContentManagerNew, and then passed to webViewNewWithUserContentManager. User style sheets can be created with userStyleSheetNew.

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

Since: 2.6

Synopsis

Exported types

newtype UserContentManager Source #

Memory-managed wrapper type.

Constructors

UserContentManager (ManagedPtr UserContentManager) 

Instances

Instances details
Eq UserContentManager Source # 
Instance details

Defined in GI.WebKit2.Objects.UserContentManager

GObject UserContentManager Source # 
Instance details

Defined in GI.WebKit2.Objects.UserContentManager

ManagedPtrNewtype UserContentManager Source # 
Instance details

Defined in GI.WebKit2.Objects.UserContentManager

TypedObject UserContentManager Source # 
Instance details

Defined in GI.WebKit2.Objects.UserContentManager

Methods

glibType :: IO GType

HasParentTypes UserContentManager Source # 
Instance details

Defined in GI.WebKit2.Objects.UserContentManager

IsGValue (Maybe UserContentManager) Source #

Convert UserContentManager to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.WebKit2.Objects.UserContentManager

type ParentTypes UserContentManager Source # 
Instance details

Defined in GI.WebKit2.Objects.UserContentManager

type ParentTypes UserContentManager = '[Object]

class (GObject o, IsDescendantOf UserContentManager o) => IsUserContentManager o Source #

Type class for types which can be safely cast to UserContentManager, for instance with toUserContentManager.

Instances

Instances details
(GObject o, IsDescendantOf UserContentManager o) => IsUserContentManager o Source # 
Instance details

Defined in GI.WebKit2.Objects.UserContentManager

toUserContentManager :: (MonadIO m, IsUserContentManager o) => o -> m UserContentManager Source #

Cast to UserContentManager, for types for which this is known to be safe. For general casts, use castTo.

Methods

addFilter

userContentManagerAddFilter Source #

Arguments

:: (HasCallStack, MonadIO m, IsUserContentManager a) 
=> a

manager: A UserContentManager

-> UserContentFilter

filter: A UserContentFilter

-> m () 

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.

Since: 2.24

addScript

userContentManagerAddScript Source #

Arguments

:: (HasCallStack, MonadIO m, IsUserContentManager a) 
=> a

manager: A UserContentManager

-> UserScript

script: A UserScript

-> m () 

Adds a UserScript to the given UserContentManager.

The same UserScript can be reused with multiple UserContentManager instances.

Since: 2.6

addStyleSheet

userContentManagerAddStyleSheet Source #

Arguments

:: (HasCallStack, MonadIO m, IsUserContentManager a) 
=> a

manager: A UserContentManager

-> UserStyleSheet

stylesheet: A UserStyleSheet

-> m () 

Adds a UserStyleSheet to the given UserContentManager.

The same UserStyleSheet can be reused with multiple UserContentManager instances.

Since: 2.6

new

userContentManagerNew Source #

Creates a new user content manager.

Since: 2.6

registerScriptMessageHandler

userContentManagerRegisterScriptMessageHandler Source #

Arguments

:: (HasCallStack, MonadIO m, IsUserContentManager a) 
=> a

manager: A UserContentManager

-> Text

name: Name of the script message channel

-> m Bool

Returns: True if message handler was registered successfully, or False otherwise.

Registers a new user script message handler.

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 UserContentManager::scriptMessageReceived 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:

c code

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.

Since: 2.8

registerScriptMessageHandlerInWorld

userContentManagerRegisterScriptMessageHandlerInWorld Source #

Arguments

:: (HasCallStack, MonadIO m, IsUserContentManager a) 
=> a

manager: A UserContentManager

-> Text

name: Name of the script message channel

-> Text

worldName: the name of a WebKitScriptWorld

-> m Bool

Returns: True if message handler was registered successfully, or False otherwise.

Registers a new user script message handler in script world.

Registers a new user script message handler in script world with name worldName. See userContentManagerRegisterScriptMessageHandler for full description.

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

Since: 2.22

removeAllFilters

userContentManagerRemoveAllFilters Source #

Arguments

:: (HasCallStack, MonadIO m, IsUserContentManager a) 
=> a

manager: A UserContentManager

-> m () 

Removes all content filters from the given UserContentManager.

Since: 2.24

removeAllScripts

userContentManagerRemoveAllScripts Source #

Arguments

:: (HasCallStack, MonadIO m, IsUserContentManager a) 
=> a

manager: A UserContentManager

-> m () 

Removes all user scripts from the given UserContentManager

See also userContentManagerRemoveScript.

Since: 2.6

removeAllStyleSheets

userContentManagerRemoveAllStyleSheets Source #

Arguments

:: (HasCallStack, MonadIO m, IsUserContentManager a) 
=> a

manager: A UserContentManager

-> m () 

Removes all user style sheets from the given UserContentManager.

Since: 2.6

removeFilter

userContentManagerRemoveFilter Source #

Arguments

:: (HasCallStack, MonadIO m, IsUserContentManager a) 
=> a

manager: A UserContentManager

-> UserContentFilter

filter: A UserContentFilter

-> m () 

Removes a filter from the given UserContentManager.

Since 2.24

removeFilterById

userContentManagerRemoveFilterById Source #

Arguments

:: (HasCallStack, MonadIO m, IsUserContentManager a) 
=> a

manager: A UserContentManager

-> Text

filterId: Filter identifier

-> m () 

Removes a filter by the given identifier.

Removes a filter from the given UserContentManager given the identifier of a UserContentFilter as returned by userContentFilterGetIdentifier.

Since: 2.26

removeScript

removeStyleSheet

unregisterScriptMessageHandler

userContentManagerUnregisterScriptMessageHandler Source #

Arguments

:: (HasCallStack, MonadIO m, IsUserContentManager a) 
=> a

manager: A UserContentManager

-> Text

name: Name of the script message channel

-> m () 

Unregisters a previously registered message handler.

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

See also userContentManagerRegisterScriptMessageHandler.

Since: 2.8

unregisterScriptMessageHandlerInWorld

userContentManagerUnregisterScriptMessageHandlerInWorld Source #

Arguments

:: (HasCallStack, MonadIO m, IsUserContentManager a) 
=> a

manager: A UserContentManager

-> Text

name: Name of the script message channel

-> Text

worldName: the name of a WebKitScriptWorld

-> m () 

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

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

See also userContentManagerRegisterScriptMessageHandlerInWorld.

Since: 2.22

Signals

scriptMessageReceived

type UserContentManagerScriptMessageReceivedCallback Source #

Arguments

 = JavascriptResult

jsResult: the JavascriptResult holding the value received from the JavaScript world.

-> IO () 

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

Since: 2.8

afterUserContentManagerScriptMessageReceived :: (IsUserContentManager a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => UserContentManagerScriptMessageReceivedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the scriptMessageReceived signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after userContentManager #scriptMessageReceived callback

This signal admits a optional parameter detail. If it's not Nothing, we will connect to “script-message-received::detail” instead.

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onUserContentManagerScriptMessageReceived :: (IsUserContentManager a, MonadIO m) => a -> Maybe Text -> ((?self :: a) => UserContentManagerScriptMessageReceivedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the scriptMessageReceived signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on userContentManager #scriptMessageReceived callback

This signal admits a optional parameter detail. If it's not Nothing, we will connect to “script-message-received::detail” instead.