static void save_password_callback(SoupMessage* msg, WebKitAuthData* authData)
{
    /* Anything but 401 and 5xx means the password was accepted */
    if (msg->status_code != 401 && msg->status_code < 500)
        soup_auth_save_password(authData->auth, authData->username, authData->password);

    /* Disconnect the callback. If the authentication succeeded we are
     * done, and if it failed we'll create a new authData and we'll
     * connect to 'got-headers' again in response_callback */
    g_signal_handlers_disconnect_by_func(msg, save_password_callback, authData);

    free_authData(authData);
}
void GtkAuthenticationDialog::savePassword()
{
    ASSERT(!m_username.isNull());
    ASSERT(!m_password.isNull());

    // Anything but 401 and 5xx means the password was accepted.
    if (m_message.get()->status_code != 401 && m_message.get()->status_code < 500)
        soup_auth_save_password(m_auth, m_username.data(), m_password.data());

    // Disconnect the callback. If the authentication succeeded we are done,
    // and if it failed we'll create a new GtkAuthenticationDialog and we'll
    // connect to 'got-headers' again in GtkAuthenticationDialog::authenticate()
    g_signal_handler_disconnect(m_message.get(), m_savePasswordHandler);

    // Dialog has been already destroyed, after saving the password it should be deleted.
    delete this;
}