summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2020-08-11 14:46:42 +0200
committerMichal Klocek <michal.klocek@qt.io>2020-08-28 13:40:00 +0200
commit1978e726a909ac945c32429e216c49ecad3ecb3a (patch)
treebf0cbbf13ba31f08b4552544122044ac6386fdf4 /src/core
parent08375ee796a545e3916feb24e0b35d561e6f0049 (diff)
Improve QWebEngineCertificateError api
* remove const ref from QWebEngineCertificateError Q_GADGET is a value type, QWebEngineCertificateError is pass as const reference from api. This is not so useful since, in qml this will be anyway copied and for c++ this is not useful since reject, ignore, defer methods are all const. Therefore simply pass it by value. * make consistent naming defer(), acceptCertificate(), rejectCertificate() * remove properties 'differed', 'answered' which are use internally, user knows if he calls functions. * error.errorDescription -> error.description() * error.error() -> error.type() [ChangeLog] In QWebEngineCertificateError use acceptCertificate() instead of ignoreCertificiateError() Change-Id: I9ffa500a0a455d98445b066252dd283872740731 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/api/qwebenginecertificateerror.cpp44
-rw-r--r--src/core/api/qwebenginecertificateerror.h19
-rw-r--r--src/core/web_contents_delegate_qt.cpp2
3 files changed, 20 insertions, 45 deletions
diff --git a/src/core/api/qwebenginecertificateerror.cpp b/src/core/api/qwebenginecertificateerror.cpp
index cf8a20d53..098986132 100644
--- a/src/core/api/qwebenginecertificateerror.cpp
+++ b/src/core/api/qwebenginecertificateerror.cpp
@@ -103,7 +103,7 @@ QWebEngineCertificateError& QWebEngineCertificateError::operator=(const QWebEngi
QWebEngineCertificateError::~QWebEngineCertificateError() = default;
/*!
- \enum QWebEngineCertificateError::Error
+ \enum QWebEngineCertificateError::Type
This enum describes the type of certificate error encountered.
@@ -136,7 +136,7 @@ QWebEngineCertificateError::~QWebEngineCertificateError() = default;
/*!
Returns whether this error can be overridden and accepted.
- \sa error(), errorDescription()
+ \sa error(), description()
*/
bool QWebEngineCertificateError::isOverridable() const
{
@@ -146,7 +146,7 @@ bool QWebEngineCertificateError::isOverridable() const
/*!
Returns the URL that triggered the error.
- \sa error(), errorDescription()
+ \sa error(), description()
*/
QUrl QWebEngineCertificateError::url() const
{
@@ -156,11 +156,11 @@ QUrl QWebEngineCertificateError::url() const
/*!
Returns the type of the error.
- \sa errorDescription(), isOverridable()
+ \sa description(), isOverridable()
*/
-QWebEngineCertificateError::Error QWebEngineCertificateError::error() const
+QWebEngineCertificateError::Type QWebEngineCertificateError::type() const
{
- return Error(d->error());
+ return Type(d->error());
}
/*!
@@ -168,7 +168,7 @@ QWebEngineCertificateError::Error QWebEngineCertificateError::error() const
\sa error(), url(), isOverridable()
*/
-QString QWebEngineCertificateError::errorDescription() const
+QString QWebEngineCertificateError::description() const
{
return d->errorString();
}
@@ -178,9 +178,9 @@ QString QWebEngineCertificateError::errorDescription() const
Marks the certificate error for delayed handling.
- This function should be called when there is a need to postpone the decision whether to ignore a
- certificate error, for example, while waiting for user input. When called, the function pauses the
- URL request until ignoreCertificateError() or rejectCertificate() is called.
+ This function should be called when there is a need to postpone the decision whether to accept a
+ certificate, for example, while waiting for user input. When called, the function pauses the
+ URL request until acceptCertificate() or rejectCertificate() is called.
\note It is only possible to defer overridable certificate errors.
@@ -194,19 +194,9 @@ void QWebEngineCertificateError::defer()
/*!
\since 5.14
- Returns whether the decision for error handling was delayed and the URL load was halted.
+ Accepts the certificate and continues the loading of the requested URL.
*/
-bool QWebEngineCertificateError::deferred() const
-{
- return d->deferred();
-}
-
-/*!
- \since 5.14
-
- Ignores the certificate error and continues the loading of the requested URL.
-*/
-void QWebEngineCertificateError::ignoreCertificateError()
+void QWebEngineCertificateError::acceptCertificate()
{
d->ignoreCertificateError();
}
@@ -224,16 +214,6 @@ void QWebEngineCertificateError::rejectCertificate()
/*!
\since 5.14
- Returns \c true if the error was explicitly rejected or ignored.
-*/
-bool QWebEngineCertificateError::answered() const
-{
- return d->answered();
-}
-
-/*!
- \since 5.14
-
Returns the peer's chain of digital certificates.
Chain starts with the peer's immediate certificate and ending with the CA's certificate.
diff --git a/src/core/api/qwebenginecertificateerror.h b/src/core/api/qwebenginecertificateerror.h
index 029c2a512..1fdea42be 100644
--- a/src/core/api/qwebenginecertificateerror.h
+++ b/src/core/api/qwebenginecertificateerror.h
@@ -56,11 +56,9 @@ QT_BEGIN_NAMESPACE
class Q_WEBENGINECORE_EXPORT QWebEngineCertificateError {
Q_GADGET
Q_PROPERTY(QUrl url READ url CONSTANT FINAL)
- Q_PROPERTY(Error error READ error CONSTANT FINAL)
- Q_PROPERTY(QString description READ errorDescription CONSTANT FINAL)
+ Q_PROPERTY(Type type READ type CONSTANT FINAL)
+ Q_PROPERTY(QString description READ description CONSTANT FINAL)
Q_PROPERTY(bool overridable READ isOverridable CONSTANT FINAL)
- Q_PROPERTY(bool deferred READ deferred CONSTANT FINAL)
- Q_PROPERTY(bool answered READ answered CONSTANT FINAL)
public:
QWebEngineCertificateError(const QWebEngineCertificateError &other);
@@ -68,7 +66,7 @@ public:
~QWebEngineCertificateError();
// Keep this identical to CertificateErrorController::CertificateError, or add mapping layer.
- enum Error {
+ enum Type {
SslPinnedKeyNotInCertificateChain = -150,
CertificateCommonNameInvalid = -200,
CertificateDateInvalid = -201,
@@ -86,19 +84,16 @@ public:
CertificateTransparencyRequired = -214,
CertificateKnownInterceptionBlocked = -217,
};
- Q_ENUM(Error)
+ Q_ENUM(Type)
- Error error() const;
+ Type type() const;
QUrl url() const;
bool isOverridable() const;
- QString errorDescription() const;
+ QString description() const;
Q_INVOKABLE void defer();
- bool deferred() const;
-
Q_INVOKABLE void rejectCertificate();
- Q_INVOKABLE void ignoreCertificateError();
- bool answered() const;
+ Q_INVOKABLE void acceptCertificate();
QList<QSslCertificate> certificateChain() const;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index ceee1d282..5318cdf1b 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -683,7 +683,7 @@ void WebContentsDelegateQt::allowCertificateError(
{
QWebEngineCertificateError error(controller);
m_viewClient->allowCertificateError(error);
- if (!error.isOverridable() || (!error.deferred() && !error.answered()))
+ if (!error.isOverridable() || (!controller->deferred() && !controller->answered()))
error.rejectCertificate();
else
m_certificateErrorControllers.append(controller);