summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r--src/webenginewidgets/api/qwebengineclientcertselection.cpp123
-rw-r--r--src/webenginewidgets/api/qwebengineclientcertselection.h80
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp31
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h7
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h1
-rw-r--r--src/webenginewidgets/webenginewidgets.pro2
6 files changed, 243 insertions, 1 deletions
diff --git a/src/webenginewidgets/api/qwebengineclientcertselection.cpp b/src/webenginewidgets/api/qwebengineclientcertselection.cpp
new file mode 100644
index 000000000..de1e101f6
--- /dev/null
+++ b/src/webenginewidgets/api/qwebengineclientcertselection.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebengineclientcertselection.h"
+
+#if QT_CONFIG(ssl)
+
+#include "client_cert_select_controller.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QWebEngineClientCertSelection
+ \brief The QWebEngineClientCertSelection class wraps a client certificate selection.
+ \since 5.12
+ \inmodule QtWebEngineWidgets
+
+ Provides access to the certicates to choose from, and a method for selecting one.
+
+ The selection is asynchronous. If no certificate is selected and no copy of the
+ object is kept alive, loading will continue without a certificate.
+*/
+
+/*! \internal
+*/
+QWebEngineClientCertSelection::QWebEngineClientCertSelection(QSharedPointer<ClientCertSelectController> selectController)
+ : d_ptr(selectController)
+{}
+
+QWebEngineClientCertSelection::QWebEngineClientCertSelection(const QWebEngineClientCertSelection &other)
+ : d_ptr(other.d_ptr)
+{}
+
+QWebEngineClientCertSelection &QWebEngineClientCertSelection::operator=(const QWebEngineClientCertSelection &other)
+{
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+QWebEngineClientCertSelection::~QWebEngineClientCertSelection()
+{
+}
+
+/*!
+ Returns the client certificates available to choose from.
+
+ \sa select()
+*/
+QVector<QSslCertificate> QWebEngineClientCertSelection::certificates() const
+{
+ return d_ptr->certificates();
+}
+
+/*!
+ Selects the client certificate \a certificate. The certificate must be one
+ of those offered in certificates().
+
+ \sa certificates(), selectNone()
+*/
+void QWebEngineClientCertSelection::select(const QSslCertificate &certificate)
+{
+ d_ptr->select(certificate);
+}
+
+/*!
+ Continue without using any of the offered certificates. This is the same
+ action as taken when destroying the last copy of this object if no
+ selection has been made.
+
+ \sa select()
+*/
+void QWebEngineClientCertSelection::selectNone()
+{
+ d_ptr->selectNone();
+}
+
+/*!
+ Returns the host and port of the server requesting the client certificate.
+*/
+QUrl QWebEngineClientCertSelection::host() const
+{
+ return d_ptr->hostAndPort();
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_CONFIG(ssl)
diff --git a/src/webenginewidgets/api/qwebengineclientcertselection.h b/src/webenginewidgets/api/qwebengineclientcertselection.h
new file mode 100644
index 000000000..84de56a67
--- /dev/null
+++ b/src/webenginewidgets/api/qwebengineclientcertselection.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINECLIENTCERTSELECTION_H
+#define QWEBENGINECLIENTCERTSELECTION_H
+
+#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
+#include <QtNetwork/qtnetwork-config.h>
+
+#if QT_CONFIG(ssl)
+
+#include <QtCore/QScopedPointer>
+#include <QtCore/QVector>
+#include <QtNetwork/QSslCertificate>
+
+QT_BEGIN_NAMESPACE
+class ClientCertSelectController;
+
+class QWEBENGINEWIDGETS_EXPORT QWebEngineClientCertSelection {
+public:
+ QWebEngineClientCertSelection(const QWebEngineClientCertSelection &);
+ ~QWebEngineClientCertSelection();
+
+ QWebEngineClientCertSelection &operator=(const QWebEngineClientCertSelection &);
+
+ QUrl host() const;
+
+ void select(const QSslCertificate &certificate);
+ void selectNone();
+ QVector<QSslCertificate> certificates() const;
+
+private:
+ friend class QWebEnginePagePrivate;
+
+ QWebEngineClientCertSelection(QSharedPointer<ClientCertSelectController>);
+
+ QSharedPointer<ClientCertSelectController> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_CONFIG(ssl)
+
+#endif // QWEBENGINECLIENTCERTSELECTION_H
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 2bb19361a..885ad7a69 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -50,6 +50,7 @@
#if QT_CONFIG(webengine_printing_and_pdf)
#include "printing/pdfium_document_wrapper_qt.h"
#endif
+#include "qwebenginecertificateerror.h"
#include "qwebenginefullscreenrequest.h"
#include "qwebenginehistory.h"
#include "qwebenginehistory_p.h"
@@ -1632,6 +1633,36 @@ void QWebEnginePagePrivate::allowCertificateError(const QSharedPointer<Certifica
controller->accept(accepted);
}
+void QWebEnginePagePrivate::selectClientCert(const QSharedPointer<ClientCertSelectController> &controller)
+{
+#if QT_CONFIG(ssl)
+ Q_Q(QWebEnginePage);
+ QWebEngineClientCertSelection certSelection(controller);
+
+ Q_EMIT q->selectClientCertificate(certSelection);
+#else
+ Q_UNUSED(controller);
+#endif
+}
+
+#if QT_CONFIG(ssl)
+/*!
+ \fn void QWebEnginePage::selectClientCertificate(QWebEngineClientCertSelection clientCertSelection)
+ \since 5.12
+
+ This signal is emitted when a web site requests an SSL client certificate, and one or more were
+ found in system's client certificate store.
+
+ Handling the signal is asynchronous, and loading will be waiting until a certificate is selected,
+ or the last copy of \a clientCertSelection is destroyed.
+
+ If the signal is not handled, \a clientCertSelection is automatically destroyed, and loading
+ will continue without a client certificate.
+
+ \sa QWebEngineClientCertSelection
+*/
+#endif
+
void QWebEnginePagePrivate::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)
{
Q_Q(QWebEnginePage);
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 3edfb96d0..6de31d9d5 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -41,7 +41,7 @@
#define QWEBENGINEPAGE_H
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtWebEngineWidgets/qwebenginecertificateerror.h>
+#include <QtWebEngineWidgets/qwebengineclientcertselection.h>
#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
#include <QtWebEngineCore/qwebenginecallback.h>
#include <QtWebEngineCore/qwebenginehttprequest.h>
@@ -59,6 +59,8 @@ class QPrinter;
class QContextMenuBuilder;
class QWebChannel;
+class QWebEngineCertificateError;
+class QWebEngineClientCertSelection;
class QWebEngineContextMenuData;
class QWebEngineFullScreenRequest;
class QWebEngineHistory;
@@ -318,6 +320,9 @@ Q_SIGNALS:
void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest);
void quotaRequested(QWebEngineQuotaRequest quotaRequest);
void registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request);
+#if QT_CONFIG(ssl)
+ void selectClientCertificate(QWebEngineClientCertSelection clientCertSelection);
+#endif
void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator);
void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost);
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 831879127..e5657c1b6 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -136,6 +136,7 @@ public:
QObject *accessibilityParentObject() override;
QtWebEngineCore::WebEngineSettings *webEngineSettings() const override;
void allowCertificateError(const QSharedPointer<CertificateErrorController> &controller) override;
+ void selectClientCert(const QSharedPointer<ClientCertSelectController> &controller) override;
void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) override;
void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override;
void updateScrollPosition(const QPointF &position) override;
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index c96bf15bb..1e24f35e9 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -14,6 +14,7 @@ INCLUDEPATH += $$PWD api ../core ../core/api ../webengine/api
SOURCES = \
api/qtwebenginewidgetsglobal.cpp \
api/qwebenginecertificateerror.cpp \
+ api/qwebengineclientcertselection.cpp \
api/qwebenginecontextmenudata.cpp \
api/qwebenginedownloaditem.cpp \
api/qwebenginefullscreenrequest.cpp \
@@ -29,6 +30,7 @@ SOURCES = \
HEADERS = \
api/qtwebenginewidgetsglobal.h \
api/qwebenginecertificateerror.h \
+ api/qwebengineclientcertselection.h \
api/qwebenginecontextmenudata.h \
api/qwebenginedownloaditem.h \
api/qwebenginedownloaditem_p.h \