mirror of
https://invent.kde.org/network/falkon.git
synced 2024-09-21 17:52:10 +02:00
WebPage: Implement certificateError
This commit is contained in:
parent
b30b25b254
commit
406f522c61
|
@ -33,7 +33,6 @@
|
|||
#include "settings.h"
|
||||
#include "datapaths.h"
|
||||
#include "passwordmanager.h"
|
||||
#include "sslerrordialog.h"
|
||||
#include "schemehandlers/adblockschemehandler.h"
|
||||
#include "schemehandlers/fileschemehandler.h"
|
||||
#include "schemehandlers/ftpschemehandler.h"
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "javascript/externaljsobject.h"
|
||||
#include "tabwidget.h"
|
||||
#include "scripts.h"
|
||||
#include "sslerrordialog.h"
|
||||
|
||||
#ifdef NONBLOCK_JS_DIALOGS
|
||||
#include "ui_jsconfirm.h"
|
||||
|
@ -70,6 +71,7 @@ QString WebPage::s_lastUploadLocation = QDir::homePath();
|
|||
QUrl WebPage::s_lastUnsupportedUrl;
|
||||
QTime WebPage::s_lastUnsupportedUrlTime;
|
||||
QList<WebPage*> WebPage::s_livingPages;
|
||||
QStringList WebPage::s_ignoredSslErrors;
|
||||
|
||||
WebPage::WebPage(QObject* parent)
|
||||
: QWebEnginePage(mApp->webProfile(), parent)
|
||||
|
@ -697,6 +699,63 @@ bool WebPage::event(QEvent* event)
|
|||
return QWebEnginePage::event(event);
|
||||
}
|
||||
|
||||
bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
|
||||
{
|
||||
m_lastRequestUrl = url;
|
||||
|
||||
if (!mApp->plugins()->acceptNavigationRequest(this, url, type, isMainFrame))
|
||||
return false;
|
||||
|
||||
return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame);
|
||||
|
||||
#if QTWEBENGINE_DISABLED
|
||||
if (type == QWebEnginePage::NavigationTypeFormResubmitted) {
|
||||
// Don't show this dialog if app is still starting
|
||||
if (!view() || !view()->isVisible()) {
|
||||
return false;
|
||||
}
|
||||
QString message = tr("To display this page, QupZilla must resend the request \n"
|
||||
"(such as a search or order confirmation) that was performed earlier.");
|
||||
bool result = (QMessageBox::question(view(), tr("Confirm form resubmission"),
|
||||
message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool WebPage::certificateError(const QWebEngineCertificateError &certificateError)
|
||||
{
|
||||
if (s_ignoredSslErrors.contains(certificateError.url().host()))
|
||||
return true;
|
||||
|
||||
QString title = tr("SSL Certificate Error!");
|
||||
QString text1 = tr("The page you are trying to access has the following errors in the SSL certificate:");
|
||||
QString text2 = tr("Would you like to make an exception for this certificate?");
|
||||
|
||||
QString message = QSL("<b>%1</b><p>%2</p><ul><li>%3</li></ul><p>%4</p>").arg(title, text1, certificateError.errorDescription(), text2);
|
||||
|
||||
SslErrorDialog dialog(view());
|
||||
dialog.setText(message);
|
||||
dialog.exec();
|
||||
|
||||
switch (dialog.result()) {
|
||||
case SslErrorDialog::Yes:
|
||||
// TODO: Permanent exceptions
|
||||
s_ignoredSslErrors.append(certificateError.url().host());
|
||||
return true;
|
||||
|
||||
case SslErrorDialog::OnlyForThisSession:
|
||||
s_ignoredSslErrors.append(certificateError.url().host());
|
||||
return true;
|
||||
|
||||
case SslErrorDialog::No:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QStringList WebPage::chooseFiles(QWebEnginePage::FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes)
|
||||
{
|
||||
Q_UNUSED(acceptedMimeTypes);
|
||||
|
@ -758,32 +817,6 @@ void WebPage::populateNetworkRequest(QNetworkRequest &request)
|
|||
#endif
|
||||
}
|
||||
|
||||
bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
|
||||
{
|
||||
m_lastRequestUrl = url;
|
||||
|
||||
if (!mApp->plugins()->acceptNavigationRequest(this, url, type, isMainFrame))
|
||||
return false;
|
||||
|
||||
return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame);
|
||||
|
||||
#if QTWEBENGINE_DISABLED
|
||||
if (type == QWebEnginePage::NavigationTypeFormResubmitted) {
|
||||
// Don't show this dialog if app is still starting
|
||||
if (!view() || !view()->isVisible()) {
|
||||
return false;
|
||||
}
|
||||
QString message = tr("To display this page, QupZilla must resend the request \n"
|
||||
"(such as a search or order confirmation) that was performed earlier.");
|
||||
bool result = (QMessageBox::question(view(), tr("Confirm form resubmission"),
|
||||
message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void WebPage::addAdBlockRule(const AdBlockRule* rule, const QUrl &url)
|
||||
{
|
||||
AdBlockedEntry entry;
|
||||
|
|
|
@ -122,6 +122,8 @@ protected:
|
|||
bool event(QEvent* event);
|
||||
|
||||
private:
|
||||
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) Q_DECL_OVERRIDE;
|
||||
bool certificateError(const QWebEngineCertificateError &certificateError) Q_DECL_OVERRIDE;
|
||||
QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes) Q_DECL_OVERRIDE;
|
||||
QWebEnginePage* createWindow(QWebEnginePage::WebWindowType type) Q_DECL_OVERRIDE;
|
||||
|
||||
|
@ -130,8 +132,6 @@ private:
|
|||
bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output = 0);
|
||||
#endif
|
||||
|
||||
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) Q_DECL_OVERRIDE;
|
||||
|
||||
void handleUnknownProtocol(const QUrl &url);
|
||||
void desktopServicesOpen(const QUrl &url);
|
||||
|
||||
|
@ -139,6 +139,7 @@ private:
|
|||
static QUrl s_lastUnsupportedUrl;
|
||||
static QTime s_lastUnsupportedUrlTime;
|
||||
static QList<WebPage*> s_livingPages;
|
||||
static QStringList s_ignoredSslErrors;
|
||||
|
||||
NetworkManagerProxy* m_networkProxy;
|
||||
TabbedWebView* m_view;
|
||||
|
|
Loading…
Reference in New Issue
Block a user