{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

'GI.WebKit.Objects.WebPolicyDecision.WebPolicyDecision' objects are given to the application on
signal emissions that deal with policy decisions, such as if a new
window should be opened, or if a given navigation should be
allowed. The application uses it to tell the engine what to do.
-}

module GI.WebKit.Objects.WebPolicyDecision
    ( 

-- * Exported types
    WebPolicyDecision(..)                   ,
    IsWebPolicyDecision                     ,
    toWebPolicyDecision                     ,
    noWebPolicyDecision                     ,


 -- * Methods
-- ** download #method:download#
    WebPolicyDecisionDownloadMethodInfo     ,
    webPolicyDecisionDownload               ,


-- ** ignore #method:ignore#
    WebPolicyDecisionIgnoreMethodInfo       ,
    webPolicyDecisionIgnore                 ,


-- ** use #method:use#
    WebPolicyDecisionUseMethodInfo          ,
    webPolicyDecisionUse                    ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object

newtype WebPolicyDecision = WebPolicyDecision (ManagedPtr WebPolicyDecision)
foreign import ccall "webkit_web_policy_decision_get_type"
    c_webkit_web_policy_decision_get_type :: IO GType

instance GObject WebPolicyDecision where
    gobjectType _ = c_webkit_web_policy_decision_get_type
    

class GObject o => IsWebPolicyDecision o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError WebPolicyDecision a) =>
    IsWebPolicyDecision a
#endif
instance IsWebPolicyDecision WebPolicyDecision
instance GObject.Object.IsObject WebPolicyDecision

toWebPolicyDecision :: IsWebPolicyDecision o => o -> IO WebPolicyDecision
toWebPolicyDecision = unsafeCastTo WebPolicyDecision

noWebPolicyDecision :: Maybe WebPolicyDecision
noWebPolicyDecision = Nothing

type family ResolveWebPolicyDecisionMethod (t :: Symbol) (o :: *) :: * where
    ResolveWebPolicyDecisionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveWebPolicyDecisionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveWebPolicyDecisionMethod "download" o = WebPolicyDecisionDownloadMethodInfo
    ResolveWebPolicyDecisionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveWebPolicyDecisionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveWebPolicyDecisionMethod "ignore" o = WebPolicyDecisionIgnoreMethodInfo
    ResolveWebPolicyDecisionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveWebPolicyDecisionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveWebPolicyDecisionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveWebPolicyDecisionMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveWebPolicyDecisionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveWebPolicyDecisionMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveWebPolicyDecisionMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveWebPolicyDecisionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveWebPolicyDecisionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveWebPolicyDecisionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveWebPolicyDecisionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveWebPolicyDecisionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveWebPolicyDecisionMethod "use" o = WebPolicyDecisionUseMethodInfo
    ResolveWebPolicyDecisionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveWebPolicyDecisionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveWebPolicyDecisionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveWebPolicyDecisionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveWebPolicyDecisionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveWebPolicyDecisionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveWebPolicyDecisionMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveWebPolicyDecisionMethod t WebPolicyDecision, O.MethodInfo info WebPolicyDecision p) => O.IsLabelProxy t (WebPolicyDecision -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveWebPolicyDecisionMethod t WebPolicyDecision, O.MethodInfo info WebPolicyDecision p) => O.IsLabel t (WebPolicyDecision -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

instance O.HasAttributeList WebPolicyDecision
type instance O.AttributeList WebPolicyDecision = WebPolicyDecisionAttributeList
type WebPolicyDecisionAttributeList = ('[ ] :: [(Symbol, *)])

type instance O.SignalList WebPolicyDecision = WebPolicyDecisionSignalList
type WebPolicyDecisionSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method WebPolicyDecision::download
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "decision", argType = TInterface (Name {namespace = "WebKit", name = "WebPolicyDecision"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebPolicyDecision", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_policy_decision_download" webkit_web_policy_decision_download :: 
    Ptr WebPolicyDecision ->                -- decision : TInterface (Name {namespace = "WebKit", name = "WebPolicyDecision"})
    IO ()

{- |
Will send the DOWNLOAD decision to the policy implementer.

@since 1.0.3
-}
webPolicyDecisionDownload ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebPolicyDecision a) =>
    a
    {- ^ /@decision@/: a 'GI.WebKit.Objects.WebPolicyDecision.WebPolicyDecision' -}
    -> m ()
webPolicyDecisionDownload decision = liftIO $ do
    decision' <- unsafeManagedPtrCastPtr decision
    webkit_web_policy_decision_download decision'
    touchManagedPtr decision
    return ()

data WebPolicyDecisionDownloadMethodInfo
instance (signature ~ (m ()), MonadIO m, IsWebPolicyDecision a) => O.MethodInfo WebPolicyDecisionDownloadMethodInfo a signature where
    overloadedMethod _ = webPolicyDecisionDownload

-- method WebPolicyDecision::ignore
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "decision", argType = TInterface (Name {namespace = "WebKit", name = "WebPolicyDecision"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebPolicyDecision", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_policy_decision_ignore" webkit_web_policy_decision_ignore :: 
    Ptr WebPolicyDecision ->                -- decision : TInterface (Name {namespace = "WebKit", name = "WebPolicyDecision"})
    IO ()

{- |
Will send the IGNORE decision to the policy implementer.

@since 1.0.3
-}
webPolicyDecisionIgnore ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebPolicyDecision a) =>
    a
    {- ^ /@decision@/: a 'GI.WebKit.Objects.WebPolicyDecision.WebPolicyDecision' -}
    -> m ()
webPolicyDecisionIgnore decision = liftIO $ do
    decision' <- unsafeManagedPtrCastPtr decision
    webkit_web_policy_decision_ignore decision'
    touchManagedPtr decision
    return ()

data WebPolicyDecisionIgnoreMethodInfo
instance (signature ~ (m ()), MonadIO m, IsWebPolicyDecision a) => O.MethodInfo WebPolicyDecisionIgnoreMethodInfo a signature where
    overloadedMethod _ = webPolicyDecisionIgnore

-- method WebPolicyDecision::use
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "decision", argType = TInterface (Name {namespace = "WebKit", name = "WebPolicyDecision"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebPolicyDecision", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_policy_decision_use" webkit_web_policy_decision_use :: 
    Ptr WebPolicyDecision ->                -- decision : TInterface (Name {namespace = "WebKit", name = "WebPolicyDecision"})
    IO ()

{- |
Will send the USE decision to the policy implementer.

@since 1.0.3
-}
webPolicyDecisionUse ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebPolicyDecision a) =>
    a
    {- ^ /@decision@/: a 'GI.WebKit.Objects.WebPolicyDecision.WebPolicyDecision' -}
    -> m ()
webPolicyDecisionUse decision = liftIO $ do
    decision' <- unsafeManagedPtrCastPtr decision
    webkit_web_policy_decision_use decision'
    touchManagedPtr decision
    return ()

data WebPolicyDecisionUseMethodInfo
instance (signature ~ (m ()), MonadIO m, IsWebPolicyDecision a) => O.MethodInfo WebPolicyDecisionUseMethodInfo a signature where
    overloadedMethod _ = webPolicyDecisionUse