diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index 0c1980f1a..1eba48ad3 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -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" diff --git a/src/lib/webkit/webpage.cpp b/src/lib/webkit/webpage.cpp index 196e918dd..e2193397e 100644 --- a/src/lib/webkit/webpage.cpp +++ b/src/lib/webkit/webpage.cpp @@ -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::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("%1

%2

%4

").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; diff --git a/src/lib/webkit/webpage.h b/src/lib/webkit/webpage.h index 88c8210cc..cee1746c0 100644 --- a/src/lib/webkit/webpage.h +++ b/src/lib/webkit/webpage.h @@ -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 s_livingPages; + static QStringList s_ignoredSslErrors; NetworkManagerProxy* m_networkProxy; TabbedWebView* m_view;