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 #WebKitNavigationPolicyDecision passed in the
@decision argument is a generic type, but should be casted to a more
specific type when making the decision. For example:
<informalexample><programlisting>
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;
}
</programlisting></informalexample>
It is possible to make policy decision asynchronously, by simply calling g_object_ref()
on the @decision argument and returning %TRUE to block the default signal handler.
If the last reference is removed on a #WebKitPolicyDecision 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 given #WebKitPolicyDecision will have any affect.
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 #WebKitNavigationPolicyDecision passed in the @decision argument is a generic type, but should be casted to a more specific type when making the decision. For example:
<informalexample><programlisting> 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; } </programlisting></informalexample>
It is possible to make policy decision asynchronously, by simply calling g_object_ref() on the @decision argument and returning %TRUE to block the default signal handler. If the last reference is removed on a #WebKitPolicyDecision 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 given #WebKitPolicyDecision will have any affect.