diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-20 00:43:57 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-20 00:43:57 +0200 |
| commit | 7fe42f659e53092b314a0542871c417e768bb6da (patch) | |
| tree | 28f3c3b6753bea06bce290ce5e111239e2f7be11 /src/browsertab.cpp | |
| parent | cf3b60ea29526417a35734a4ae4f5a7b0d5560d5 (diff) | |
| download | kristall-7fe42f659e53092b314a0542871c417e768bb6da.tar.gz | |
Makes previous code a tad nicer.
Diffstat (limited to 'src/browsertab.cpp')
| -rw-r--r-- | src/browsertab.cpp | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp index 0fe0af6..041f886 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -810,20 +810,25 @@ bool BrowserTab::startRequest(const QUrl &url, ProtocolHandler::RequestOptions o assert((this->current_handler != nullptr) and "If this error happens, someone forgot to add a new protocol handler class in the constructor. Shame on the programmer!"); - if(this->current_identity.isValid()) { - if(not this->current_handler->enableClientCertificate(this->current_identity)) { - auto answer = QMessageBox::question( - this, - "Kristall", - tr("You requested a %1-URL with a client certificate, but these are not supported for this scheme. Continue?").arg(url.scheme()) - ); - if(answer != QMessageBox::Yes) - return false; + auto const try_enable_certificate = [&]() -> bool { + if(this->current_identity.isValid()) { + if(not this->current_handler->enableClientCertificate(this->current_identity)) { + auto answer = QMessageBox::question( + this, + "Kristall", + tr("You requested a %1-URL with a client certificate, but these are not supported for this scheme. Continue?").arg(url.scheme()) + ); + if(answer != QMessageBox::Yes) + return false; + this->disableClientCertificate(); + } + } else { this->disableClientCertificate(); } - } else { - this->disableClientCertificate(); - } + return true; + }; + if(not try_enable_certificate()) + return false; if(this->current_identity.isValid() and (url.host() != this->current_location.host())) { auto answer = QMessageBox::question( @@ -876,20 +881,8 @@ bool BrowserTab::startRequest(const QUrl &url, ProtocolHandler::RequestOptions o } } - if(this->current_identity.isValid()) { - if(not this->current_handler->enableClientCertificate(this->current_identity)) { - auto answer = QMessageBox::question( - this, - "Kristall", - tr("You requested a %1-URL with a client certificate, but these are not supported for this scheme. Continue?").arg(url.scheme()) - ); - if(answer != QMessageBox::Yes) - return false; - this->disableClientCertificate(); - } - } else { - this->disableClientCertificate(); - } + if(not try_enable_certificate()) + return false; this->is_internal_location = (url.scheme() == "about"); this->current_location = url; |
