diff options
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r-- | src/webenginewidgets/api/qwebenginecertificateerror.cpp | 111 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginecertificateerror.h | 84 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 19 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.h | 2 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage_p.h | 1 | ||||
-rw-r--r-- | src/webenginewidgets/webenginewidgets.pro | 2 |
6 files changed, 219 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.cpp b/src/webenginewidgets/api/qwebenginecertificateerror.cpp new file mode 100644 index 000000000..7be8c75d0 --- /dev/null +++ b/src/webenginewidgets/api/qwebenginecertificateerror.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** 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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 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.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 later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwebenginecertificateerror.h" + +QT_BEGIN_NAMESPACE + +class QWebEngineCertificateErrorPrivate { +public: + QWebEngineCertificateErrorPrivate(int error, QUrl url, bool overridable, QString errorDescription); + + QWebEngineCertificateError::Error error; + QUrl url; + bool overridable; + QString errorDescription; +}; + +QWebEngineCertificateErrorPrivate::QWebEngineCertificateErrorPrivate(int error, QUrl url, bool overridable, QString errorDescription) + : error(QWebEngineCertificateError::Error(error)) + , url(url) + , overridable(overridable) + , errorDescription(errorDescription) +{ } + + +QWebEngineCertificateError::QWebEngineCertificateError(int error, QUrl url, bool overridable, QString errorDescription) + : d_ptr(new QWebEngineCertificateErrorPrivate(error, url, overridable, errorDescription)) +{ } + +QWebEngineCertificateError::~QWebEngineCertificateError() +{ +} + +/*! + Returns whether this error can be overridden and accepted. + + \sa error(), errorDescription() +*/ +bool QWebEngineCertificateError::isOverridable() const +{ + const Q_D(QWebEngineCertificateError); + return d->overridable; +} + +/*! + Returns the URL that triggered the error. + + \sa error(), errorDescription() +*/ +QUrl QWebEngineCertificateError::url() const +{ + const Q_D(QWebEngineCertificateError); + return d->url; +} + +/*! + Returns the type of the error. + + \sa errorDescription(), isOverridable() +*/ +QWebEngineCertificateError::Error QWebEngineCertificateError::error() const +{ + const Q_D(QWebEngineCertificateError); + return d->error; +} + +/*! + Returns a short localized human-readable description of the error. + + \sa error(), url(), isOverridable() +*/ +QString QWebEngineCertificateError::errorDescription() const +{ + const Q_D(QWebEngineCertificateError); + return d->errorDescription; +} + +QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.h b/src/webenginewidgets/api/qwebenginecertificateerror.h new file mode 100644 index 000000000..8cdd6946c --- /dev/null +++ b/src/webenginewidgets/api/qwebenginecertificateerror.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 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.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 later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWEBENGINECERTIFICATEERROR_H +#define QWEBENGINECERTIFICATEERROR_H + +#include "qtwebenginewidgetsglobal.h" + +#include <QtCore/QScopedPointer> +#include <QtCore/QUrl> + +QT_BEGIN_NAMESPACE + +class QWebEngineCertificateErrorPrivate; + +class QWEBENGINEWIDGETS_EXPORT QWebEngineCertificateError { +public: + QWebEngineCertificateError(int error, QUrl url, bool overridable, QString errorDescription); + ~QWebEngineCertificateError(); + + // Keep this identical to CertificateErrorController::CertificateError, or add mapping layer. + enum Error { + SslPinnedKeyNotInCertificateChain = -150, + CertificateCommonNameInvalid = -200, + CertificateDateInvalid = -201, + CertificateAuthorityInvalid = -202, + CertificateContainsErrors = -203, + CertificateNoRevocationMechanism = -204, + CertificateUnableToCheckRevocation = -205, + CertificateRevoked = -206, + CertificateInvalid = -207, + CertificateWeakSignatureAlgorithm = -208, + CertificateNonUniqueName = -210, + CertificateWeakKey = -211, + CertificateNameConstraintViolation = -212, + }; + + Error error() const; + QUrl url() const; + bool isOverridable() const; + QString errorDescription() const; + +private: + Q_DISABLE_COPY(QWebEngineCertificateError) + Q_DECLARE_PRIVATE(QWebEngineCertificateError); + QScopedPointer<QWebEngineCertificateErrorPrivate> d_ptr; +}; + +QT_END_NAMESPACE + +#endif // QWEBENGINECERTIFICATEERROR_H diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index e8f34a1ea..51e733e70 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -23,6 +23,7 @@ #include "qwebenginepage.h" #include "qwebenginepage_p.h" +#include "certificate_error_controller.h" #include "javascript_dialog_controller.h" #include "qwebenginehistory.h" #include "qwebenginehistory_p.h" @@ -646,6 +647,18 @@ void QWebEnginePagePrivate::javascriptDialog(QSharedPointer<JavaScriptDialogCont controller->reject(); } +void QWebEnginePagePrivate::allowCertificateError(const QExplicitlySharedDataPointer<CertificateErrorController> &controller) +{ + Q_Q(QWebEnginePage); + bool accepted = false; + + QWebEngineCertificateError error(controller->error(), controller->url(), controller->overridable() && !controller->strictEnforcement(), controller->errorString()); + accepted = q->certificateError(error); + + if (error.isOverridable()) + controller->accept(accepted); +} + void QWebEnginePagePrivate::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) { Q_Q(QWebEnginePage); @@ -919,6 +932,12 @@ void QWebEnginePage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel leve Q_UNUSED(lineNumber); Q_UNUSED(sourceID); } + +bool QWebEnginePage::certificateError(const QWebEngineCertificateError &) +{ + return false; +} + QT_END_NAMESPACE #include "moc_qwebenginepage.cpp" diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index e1afa14ee..667098032 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -38,6 +38,7 @@ #define QWEBENGINEPAGE_H #include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> +#include <QtWebEngineWidgets/qwebenginecertificateerror.h> #include <QtCore/qobject.h> #include <QtCore/qurl.h> @@ -228,6 +229,7 @@ protected: virtual bool javaScriptConfirm(const QUrl &securityOrigin, const QString& msg); virtual bool javaScriptPrompt(const QUrl &securityOrigin, const QString& msg, const QString& defaultValue, QString* result); virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID); + virtual bool certificateError(const QWebEngineCertificateError &certificateError); private: Q_DECLARE_PRIVATE(QWebEnginePage); diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index 40e44a07e..10a253d8d 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -137,6 +137,7 @@ public: virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE; virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE; virtual WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE; + virtual void allowCertificateError(const QExplicitlySharedDataPointer<CertificateErrorController> &controller) Q_DECL_OVERRIDE; void updateAction(QWebEnginePage::WebAction) const; void updateNavigationActions(); diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro index d4cce2590..37a076307 100644 --- a/src/webenginewidgets/webenginewidgets.pro +++ b/src/webenginewidgets/webenginewidgets.pro @@ -14,6 +14,7 @@ INCLUDEPATH += $$PWD api ../core ../webengine/api SOURCES = \ api/qtwebenginewidgetsglobal.cpp \ + api/qwebenginecertificateerror.cpp \ api/qwebenginehistory.cpp \ api/qwebenginepage.cpp \ api/qwebenginesettings.cpp \ @@ -22,6 +23,7 @@ SOURCES = \ HEADERS = \ api/qtwebenginewidgetsglobal.h \ + api/qwebenginecertificateerror.h \ api/qwebenginehistory.h \ api/qwebenginepage.h \ api/qwebenginepage_p.h \ |