Package org.gnome.webkit
Interface WebView.DecidePolicyCallback
- All Superinterfaces:
FunctionPointer
- Enclosing class:
WebView
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface declaration of the
DecidePolicyCallback
callback.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
run
(PolicyDecision decision, PolicyDecisionType decisionType) This signal is emitted when WebKit is requesting the client to decide a policy decision, such as whether to navigate to a page, open a new window or whether or not to download a resource.default MemorySegment
toCallback
(Arena arena) Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, int)
method.default int
upcall
(MemorySegment sourceWebView, MemorySegment decision, int decisionType) Theupcall
method is called from native code.
-
Method Details
-
run
This signal is emitted when WebKit is requesting the client to decide a policy decision, such as whether to navigate to a page, open a new window or whether or not to download a resource. TheWebKitNavigationPolicyDecision
passed in thedecision
argument is a generic type, but should be casted to a more specific type when making the decision. For example:static gboolean decide_policy_cb (WebKitWebView *web_view, WebKitPolicyDecision *decision, WebKitPolicyDecisionType type) { switch (type) { case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: { WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision); // Make a policy decision here break; } case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: { WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision); // Make a policy decision here break; } case WEBKIT_POLICY_DECISION_TYPE_RESPONSE: WebKitResponsePolicyDecision *response = WEBKIT_RESPONSE_POLICY_DECISION (decision); // Make a policy decision here break; default: // Making no decision results in webkit_policy_decision_use() return FALSE; } return TRUE; }
It is possible to make policy decision asynchronously, by simply calling g_object_ref() on the
decision
argument and returningtrue
to block the default signal handler. If the last reference is removed on aWebKitPolicyDecision
and no decision has been made explicitly, webkit_policy_decision_use() will be the default policy decision. The default signal handler will simply call webkit_policy_decision_use(). Only the first policy decision chosen for a givenWebKitPolicyDecision
will have any affect. -
upcall
Theupcall
method is called from native code. The parameters are marshaled andrun(org.gnome.webkit.PolicyDecision, org.gnome.webkit.PolicyDecisionType)
is executed. -
toCallback
Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, int)
method.- Specified by:
toCallback
in interfaceFunctionPointer
- Parameters:
arena
- the function pointer will be allocated in this arena- Returns:
- the native function pointer
-