summaryrefslogtreecommitdiffstats
path: root/WebKitTools/QtTestBrowser/webpage.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-05-26 10:11:43 +0100
committerSteve Block <steveblock@google.com>2010-05-27 11:14:42 +0100
commite78cbe89e6f337f2f1fe40315be88f742b547151 (patch)
treed778000b84a04f24bbad50c7fa66244365e960e9 /WebKitTools/QtTestBrowser/webpage.cpp
parent7b582e96e4e909ed7dba1e07153d20fbddaec3f7 (diff)
downloadexternal_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.zip
external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.gz
external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.bz2
Merge WebKit at r60074: Initial merge by git
Change-Id: I18a2dc5439e36c928351ea829d8fb4e39b062fc7
Diffstat (limited to 'WebKitTools/QtTestBrowser/webpage.cpp')
-rw-r--r--WebKitTools/QtTestBrowser/webpage.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/WebKitTools/QtTestBrowser/webpage.cpp b/WebKitTools/QtTestBrowser/webpage.cpp
index 624a66f..2a3aae6 100644
--- a/WebKitTools/QtTestBrowser/webpage.cpp
+++ b/WebKitTools/QtTestBrowser/webpage.cpp
@@ -32,8 +32,10 @@
#include "webpage.h"
+#include <QAuthenticator>
#include <QDesktopServices>
#include <QtGui>
+#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkProxy>
@@ -43,6 +45,9 @@ WebPage::WebPage(QObject* parent)
, m_interruptingJavaScriptEnabled(false)
{
applyProxy();
+
+ connect(networkAccessManager(), SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)),
+ this, SLOT(authenticationRequired(QNetworkReply*, QAuthenticator*)));
}
void WebPage::applyProxy()
@@ -118,3 +123,42 @@ bool WebPage::shouldInterruptJavaScript()
return false;
return QWebPage::shouldInterruptJavaScript();
}
+
+void WebPage::authenticationRequired(QNetworkReply* reply, QAuthenticator* authenticator)
+{
+ QDialog* dialog = new QDialog(QApplication::activeWindow());
+ dialog->setWindowTitle("HTTP Authentication");
+
+ QGridLayout* layout = new QGridLayout(dialog);
+ dialog->setLayout(layout);
+
+ QLabel* messageLabel = new QLabel(dialog);
+ messageLabel->setWordWrap(true);
+ QString messageStr = QString("Enter with username and password for: %1");
+ messageLabel->setText(messageStr.arg(reply->url().toString()));
+ layout->addWidget(messageLabel, 0, 1);
+
+ QLabel* userLabel = new QLabel("Username:", dialog);
+ layout->addWidget(userLabel, 1, 0);
+ QLineEdit* userInput = new QLineEdit(dialog);
+ layout->addWidget(userInput, 1, 1);
+
+ QLabel* passLabel = new QLabel("Password:", dialog);
+ layout->addWidget(passLabel, 2, 0);
+ QLineEdit* passInput = new QLineEdit(dialog);
+ passInput->setEchoMode(QLineEdit::Password);
+ layout->addWidget(passInput, 2, 1);
+
+ QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
+ | QDialogButtonBox::Cancel, Qt::Horizontal, dialog);
+ connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
+ connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
+ layout->addWidget(buttonBox, 3, 1);
+
+ if (dialog->exec() == QDialog::Accepted) {
+ authenticator->setUser(userInput->text());
+ authenticator->setPassword(passInput->text());
+ }
+
+ delete dialog;
+}