diff options
Diffstat (limited to 'src/webenginewidgets/api')
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 17 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.h | 3 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage_p.h | 1 |
3 files changed, 21 insertions, 0 deletions
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(); |