Skip to content

Commit

Permalink
2009-02-26 Xan Lopez <[email protected]>
Browse files Browse the repository at this point in the history
        Reviewed by Holger Freyther.

        https://bugs.webkit.org/show_bug.cgi?id=16947
        [GTK] Missing HTTP Auth challenge

        Add HTTP authentication dialog with optional GNOME Keyring
        storage.

        * GNUmakefile.am:
        * platform/network/ResourceHandleInternal.h:
        (WebCore::ResourceHandleInternal::ResourceHandleInternal):
        * platform/network/soup/ResourceHandleSoup.cpp:
        (WebCore::currentToplevelCallback):
        (WebCore::ResourceHandle::startHttp):
        (WebCore::ResourceHandle::start):
        * platform/network/soup/webkit-soup-auth-dialog.c: Added.
        (webkit_soup_auth_dialog_class_init):
        (webkit_soup_auth_dialog_init):
        (webkit_soup_auth_dialog_session_feature_init):
        (free_authData):
        (set_password_callback):
        (response_callback):
        (show_auth_dialog):
        (find_password_callback):
        (session_authenticate):
        (attach):
        * platform/network/soup/webkit-soup-auth-dialog.h: Added.

Canonical link: https://commits.webkit.org/33345@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@41270 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
kov committed Feb 26, 2009
1 parent 7c3bcab commit 6034338
Show file tree
Hide file tree
Showing 9 changed files with 510 additions and 3 deletions.
13 changes: 13 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2009-02-26 Xan Lopez <[email protected]>

Reviewed by Holger Freyther.

https://bugs.webkit.org/show_bug.cgi?id=16947
[GTK] Missing HTTP Auth challenge

Add HTTP authentication dialog with optional GNOME Keyring
storage.

* GNUmakefile.am:
* configure.ac:

2009-02-26 Xan Lopez <[email protected]>

Reviewed by Holger Freyther.
Expand Down
4 changes: 3 additions & 1 deletion GNUmakefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ libWebCore_la_CFLAGS = \
$(LIBXSLT_CFLAGS) \
$(COVERAGE_CFLAGS) \
$(HILDON_CFLAGS) \
$(GEOCLUE_CFLAGS)
$(GEOCLUE_CFLAGS) \
$(GNOMEKEYRING_CFLAGS)

libWebCore_la_CPPFLAGS = \
$(global_cppflags) \
Expand Down Expand Up @@ -210,6 +211,7 @@ libWebCore_la_LIBADD = \
$(JPEG_LIBS) \
$(PNG_LIBS) \
$(GEOCLUE_LIBS) \
$(GNOMEKEYRING_LIBS) \
-lpthread

# WebKit
Expand Down
30 changes: 30 additions & 0 deletions WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
2009-02-26 Xan Lopez <[email protected]>

Reviewed by Holger Freyther.

https://bugs.webkit.org/show_bug.cgi?id=16947
[GTK] Missing HTTP Auth challenge

Add HTTP authentication dialog with optional GNOME Keyring
storage.

* GNUmakefile.am:
* platform/network/ResourceHandleInternal.h:
(WebCore::ResourceHandleInternal::ResourceHandleInternal):
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::currentToplevelCallback):
(WebCore::ResourceHandle::startHttp):
(WebCore::ResourceHandle::start):
* platform/network/soup/webkit-soup-auth-dialog.c: Added.
(webkit_soup_auth_dialog_class_init):
(webkit_soup_auth_dialog_init):
(webkit_soup_auth_dialog_session_feature_init):
(free_authData):
(set_password_callback):
(response_callback):
(show_auth_dialog):
(find_password_callback):
(session_authenticate):
(attach):
* platform/network/soup/webkit-soup-auth-dialog.h: Added.

2009-02-25 Ojan Vafai <[email protected]> and Eric Seidel <[email protected]>

Reviewed by Dave Hyatt.
Expand Down
9 changes: 8 additions & 1 deletion WebCore/GNUmakefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,14 @@ webcore_sources += \
WebCore/platform/network/soup/ResourceError.h \
WebCore/platform/network/soup/ResourceHandleSoup.cpp \
WebCore/platform/network/soup/ResourceRequest.h \
WebCore/platform/network/soup/ResourceResponse.h
WebCore/platform/network/soup/ResourceResponse.h \
WebCore/platform/network/soup/webkit-soup-auth-dialog.c \
WebCore/platform/network/soup/webkit-soup-auth-dialog.h

if USE_GNOMEKEYRING
webcore_cppflags += \
-DWTF_USE_GNOMEKEYRING=1
endif

# ---
# Freetype font backend
Expand Down
3 changes: 3 additions & 0 deletions WebCore/platform/network/ResourceHandleInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

#if USE(SOUP)
#include <libsoup/soup.h>
class Frame;
#endif

#if PLATFORM(QT)
Expand Down Expand Up @@ -117,6 +118,7 @@ namespace WebCore {
, m_bufsize(0)
, m_total(0)
, m_idleHandler(0)
, m_frame(0)
#endif
#if PLATFORM(QT)
, m_job(0)
Expand Down Expand Up @@ -187,6 +189,7 @@ namespace WebCore {
char* m_buffer;
gsize m_bufsize, m_total;
guint m_idleHandler;
Frame* m_frame;
#endif
#if PLATFORM(QT)
#if QT_VERSION < 0x040400
Expand Down
40 changes: 39 additions & 1 deletion WebCore/platform/network/soup/ResourceHandleSoup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@

#include "Base64.h"
#include "CookieJarSoup.h"
#include "ChromeClient.h"
#include "CString.h"
#include "DocLoader.h"
#include "Frame.h"
#include "HTTPParsers.h"
#include "MIMETypeRegistry.h"
#include "NotImplemented.h"
#include "Page.h"
#include "ResourceError.h"
#include "ResourceHandleClient.h"
#include "ResourceHandleInternal.h"
#include "ResourceResponse.h"
#include "TextEncoding.h"
#include "webkit-soup-auth-dialog.h"

#include <errno.h>
#include <fcntl.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <libsoup/soup.h>
#include <libsoup/soup-message.h>
#include <sys/types.h>
Expand Down Expand Up @@ -370,6 +374,31 @@ static SoupSession* createSoupSession()
return soup_session_async_new();
}

static GtkWidget* currentToplevelCallback(WebKitSoupAuthDialog* feature, SoupMessage* message, gpointer userData)
{
gpointer messageData = g_object_get_data(G_OBJECT(message), "resourceHandle");
if (!messageData)
return NULL;

ResourceHandle* handle = static_cast<ResourceHandle*>(messageData);
if (!handle)
return NULL;

ResourceHandleInternal* d = handle->getInternal();
if (!d)
return NULL;

Frame* frame = d->m_frame;
if (!frame)
return NULL;

GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(frame->page()->chrome()->platformWindow()));
if (GTK_WIDGET_TOPLEVEL(toplevel))
return toplevel;
else
return NULL;
}

static void ensureSessionIsInitialized(SoupSession* session)
{
if (g_object_get_data(G_OBJECT(session), "webkit-init"))
Expand All @@ -381,6 +410,11 @@ static void ensureSessionIsInitialized(SoupSession* session)
else
setDefaultCookieJar(jar);

SoupSessionFeature* authDialog = static_cast<SoupSessionFeature*>(g_object_new(WEBKIT_TYPE_SOUP_AUTH_DIALOG, NULL));
g_signal_connect(authDialog, "current-toplevel", G_CALLBACK(currentToplevelCallback), NULL);
soup_session_add_feature(session, authDialog);
g_object_unref(authDialog);

const char* webkit_debug = g_getenv("WEBKIT_DEBUG");
if (!soup_session_get_feature(session, SOUP_TYPE_LOGGER)
&& webkit_debug && !strcmp(webkit_debug, "network")) {
Expand All @@ -400,10 +434,11 @@ bool ResourceHandle::startHttp(String urlString)
SoupMessage* msg;
msg = soup_message_new(request().httpMethod().utf8().data(), urlString.utf8().data());
g_signal_connect(msg, "restarted", G_CALLBACK(restartedCallback), this);

g_signal_connect(msg, "got-headers", G_CALLBACK(gotHeadersCallback), this);
g_signal_connect(msg, "got-chunk", G_CALLBACK(gotChunkCallback), this);

g_object_set_data(G_OBJECT(msg), "resourceHandle", reinterpret_cast<void*>(this));

HTTPHeaderMap customHeaders = d->m_request.httpHeaderFields();
if (!customHeaders.isEmpty()) {
HTTPHeaderMap::const_iterator end = customHeaders.end();
Expand Down Expand Up @@ -518,6 +553,9 @@ bool ResourceHandle::start(Frame* frame)
String urlString = url.string();
String protocol = url.protocol();

// Used to set the authentication dialog toplevel; may be NULL
d->m_frame = frame;

if (equalIgnoringCase(protocol, "data"))
return startData(urlString);
else if ((equalIgnoringCase(protocol, "http") || equalIgnoringCase(protocol, "https")) && SOUP_URI_VALID_FOR_HTTP(soup_uri_new(urlString.utf8().data())))
Expand Down
Loading

0 comments on commit 6034338

Please sign in to comment.