decide_policy


Description:

public virtual signal bool decide_policy (PolicyDecision decision, PolicyDecisionType type)

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.

The NavigationPolicyDecision passed in the decision argument is a generic type, but should be casted to a more specific type when making the decision. For example:

```c 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 use return FALSE; } return TRUE; } ```

It is possible to make policy decision asynchronously, by simply calling @ref on the decision argument and returning true to block the default signal handler. If the last reference is removed on a PolicyDecision and no decision has been made explicitly, use will be the default policy decision. The default signal handler will simply call use. Only the first policy decision chosen for a given PolicyDecision will have any affect.

Parameters:

decision

the PolicyDecision

decision_type

a PolicyDecisionType denoting the type of decision

Returns:

true to stop other handlers from being invoked for the event. false to propagate the event further.




2022 vala-language.org