diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
tree | e367e64a75991c554930278175d403c072de6bb8 /Source/WebKit/gtk/webkit/webkitauthenticationdialog.cpp | |
parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebKit/gtk/webkit/webkitauthenticationdialog.cpp')
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitauthenticationdialog.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Source/WebKit/gtk/webkit/webkitauthenticationdialog.cpp b/Source/WebKit/gtk/webkit/webkitauthenticationdialog.cpp new file mode 100644 index 000000000..e26defa70 --- /dev/null +++ b/Source/WebKit/gtk/webkit/webkitauthenticationdialog.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2013 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "webkitauthenticationdialog.h" + +static void authenticationDialogResponseCallback(GtkWidget* authDialog, gint responseID, WebKitAuthenticationWidget* authWidget) +{ + WebCore::AuthenticationChallenge challenge = webkitAuthenticationWidgetGetChallenge(authWidget); + if (responseID == GTK_RESPONSE_OK) { + WebCore::Credential credential = webkitAuthenticationWidgetCreateCredential(authWidget); + challenge.authenticationClient()->receivedCredential(challenge, credential); + } else + challenge.authenticationClient()->receivedRequestToContinueWithoutCredential(challenge); + + gtk_widget_destroy(authDialog); +} + +GtkWidget* createAuthenticationDialog(GtkWindow* parentWindow, const WebCore::AuthenticationChallenge& challenge, CredentialStorageMode mode) +{ + GtkDialog* dialog = GTK_DIALOG(gtk_dialog_new()); + gtk_dialog_add_buttons(dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + gtk_dialog_set_default_response(dialog, GTK_RESPONSE_OK); + + GtkWidget* contentArea = gtk_dialog_get_content_area(dialog); + gtk_container_set_border_width(GTK_CONTAINER(dialog), 5); + gtk_box_set_spacing(GTK_BOX(contentArea), 2); /* 2 * 5 + 2 = 12 */ + + GtkWidget* authWidget = webkitAuthenticationWidgetNew(challenge, mode); + gtk_box_pack_start(GTK_BOX(contentArea), authWidget, TRUE, TRUE, 0); + gtk_widget_show(authWidget); + + GtkWidget* actionArea = gtk_dialog_get_action_area(dialog); + gtk_container_set_border_width(GTK_CONTAINER(actionArea), 5); + gtk_box_set_spacing(GTK_BOX(actionArea), 6); + + GtkWindow* window = GTK_WINDOW(dialog); + gtk_window_set_resizable(window, FALSE); + gtk_window_set_title(window, ""); + gtk_window_set_icon_name(window, GTK_STOCK_DIALOG_AUTHENTICATION); + gtk_window_set_destroy_with_parent (window, TRUE); + if (parentWindow) + gtk_window_set_transient_for(window, parentWindow); + + g_signal_connect(dialog, "response", G_CALLBACK(authenticationDialogResponseCallback), authWidget); + + return GTK_WIDGET(dialog); +} |