Index: WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp =================================================================== --- WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp (revision 29676) +++ WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp (working copy) @@ -30,15 +30,18 @@ #include "HTMLFrameOwnerElement.h" #include "HTMLNames.h" #include "Language.h" +#include "MainResourceLoader.h" #include "MIMETypeRegistry.h" #include "NotImplemented.h" #include "PlatformString.h" +#include "ResourceHandle.h" #include "ResourceRequest.h" #include "CString.h" #include "ProgressTracker.h" #include "kjs_binding.h" #include "kjs_proxy.h" #include "kjs_window.h" +#include "webkitauthenticationchallenge.h" #include "webkitwebview.h" #include "webkitwebframe.h" #include "webkitprivate.h" @@ -165,9 +168,42 @@ fl->addData(data, length); } -void FrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) +void FrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader* documentLoader, unsigned long identifier, const AuthenticationChallenge& webChallenge) { - notImplemented(); + ResourceHandle* handle = documentLoader->mainResourceLoader()->handle(); + ASSERT(handle); + if (!handle) + return; + + WebKitAuthenticationChallenge* challenge = webkit_authentication_challenge_new(); + Credential credential = webChallenge.proposedCredential(); + webkit_authentication_challenge_set_user(challenge, credential.user().utf8().data()); + webkit_authentication_challenge_set_password(challenge, credential.password().utf8().data()); + + WebKitWebView* webView = getViewFromFrame(m_frame); + WebKitAuthenticationResponse response; + g_signal_emit_by_name(webView, "authentication-requested", m_frame, challenge, &response); + + credential = Credential(webkit_authentication_challenge_get_user(challenge), + webkit_authentication_challenge_get_password(challenge), + CredentialPersistenceForSession); + + g_object_unref(challenge); + + switch (response) { + case WEBKIT_AUTHENTICATION_RESPONSE_ACCEPT: + handle->receivedCredential(webChallenge, credential); + break; + case WEBKIT_AUTHENTICATION_RESPONSE_CONTINUE_WITHOUT_CREDENTIAL: + handle->receivedRequestToContinueWithoutCredential(webChallenge); + break; + case WEBKIT_AUTHENTICATION_RESPONSE_CANCEL: + handle->receivedCancellation(webChallenge); + break; + default: + g_assert_not_reached (); + break; + } } void FrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) Index: WebKit/gtk/WebView/webkitwebview.cpp =================================================================== --- WebKit/gtk/WebView/webkitwebview.cpp (revision 29676) +++ WebKit/gtk/WebView/webkitwebview.cpp (working copy) @@ -77,6 +77,7 @@ COPY_CLIPBOARD, PASTE_CLIPBOARD, CUT_CLIPBOARD, + AUTHENTICATION_REQUESTED, LAST_SIGNAL }; @@ -431,6 +432,63 @@ return WEBKIT_NAVIGATION_RESPONSE_ACCEPT; } +static WebKitAuthenticationResponse webkit_web_view_real_authentication_requested(WebKitWebView* webView, WebKitWebFrame* frame, WebKitAuthenticationChallenge* challenge) +{ + GtkWidget* window; + GtkWidget* dialog; + GtkWidget* user_entry; + GtkWidget* password_entry; + GtkWidget* table; + gboolean didConfirm = FALSE; + + window = gtk_widget_get_toplevel(GTK_WIDGET(webView)); + dialog = gtk_message_dialog_new(GTK_WIDGET_TOPLEVEL(window) ? GTK_WINDOW(window) : 0, GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK_CANCEL, + "Realm"); + gchar* title = g_strconcat("Authentication - ", webkit_web_frame_get_uri(frame), NULL); + gtk_window_set_title(GTK_WINDOW(dialog), title); + g_free(title); + + table = gtk_table_new(2, 2, FALSE); + gtk_table_set_row_spacings(GTK_TABLE(table), 3); + gtk_table_set_col_spacings(GTK_TABLE(table), 3); + + gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Username:"), 0, 1, 0, 1); + user_entry = gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(user_entry), webkit_authentication_challenge_get_user(challenge)); + gtk_entry_set_activates_default(GTK_ENTRY(user_entry), TRUE); + gtk_table_attach_defaults(GTK_TABLE(table), user_entry, 1, 2, 0, 1); + + gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Password:"), 0, 1, 1, 2); + password_entry = gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(password_entry), webkit_authentication_challenge_get_password(challenge)); + gtk_table_attach_defaults(GTK_TABLE(table), password_entry, 1, 2, 1, 2); + + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table); + gtk_widget_show_all(table); + + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); + gint response = gtk_dialog_run(GTK_DIALOG(dialog)); + + switch (response) { + case GTK_RESPONSE_OK: + didConfirm = TRUE; + webkit_authentication_challenge_set_user(challenge, gtk_entry_get_text(GTK_ENTRY(user_entry))); + webkit_authentication_challenge_set_password(challenge, gtk_entry_get_text(GTK_ENTRY(password_entry))); + break; + case GTK_RESPONSE_CANCEL: + didConfirm = FALSE; + break; + + } + gtk_widget_destroy(GTK_WIDGET(dialog)); + + if (didConfirm) + return WEBKIT_AUTHENTICATION_RESPONSE_ACCEPT; + else + return WEBKIT_AUTHENTICATION_RESPONSE_CONTINUE_WITHOUT_CREDENTIAL; +} + static void webkit_web_view_real_window_object_cleared(WebKitWebView*, WebKitWebFrame*, JSGlobalContextRef context, JSObjectRef window_object) { notImplemented(); @@ -910,6 +968,25 @@ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + /** + * WebKitWebView::authentication-requested: + * @web_view: the object which received the signal + * + * The ::authentication-requested signal is a emitted when an authentication is + * requested from the server to access a resource. + * + * The default behavior for this signal is creating an input dialog to get a suitable credential. + */ + webkit_web_view_signals[PASTE_CLIPBOARD] = g_signal_new("authentication-requested", + G_TYPE_FROM_CLASS(webViewClass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + G_STRUCT_OFFSET(WebKitWebViewClass, authentication_requested), + NULL, NULL, + webkit_marshal_INT__OBJECT_OBJECT, + G_TYPE_INT, 2, + WEBKIT_TYPE_WEB_FRAME, + WEBKIT_TYPE_AUTHENTICATION_CHALLENGE); + /* * implementations of virtual methods */ @@ -925,6 +1002,7 @@ webViewClass->cut_clipboard = webkit_web_view_real_cut_clipboard; webViewClass->copy_clipboard = webkit_web_view_real_copy_clipboard; webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard; + webViewClass->authentication_requested = webkit_web_view_real_authentication_requested; GObjectClass* objectClass = G_OBJECT_CLASS(webViewClass); objectClass->finalize = webkit_web_view_finalize; Index: WebKit/gtk/WebView/webkitwebview.h =================================================================== --- WebKit/gtk/WebView/webkitwebview.h (revision 29676) +++ WebKit/gtk/WebView/webkitwebview.h (working copy) @@ -47,6 +47,12 @@ WEBKIT_WEB_VIEW_TARGET_INFO_TEXT = - 2 } WebKitWebViewTargetInfo; +typedef enum { + WEBKIT_AUTHENTICATION_RESPONSE_ACCEPT, + WEBKIT_AUTHENTICATION_RESPONSE_CONTINUE_WITHOUT_CREDENTIAL, + WEBKIT_AUTHENTICATION_RESPONSE_CANCEL +} WebKitAuthenticationResponse; + struct _WebKitWebView { GtkContainer parent; }; @@ -77,6 +83,7 @@ void (*cut_clipboard) (WebKitWebView* web_view); void (*copy_clipboard) (WebKitWebView* web_view); void (*paste_clipboard) (WebKitWebView* web_view); + WebKitAuthenticationResponse (*authentication_requested) (WebKitWebView* web_view, WebKitWebFrame* frame, WebKitAuthenticationChallenge* challenge); /* * internal Index: WebKit/gtk/WebView/webkitprivate.h =================================================================== --- WebKit/gtk/WebView/webkitprivate.h (revision 29676) +++ WebKit/gtk/WebView/webkitprivate.h (working copy) @@ -31,7 +31,9 @@ #include "webkitwebview.h" #include "webkitwebframe.h" #include "webkitnetworkrequest.h" +#include "webkitauthenticationchallenge.h" +#include "AuthenticationChallenge.h" #include "Settings.h" #include "Page.h" #include "Frame.h" @@ -92,6 +94,13 @@ struct _WebKitNetworkRequestPrivate { gchar* uri; }; + + #define WEBKIT_AUTHENTICATION_CHALLENGE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_AUTHENTICATION_CHALLENGE, WebKitAuthenticationChallengePrivate)) + typedef struct _WebKitAuthenticationChallengePrivate WebKitAuthenticationChallengePrivate; + struct _WebKitAuthenticationChallengePrivate { + gchar* user; + gchar* password; + }; WebKitWebFrame* webkit_web_frame_init_with_web_view(WebKitWebView*, WebCore::HTMLFrameOwnerElement*); Index: WebKit/gtk/WebView/webkitauthenticationchallenge.cpp =================================================================== --- WebKit/gtk/WebView/webkitauthenticationchallenge.cpp (revision 0) +++ WebKit/gtk/WebView/webkitauthenticationchallenge.cpp (revision 0) @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2008 Luca Bruno + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" + +#include "webkitauthenticationchallenge.h" +#include "webkitprivate.h" + +using namespace WebKit; +using namespace WebCore; + +extern "C" { + +G_DEFINE_TYPE(WebKitAuthenticationChallenge, webkit_authentication_challenge, G_TYPE_OBJECT); + +static void webkit_authentication_challenge_finalize(GObject* object) +{ + WebKitAuthenticationChallengePrivate* challengePrivate = WEBKIT_AUTHENTICATION_CHALLENGE_GET_PRIVATE(object); + + g_free(challengePrivate->user); + g_free(challengePrivate->password); + + G_OBJECT_CLASS(webkit_authentication_challenge_parent_class)->finalize(object); +} + +static void webkit_authentication_challenge_class_init(WebKitAuthenticationChallengeClass* challengeClass) +{ + g_type_class_add_private(challengeClass, sizeof(WebKitAuthenticationChallengePrivate)); + + G_OBJECT_CLASS(challengeClass)->finalize = webkit_authentication_challenge_finalize; +} + +static void webkit_authentication_challenge_init(WebKitAuthenticationChallenge* challenge) +{ + WebKitAuthenticationChallengePrivate* challengePrivate = WEBKIT_AUTHENTICATION_CHALLENGE_GET_PRIVATE(challenge); + + challengePrivate->user = NULL; + challengePrivate->password = NULL; +} + +WebKitAuthenticationChallenge* webkit_authentication_challenge_new() +{ + WebKitAuthenticationChallenge* challenge = WEBKIT_AUTHENTICATION_CHALLENGE(g_object_new(WEBKIT_TYPE_AUTHENTICATION_CHALLENGE, NULL)); + + return challenge; +} + +void webkit_authentication_challenge_set_user(WebKitAuthenticationChallenge* challenge, const gchar* user) +{ + g_return_if_fail(WEBKIT_IS_AUTHENTICATION_CHALLENGE(challenge)); + g_return_if_fail(user); + + WebKitAuthenticationChallengePrivate* challengePrivate = WEBKIT_AUTHENTICATION_CHALLENGE_GET_PRIVATE(challenge); + + g_free(challengePrivate->user); + challengePrivate->user = g_strdup(user); +} + +const gchar* webkit_authentication_challenge_get_user(WebKitAuthenticationChallenge* challenge) +{ + g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_CHALLENGE(challenge), NULL); + + WebKitAuthenticationChallengePrivate* challengePrivate = WEBKIT_AUTHENTICATION_CHALLENGE_GET_PRIVATE(challenge); + + return challengePrivate->user; +} + +void webkit_authentication_challenge_set_password(WebKitAuthenticationChallenge* challenge, const gchar* password) +{ + g_return_if_fail(WEBKIT_IS_AUTHENTICATION_CHALLENGE(challenge)); + g_return_if_fail(password); + + WebKitAuthenticationChallengePrivate* challengePrivate = WEBKIT_AUTHENTICATION_CHALLENGE_GET_PRIVATE(challenge); + + g_free(challengePrivate->password); + challengePrivate->password = g_strdup(password); +} + +const gchar* webkit_authentication_challenge_get_password(WebKitAuthenticationChallenge* challenge) +{ + g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_CHALLENGE(challenge), NULL); + + WebKitAuthenticationChallengePrivate* challengePrivate = WEBKIT_AUTHENTICATION_CHALLENGE_GET_PRIVATE(challenge); + + return challengePrivate->password; +} + +} Index: WebKit/gtk/WebView/webkitdefines.h =================================================================== --- WebKit/gtk/WebView/webkitdefines.h (revision 29676) +++ WebKit/gtk/WebView/webkitdefines.h (working copy) @@ -49,6 +49,9 @@ typedef struct _WebKitNetworkRequest WebKitNetworkRequest; typedef struct _WebKitNetworkRequestClass WebKitNetworkRequestClass; +typedef struct _WebKitAuthenticationChallenge WebKitAuthenticationChallenge; +typedef struct _WebKitAuthenticationChallengeClass WebKitAuthenticationChallengeClass; + G_END_DECLS #endif Index: WebKit/gtk/WebView/webkitauthenticationchallenge.h =================================================================== --- WebKit/gtk/WebView/webkitauthenticationchallenge.h (revision 0) +++ WebKit/gtk/WebView/webkitauthenticationchallenge.h (revision 0) @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2008 Luca Bruno + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef WEBKIT_AUTHENTICATION_CHALLENGE_H +#define WEBKIT_AUTHENTICATION_CHALLENGE_H + +#include + +#include "webkitdefines.h" + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_AUTHENTICATION_CHALLENGE (webkit_authentication_challenge_get_type()) +#define WEBKIT_AUTHENTICATION_CHALLENGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_AUTHENTICATION_CHALLENGE, WebKitAuthenticationChallenge)) +#define WEBKIT_AUTHENTICATION_CHALLENGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_AUTHENTICATION_CHALLENGE, WebKitAuthenticationChallengeClass)) +#define WEBKIT_IS_AUTHENTICATION_CHALLENGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_AUTHENTICATION_CHALLENGE)) +#define WEBKIT_IS_AUTHENTICATION_CHALLENGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_AUTHENTICATION_CHALLENGE)) +#define WEBKIT_AUTHENTICATION_CHALLENGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_AUTHENTICATION_CHALLENGE, WebKitAuthenticationChallengeClass)) + +struct _WebKitAuthenticationChallenge { + GObject parent; +}; + +struct _WebKitAuthenticationChallengeClass { + GObjectClass parent; +}; + +WEBKIT_API GType +webkit_authentication_challenge_get_type (void); + +WEBKIT_API WebKitAuthenticationChallenge* +webkit_authentication_challenge_new (); + +WEBKIT_API void +webkit_authentication_challenge_set_user (WebKitAuthenticationChallenge* challenge, const gchar* user); + +WEBKIT_API const gchar* +webkit_authentication_challenge_get_user (WebKitAuthenticationChallenge* challenge); + +WEBKIT_API void +webkit_authentication_challenge_set_password (WebKitAuthenticationChallenge* challenge, const gchar* password); + +WEBKIT_API const gchar* +webkit_authentication_challenge_get_password (WebKitAuthenticationChallenge* challenge); + +G_END_DECLS + +#endif Index: WebCore/platform/network/ResourceHandleInternal.h =================================================================== --- WebCore/platform/network/ResourceHandleInternal.h (revision 29676) +++ WebCore/platform/network/ResourceHandleInternal.h (working copy) @@ -101,6 +101,8 @@ , m_file(0) , m_formDataElementIndex(0) , m_formDataElementDataOffset(0) + , m_webChallenge() + , m_continueWithoutCredential(false) #endif #if PLATFORM(QT) , m_job(0) @@ -159,6 +161,9 @@ size_t m_formDataElementIndex; size_t m_formDataElementDataOffset; Vector m_postBytes; + + AuthenticationChallenge m_webChallenge; + bool m_continueWithoutCredential; #endif #if PLATFORM(QT) #if QT_VERSION < 0x040400 Index: WebCore/platform/network/ResourceHandle.h =================================================================== --- WebCore/platform/network/ResourceHandle.h (revision 29676) +++ WebCore/platform/network/ResourceHandle.h (working copy) @@ -97,6 +97,12 @@ ~ResourceHandle(); +#if PLATFORM(GTK) + void didReceiveAuthenticationChallenge(const AuthenticationChallenge&); + void receivedCredential(const AuthenticationChallenge&, const Credential&); + void receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&); + void receivedCancellation(const AuthenticationChallenge&); +#endif #if PLATFORM(MAC) || USE(CFNETWORK) void didReceiveAuthenticationChallenge(const AuthenticationChallenge&); void receivedCredential(const AuthenticationChallenge&, const Credential&); Index: WebCore/platform/network/curl/ResourceHandleManager.cpp =================================================================== --- WebCore/platform/network/curl/ResourceHandleManager.cpp (revision 29676) +++ WebCore/platform/network/curl/ResourceHandleManager.cpp (working copy) @@ -34,6 +34,7 @@ #include "FileSystem.h" #include "MIMETypeRegistry.h" #include "NotImplemented.h" +#include "ResourceLoader.h" #include "ResourceHandle.h" #include "ResourceHandleInternal.h" #include "HTTPParsers.h" @@ -162,6 +163,17 @@ d->m_response.setTextEncodingName(extractCharsetFromMediaType(d->m_response.httpHeaderField("Content-Type"))); d->m_response.setSuggestedFilename(filenameFromHTTPContentDisposition(d->m_response.httpHeaderField("Content-Disposition"))); + // HTTP authentication + if (httpCode == 401 && d->m_response.isHTTP()) { + job->didReceiveAuthenticationChallenge(d->m_webChallenge); + + if (!d->m_continueWithoutCredential) { + job->cancel(); + ResourceHandleManager::sharedInstance()->add(job); + return totalSize; + } + } + // HTTP redirection if (httpCode >= 300 && httpCode < 400) { String location = d->m_response.httpHeaderField("location"); @@ -528,6 +540,8 @@ } d->m_handle = curl_easy_init(); + // HTTP Authentication cancels the job so be sure the new job is not cancelled + d->m_cancelled = false; #ifndef NDEBUG if (getenv("DEBUG_CURL")) curl_easy_setopt(d->m_handle, CURLOPT_VERBOSE, 1); @@ -541,7 +555,6 @@ curl_easy_setopt(d->m_handle, CURLOPT_AUTOREFERER, 1); curl_easy_setopt(d->m_handle, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(d->m_handle, CURLOPT_MAXREDIRS, 10); - curl_easy_setopt(d->m_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_easy_setopt(d->m_handle, CURLOPT_SHARE, m_curlShareHandle); curl_easy_setopt(d->m_handle, CURLOPT_DNS_CACHE_TIMEOUT, 60 * 5); // 5 minutes // enable gzip and deflate through Accept-Encoding: @@ -557,6 +570,23 @@ curl_easy_setopt(d->m_handle, CURLOPT_COOKIEJAR, m_cookieJarFileName); } + if (!d->m_webChallenge.isNull()) { + long curlAuth; + switch(d->m_webChallenge.protectionSpace().authenticationScheme()) { + case ProtectionSpaceAuthenticationSchemeHTTPBasic: + case ProtectionSpaceAuthenticationSchemeDefault: + default: + curlAuth = CURLAUTH_BASIC; + break; + } + + Credential credential = d->m_webChallenge.proposedCredential(); + String userpwd = credential.user() + ":" + credential.password(); + + curl_easy_setopt(d->m_handle, CURLOPT_HTTPAUTH, curlAuth); + curl_easy_setopt(d->m_handle, CURLOPT_USERPWD, strdup(userpwd.utf8().data())); + } + struct curl_slist* headers = 0; if (job->request().httpHeaderFields().size() > 0) { HTTPHeaderMap customHeaders = job->request().httpHeaderFields(); Index: WebCore/platform/network/curl/ResourceHandleCurl.cpp =================================================================== --- WebCore/platform/network/curl/ResourceHandleCurl.cpp (revision 29676) +++ WebCore/platform/network/curl/ResourceHandleCurl.cpp (working copy) @@ -95,4 +95,63 @@ notImplemented(); } +void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge) +{ + /* FIXME: add support for FTP, HTTPS, and FTPS authentication, + * get the right port, server and authentication scheme + */ + ResourceHandleInternal* d = getInternal(); + ProtectionSpace protectionSpace; + unsigned previousFailureCount = 0; + if (challenge.isNull()) { + protectionSpace = ProtectionSpace(d->m_response.httpHeaderField("Host"), + 80, + ProtectionSpaceServerHTTP, + d->m_response.httpHeaderField("Realm"), + ProtectionSpaceAuthenticationSchemeDefault); + } else { + protectionSpace = d->m_webChallenge.protectionSpace(); + previousFailureCount = d->m_webChallenge.previousFailureCount()+1; + } + + d->m_webChallenge = AuthenticationChallenge(protectionSpace, + challenge.proposedCredential(), + previousFailureCount, + d->m_response, + challenge.error()); + + if (d->client()) + d->client()->didReceiveAuthenticationChallenge(this, d->m_webChallenge); +} + +void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential) +{ + ASSERT(!challenge.isNull()); + ResourceHandleInternal* d = getInternal(); + if (challenge != d->m_webChallenge) + return; + + d->m_webChallenge = AuthenticationChallenge(challenge.protectionSpace(), + credential, + challenge.previousFailureCount(), + challenge.failureResponse(), + challenge.error()); +} + +void ResourceHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& challenge) +{ + ASSERT(!challenge.isNull()); + ResourceHandleInternal* d = getInternal(); + if (challenge != d->m_webChallenge) + return; + + d->m_continueWithoutCredential = true; + d->m_webChallenge.nullify(); +} + +void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challenge) +{ + notImplemented(); +} + } // namespace WebCore Index: WebCore/WebCore.pro =================================================================== --- WebCore/WebCore.pro (revision 29676) +++ WebCore/WebCore.pro (working copy) @@ -988,6 +988,7 @@ ../WebKit/gtk/WebView/webkit.h \ ../WebKit/gtk/WebView/webkitdefines.h \ ../WebKit/gtk/WebView/webkitnetworkrequest.h \ + ../WebKit/gtk/WebView/webkitauthenticationchallenge.h \ ../WebKit/gtk/WebView/webkitprivate.h \ ../WebKit/gtk/WebView/webkitsettings.h \ ../WebKit/gtk/WebView/webkitwebframe.h \ @@ -1065,6 +1066,7 @@ platform/image-decoders/ico/ICOImageDecoder.cpp \ platform/image-decoders/xbm/XBMImageDecoder.cpp \ ../WebKit/gtk/WebView/webkitnetworkrequest.cpp \ + ../WebKit/gtk/WebView/webkitauthenticationchallenge.cpp \ ../WebKit/gtk/WebView/webkitprivate.cpp \ ../WebKit/gtk/WebView/webkitsettings.cpp \ ../WebKit/gtk/WebView/webkitwebframe.cpp \