### Signal

# WebKit WebView::decide-policy

#### Declaration

    gboolean
    decide_policy (
      WebKitWebView* self,
      WebKitPolicyDecision* decision,
      WebKitPolicyDecisionType decision_type,
      gpointer user_data
    )

#### Description [src]

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:

    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 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.

Default handler: The default handler is called after the handlers added via `g_signal_connect()`.

#### Parameters

`decision`

  Type: `WebKitPolicyDecision`

  The `WebKitPolicyDecision`.

  The data is owned by the caller of the function.

`decision_type`

  Type: `WebKitPolicyDecisionType`

  A `WebKitPolicyDecisionType` denoting the type of `decision`.

#### Return value

Type: `gboolean`

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.