summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/widgets/browser/networkaccessmanager.cpp54
-rw-r--r--examples/widgets/browser/networkaccessmanager.h2
-rw-r--r--examples/widgets/browser/webview.cpp54
-rw-r--r--examples/widgets/browser/webview.h2
-rw-r--r--src/core/content_browser_client_qt.cpp10
-rw-r--r--src/core/content_browser_client_qt.h3
-rw-r--r--src/core/core_gyp_generator.pro2
-rw-r--r--src/core/resource_dispatcher_host_delegate_qt.cpp128
-rw-r--r--src/core/resource_dispatcher_host_delegate_qt.h81
-rw-r--r--src/core/web_contents_adapter_client.h1
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h1
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp17
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h3
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h1
-rw-r--r--src/webenginewidgets/webenginewidgets.pro4
15 files changed, 304 insertions, 59 deletions
diff --git a/examples/widgets/browser/networkaccessmanager.cpp b/examples/widgets/browser/networkaccessmanager.cpp
index ae5dfe4de..a7127ade6 100644
--- a/examples/widgets/browser/networkaccessmanager.cpp
+++ b/examples/widgets/browser/networkaccessmanager.cpp
@@ -43,8 +43,6 @@
#include "browserapplication.h"
#include "browsermainwindow.h"
-#include "ui_passworddialog.h"
-#include "ui_proxy.h"
#include <QtCore/QSettings>
@@ -66,10 +64,6 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent)
requestFinishedCount(0), requestFinishedFromCacheCount(0), requestFinishedPipelinedCount(0),
requestFinishedSecureCount(0), requestFinishedDownloadBufferCount(0)
{
- connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
- SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
- connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
- SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
connect(this, SIGNAL(finished(QNetworkReply*)),
SLOT(requestFinished(QNetworkReply*)));
#ifndef QT_NO_OPENSSL
@@ -140,54 +134,6 @@ void NetworkAccessManager::loadSettings()
setProxy(proxy);
}
-void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth)
-{
- BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();
-
- QDialog dialog(mainWindow);
- dialog.setWindowFlags(Qt::Sheet);
-
- Ui::PasswordDialog passwordDialog;
- passwordDialog.setupUi(&dialog);
-
- passwordDialog.iconLabel->setText(QString());
- passwordDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32));
-
- QString introMessage = tr("<qt>Enter username and password for \"%1\" at %2</qt>");
- introMessage = introMessage.arg(reply->url().toString().toHtmlEscaped()).arg(reply->url().toString().toHtmlEscaped());
- passwordDialog.introLabel->setText(introMessage);
- passwordDialog.introLabel->setWordWrap(true);
-
- if (dialog.exec() == QDialog::Accepted) {
- auth->setUser(passwordDialog.userNameLineEdit->text());
- auth->setPassword(passwordDialog.passwordLineEdit->text());
- }
-}
-
-void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth)
-{
- BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();
-
- QDialog dialog(mainWindow);
- dialog.setWindowFlags(Qt::Sheet);
-
- Ui::ProxyDialog proxyDialog;
- proxyDialog.setupUi(&dialog);
-
- proxyDialog.iconLabel->setText(QString());
- proxyDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32));
-
- QString introMessage = tr("<qt>Connect to proxy \"%1\" using:</qt>");
- introMessage = introMessage.arg(proxy.hostName().toHtmlEscaped());
- proxyDialog.introLabel->setText(introMessage);
- proxyDialog.introLabel->setWordWrap(true);
-
- if (dialog.exec() == QDialog::Accepted) {
- auth->setUser(proxyDialog.userNameLineEdit->text());
- auth->setPassword(proxyDialog.passwordLineEdit->text());
- }
-}
-
#ifndef QT_NO_OPENSSL
void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList<QSslError> &error)
{
diff --git a/examples/widgets/browser/networkaccessmanager.h b/examples/widgets/browser/networkaccessmanager.h
index 8a7aaf808..54c24f86e 100644
--- a/examples/widgets/browser/networkaccessmanager.h
+++ b/examples/widgets/browser/networkaccessmanager.h
@@ -67,8 +67,6 @@ public slots:
void requestFinished(QNetworkReply *reply);
private slots:
- void authenticationRequired(QNetworkReply *reply, QAuthenticator *auth);
- void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth);
#ifndef QT_NO_OPENSSL
void sslErrors(QNetworkReply *reply, const QList<QSslError> &error);
#endif
diff --git a/examples/widgets/browser/webview.cpp b/examples/widgets/browser/webview.cpp
index 7eb08d6a3..193cb4797 100644
--- a/examples/widgets/browser/webview.cpp
+++ b/examples/widgets/browser/webview.cpp
@@ -44,10 +44,13 @@
#include "cookiejar.h"
#include "downloadmanager.h"
#include "networkaccessmanager.h"
+#include "ui_passworddialog.h"
+#include "ui_proxy.h"
#include "tabwidget.h"
#include "webview.h"
#include <QtGui/QClipboard>
+#include <QtNetwork/QAuthenticator>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMessageBox>
#include <QtGui/QMouseEvent>
@@ -72,6 +75,10 @@ WebPage::WebPage(QObject *parent)
#endif
connect(this, SIGNAL(unsupportedContent(QNetworkReply*)),
this, SLOT(handleUnsupportedContent(QNetworkReply*)));
+ connect(this, SIGNAL(authenticationRequired(const QUrl &, QAuthenticator*)),
+ SLOT(authenticationRequired(const QUrl &, QAuthenticator*)));
+ connect(this, SIGNAL(proxyAuthenticationRequired(const QUrl &, QAuthenticator *, const QString &)),
+ SLOT(proxyAuthenticationRequired(const QUrl &, QAuthenticator *, const QString &)));
}
BrowserMainWindow *WebPage::mainWindow()
@@ -249,6 +256,53 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
#endif
}
+void WebPage::authenticationRequired(const QUrl &requestUrl, QAuthenticator *auth)
+{
+ BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();
+
+ QDialog dialog(mainWindow);
+ dialog.setWindowFlags(Qt::Sheet);
+
+ Ui::PasswordDialog passwordDialog;
+ passwordDialog.setupUi(&dialog);
+
+ passwordDialog.iconLabel->setText(QString());
+ passwordDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32));
+
+ QString introMessage = tr("<qt>Enter username and password for \"%1\" at %2</qt>");
+ introMessage = introMessage.arg(auth->realm()).arg(requestUrl.toString().toHtmlEscaped());
+ passwordDialog.introLabel->setText(introMessage);
+ passwordDialog.introLabel->setWordWrap(true);
+
+ if (dialog.exec() == QDialog::Accepted) {
+ auth->setUser(passwordDialog.userNameLineEdit->text());
+ auth->setPassword(passwordDialog.passwordLineEdit->text());
+ }
+}
+
+void WebPage::proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *auth, const QString &proxyHost)
+{
+ BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();
+
+ QDialog dialog(mainWindow);
+ dialog.setWindowFlags(Qt::Sheet);
+
+ Ui::ProxyDialog proxyDialog;
+ proxyDialog.setupUi(&dialog);
+
+ proxyDialog.iconLabel->setText(QString());
+ proxyDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32));
+
+ QString introMessage = tr("<qt>Connect to proxy \"%1\" using:</qt>");
+ introMessage = introMessage.arg(proxyHost.toHtmlEscaped());
+ proxyDialog.introLabel->setText(introMessage);
+ proxyDialog.introLabel->setWordWrap(true);
+
+ if (dialog.exec() == QDialog::Accepted) {
+ auth->setUser(proxyDialog.userNameLineEdit->text());
+ auth->setPassword(proxyDialog.passwordLineEdit->text());
+ }
+}
WebView::WebView(QWidget* parent)
: QWebEngineView(parent)
diff --git a/examples/widgets/browser/webview.h b/examples/widgets/browser/webview.h
index 0dce3e029..2d3ec50cc 100644
--- a/examples/widgets/browser/webview.h
+++ b/examples/widgets/browser/webview.h
@@ -72,6 +72,8 @@ protected:
private slots:
void handleUnsupportedContent(QNetworkReply *reply);
+ void authenticationRequired(const QUrl &requestUrl, QAuthenticator *auth);
+ void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *auth, const QString &proxyHost);
private:
friend class WebView;
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 7e06aed65..99862235f 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -44,8 +44,9 @@
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/browser_main_parts.h"
-#include "content/public/common/main_function_params.h"
#include "content/public/browser/child_process_security_policy.h"
+#include "content/public/browser/resource_dispatcher_host.h"
+#include "content/public/common/main_function_params.h"
#include "content/public/common/url_constants.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
@@ -53,6 +54,7 @@
#include "browser_context_qt.h"
#include "dev_tools_http_handler_delegate_qt.h"
+#include "resource_dispatcher_host_delegate_qt.h"
#include "web_contents_view_qt.h"
#include <QGuiApplication>
@@ -288,6 +290,12 @@ void ContentBrowserClientQt::RenderProcessHostCreated(content::RenderProcessHost
content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(host->GetID(), chrome::kFileScheme);
}
+void ContentBrowserClientQt::ResourceDispatcherHostCreated()
+{
+ m_resourceDispatcherHostDelegate.reset(new ResourceDispatcherHostDelegateQt);
+ content::ResourceDispatcherHost::Get()->SetDelegate(m_resourceDispatcherHostDelegate.get());
+}
+
gfx::GLShareGroup *ContentBrowserClientQt::GetInProcessGpuShareGroup()
{
if (!m_shareGroupQtQuick)
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index b97eaa5e1..c8afc633a 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -68,6 +68,7 @@ class GLShareGroup;
class BrowserContextQt;
class BrowserMainPartsQt;
class DevToolsHttpHandlerDelegateQt;
+class ResourceDispatcherHostDelegateQt;
class ShareGroupQtQuick;
class ContentBrowserClientQt : public content::ContentBrowserClient {
@@ -79,6 +80,7 @@ public:
virtual content::WebContentsViewPort* OverrideCreateWebContentsView(content::WebContents* , content::RenderViewHostDelegateView**) Q_DECL_OVERRIDE;
virtual content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) Q_DECL_OVERRIDE;
virtual void RenderProcessHostCreated(content::RenderProcessHost* host) Q_DECL_OVERRIDE;
+ virtual void ResourceDispatcherHostCreated() Q_DECL_OVERRIDE;
virtual gfx::GLShareGroup* GetInProcessGpuShareGroup() Q_DECL_OVERRIDE;
BrowserContextQt* browser_context();
@@ -90,6 +92,7 @@ public:
private:
BrowserMainPartsQt* m_browserMainParts;
scoped_ptr<DevToolsHttpHandlerDelegateQt> m_devtools;
+ scoped_ptr<ResourceDispatcherHostDelegateQt> m_resourceDispatcherHostDelegate;
scoped_refptr<ShareGroupQtQuick> m_shareGroupQtQuick;
};
diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro
index bf7cce9fe..7b0e36e0e 100644
--- a/src/core/core_gyp_generator.pro
+++ b/src/core/core_gyp_generator.pro
@@ -52,6 +52,7 @@ SOURCES = \
renderer/qt_render_view_observer.cpp \
resource_bundle_qt.cpp \
resource_context_qt.cpp \
+ resource_dispatcher_host_delegate_qt.cpp \
stream_video_node.cpp \
url_request_context_getter_qt.cpp \
web_contents_adapter.cpp \
@@ -87,6 +88,7 @@ HEADERS = \
renderer/content_renderer_client_qt.h \
renderer/qt_render_view_observer.h \
resource_context_qt.h \
+ resource_dispatcher_host_delegate_qt.h \
stream_video_node.h \
url_request_context_getter_qt.h \
web_contents_adapter.h \
diff --git a/src/core/resource_dispatcher_host_delegate_qt.cpp b/src/core/resource_dispatcher_host_delegate_qt.cpp
new file mode 100644
index 000000000..3e650afb7
--- /dev/null
+++ b/src/core/resource_dispatcher_host_delegate_qt.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "resource_dispatcher_host_delegate_qt.h"
+
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/resource_dispatcher_host.h"
+#include "content/public/browser/resource_request_info.h"
+#include "net/url_request/url_request.h"
+
+#include "type_conversion.h"
+#include "web_contents_view_qt.h"
+
+ResourceDispatcherHostLoginDelegateQt::ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request)
+ : m_request(request)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ content::ResourceRequestInfo::ForRequest(request)->GetAssociatedRenderView(&m_renderProcessId, &m_renderViewId);
+
+ m_url = toQt(request->url());
+ m_realm = QString::fromStdString(authInfo->realm);
+ m_isProxy = authInfo->is_proxy;
+ m_host = QString::fromStdString(authInfo->challenger.ToString());
+
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&ResourceDispatcherHostLoginDelegateQt::triggerDialog, this));
+}
+
+ResourceDispatcherHostLoginDelegateQt::~ResourceDispatcherHostLoginDelegateQt()
+{
+ // We must have called ClearLoginDelegateForRequest if we didn't receive an OnRequestCancelled.
+ Q_ASSERT(!m_request);
+}
+
+void ResourceDispatcherHostLoginDelegateQt::OnRequestCancelled()
+{
+ m_request = 0;
+}
+
+void ResourceDispatcherHostLoginDelegateQt::triggerDialog()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ content::RenderViewHost* renderViewHost = content::RenderViewHost::FromID(m_renderProcessId, m_renderViewId);
+ content::WebContents *webContents = content::WebContents::FromRenderViewHost(renderViewHost);
+ WebContentsAdapterClient *client = WebContentsViewQt::from(webContents->GetView())->client();
+
+ // The widgets API will ask for credentials synchronouly, keep it simple for now.
+ // We'll have to figure out a mechanism to keep a ref to the ResourceDispatcherHostLoginDelegateQt
+ // to avoid crashing in the OnRequestCancelled case if we want to allow the credentials to
+ // come back asynchronously in the QtQuick API.
+ QString user, password;
+ client->authenticationRequired(m_url , m_realm , m_isProxy , m_host, &user, &password);
+
+ bool success = !user.isEmpty() || !password.isEmpty();
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester, this, success, user, password));
+}
+
+void ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester(bool success, const QString &user, const QString &password)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ if (!m_request)
+ return;
+
+ if (success)
+ m_request->SetAuth(net::AuthCredentials(toString16(user), toString16(password)));
+ else
+ m_request->CancelAuth();
+ content::ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(m_request);
+
+ m_request = 0;
+}
+
+bool ResourceDispatcherHostDelegateQt::AcceptAuthRequest(net::URLRequest *, net::AuthChallengeInfo *)
+{
+ return true;
+}
+
+content::ResourceDispatcherHostLoginDelegate *ResourceDispatcherHostDelegateQt::CreateLoginDelegate(net::AuthChallengeInfo *authInfo, net::URLRequest *request)
+{
+ // ResourceDispatcherHostLoginDelegateQt is ref-counted and will be released after we called ClearLoginDelegateForRequest.
+ return new ResourceDispatcherHostLoginDelegateQt(authInfo, request);
+}
diff --git a/src/core/resource_dispatcher_host_delegate_qt.h b/src/core/resource_dispatcher_host_delegate_qt.h
new file mode 100644
index 000000000..1b584912e
--- /dev/null
+++ b/src/core/resource_dispatcher_host_delegate_qt.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RESOURCE_DISPATCHER_HOST_DELEGATE_QT_H
+#define RESOURCE_DISPATCHER_HOST_DELEGATE_QT_H
+
+#include "content/public/browser/resource_dispatcher_host_delegate.h"
+#include "content/public/browser/resource_dispatcher_host_login_delegate.h"
+
+#include "web_contents_adapter_client.h"
+
+class ResourceDispatcherHostLoginDelegateQt : public content::ResourceDispatcherHostLoginDelegate {
+public:
+ ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request);
+ ~ResourceDispatcherHostLoginDelegateQt();
+
+ // ResourceDispatcherHostLoginDelegate implementation
+ virtual void OnRequestCancelled();
+
+private:
+ void triggerDialog();
+ void sendAuthToRequester(bool success, const QString &user, const QString &password);
+
+ QUrl m_url;
+ QString m_realm;
+ bool m_isProxy;
+ QString m_host;
+
+ int m_renderProcessId;
+ int m_renderViewId;
+
+ // The request that wants login data.
+ // Must only be accessed on the IO thread.
+ net::URLRequest *m_request;
+};
+
+class ResourceDispatcherHostDelegateQt : public content::ResourceDispatcherHostDelegate {
+public:
+ virtual bool AcceptAuthRequest(net::URLRequest *request, net::AuthChallengeInfo *authInfo) Q_DECL_OVERRIDE;
+ virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(net::AuthChallengeInfo *authInfo, net::URLRequest *request) Q_DECL_OVERRIDE;
+};
+
+#endif // RESOURCE_DISPATCHER_HOST_DELEGATE_QT_H
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index f56e31a71..e436fd61d 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -139,6 +139,7 @@ public:
virtual void didFindText(quint64 requestId, int matchCount) = 0;
virtual void passOnFocus(bool reverse) = 0;
virtual void javaScriptConsoleMessage(int level, const QString& message, int lineNumber, const QString& sourceID) = 0;
+ virtual void authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) = 0;
};
#endif // WEB_CONTENTS_ADAPTER_CLIENT_H
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 5c75f7780..7fed546d4 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -145,6 +145,7 @@ public:
virtual void didFindText(quint64, int) Q_DECL_OVERRIDE { }
virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE;
virtual void javaScriptConsoleMessage(int level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE;
+ virtual void authenticationRequired(const QUrl&, const QString&, bool, const QString&, QString*, QString*) Q_DECL_OVERRIDE { }
void setDevicePixelRatio(qreal);
void adoptWebContents(WebContentsAdapter *webContents);
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 83f77b4bd..4c4243ccc 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -42,6 +42,7 @@
#include <QMessageBox>
#include <QStandardPaths>
#include <QUrl>
+#include <private/qauthenticator_p.h>
QT_BEGIN_NAMESPACE
@@ -284,6 +285,22 @@ void QWebEnginePagePrivate::didFindText(quint64 requestId, int matchCount)
m_callbacks.invoke(requestId, matchCount > 0);
}
+void QWebEnginePagePrivate::authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword)
+{
+ Q_Q(QWebEnginePage);
+ QAuthenticator networkAuth;
+ // Detach to trigger the creation of its QAuthenticatorPrivate.
+ networkAuth.detach();
+ QAuthenticatorPrivate::getPrivate(networkAuth)->realm = realm;
+
+ if (isProxy)
+ Q_EMIT q->proxyAuthenticationRequired(requestUrl, &networkAuth, challengingHost);
+ else
+ Q_EMIT q->authenticationRequired(requestUrl, &networkAuth);
+ *outUser = networkAuth.user();
+ *outPassword = networkAuth.password();
+}
+
void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
{
#ifdef QT_NO_ACTION
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 96ffeda3a..04db99750 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -542,6 +542,9 @@ Q_SIGNALS:
void featurePermissionRequested(QWebEngineFrame* frame, QWebEnginePage::Feature feature);
void featurePermissionRequestCanceled(QWebEngineFrame* frame, QWebEnginePage::Feature feature);
+ void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator);
+ void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost);
+
// Ex-QWebFrame signals
void javaScriptWindowObjectCleared();
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 773df00d4..42f66cd01 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -134,6 +134,7 @@ public:
virtual void didFindText(quint64 requestId, int matchCount) Q_DECL_OVERRIDE;
virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE { Q_UNUSED(reverse); };
virtual void javaScriptConsoleMessage(int level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE;
+ virtual void authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) Q_DECL_OVERRIDE;
void updateAction(QWebEnginePage::WebAction) const;
void updateNavigationActions();
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index 86367d771..a871586ae 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -3,8 +3,8 @@ TARGET = QtWebEngineWidgets
# For our export macros
DEFINES += QT_BUILD_WEBENGINEWIDGETS_LIB
-QT += widgets
-QT_PRIVATE += widgets-private gui-private core-private
+QT += widgets network
+QT_PRIVATE += widgets-private gui-private network-private core-private
# FIXME: all this should eventually be turned into QT += webenginecore
macx:LIBPATH = $$getOutDir()/$$getConfigDir()