From ad0d549d4cc13433f77c1ac8f0ab379c83d93f28 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 24 Feb 2012 16:36:50 +0100 Subject: Imported WebKit commit bb52bf3c0119e8a128cd93afe5572413a8617de9 (http://svn.webkit.org/repository/webkit/trunk@108790) --- .../WebProcess/qt/QtNetworkAccessManager.cpp | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.cpp') diff --git a/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.cpp b/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.cpp index 28efc0c82..ce46be854 100644 --- a/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.cpp +++ b/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.cpp @@ -33,6 +33,7 @@ #include "WebPageProxyMessages.h" #include "WebProcess.h" #include +#include #include #include @@ -43,6 +44,7 @@ QtNetworkAccessManager::QtNetworkAccessManager(WebProcess* webProcess) , m_webProcess(webProcess) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), SLOT(onAuthenticationRequired(QNetworkReply*, QAuthenticator*))); + connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), SLOT(onProxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); connect(this, SIGNAL(sslErrors(QNetworkReply*, QList)), SLOT(onSslErrors(QNetworkReply*, QList))); } @@ -73,6 +75,31 @@ void QtNetworkAccessManager::registerApplicationScheme(const WebPage* page, cons m_applicationSchemes.insert(page, scheme.toLower()); } +void QtNetworkAccessManager::onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator* authenticator) +{ + // FIXME: Check if there is a better way to get a reference to the page. + WebPage* webPage = m_webProcess->focusedWebPage(); + + if (!webPage) + return; + + String hostname = proxy.hostName(); + uint16_t port = static_cast(proxy.port()); + String prefilledUsername = authenticator->user(); + String username; + String password; + + if (webPage->sendSync( + Messages::WebPageProxy::ProxyAuthenticationRequiredRequest(hostname, port, prefilledUsername), + Messages::WebPageProxy::ProxyAuthenticationRequiredRequest::Reply(username, password))) { + if (!username.isEmpty()) + authenticator->setUser(username); + if (!password.isEmpty()) + authenticator->setPassword(password); + } + +} + void QtNetworkAccessManager::onAuthenticationRequired(QNetworkReply* reply, QAuthenticator* authenticator) { WebPage* webPage = obtainOriginatingWebPage(reply->request()); -- cgit v1.2.1