diff --git a/src/defines.pri b/src/defines.pri index 362809d7b..d95aca109 100644 --- a/src/defines.pri +++ b/src/defines.pri @@ -18,9 +18,6 @@ win32 { DEFINES *= QT_NO_URL_CAST_FROM_STRING DEFINES *= QT_USE_QSTRINGBUILDER -##It won't compile on windows with this define. Some bug in qtsingleapp / qvector template -!win32: !CONFIG(debug, debug|release): DEFINES *= QT_NO_DEBUG_OUTPUT - CONFIG(debug, debug|release): DEFINES *= QUPZILLA_DEBUG_BUILD d_no_system_datapath = $$(NO_SYSTEM_DATAPATH) diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index f4a604686..e5cc7999c 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -45,7 +45,7 @@ #include "webpage.h" #include "settings.h" #include "locationbarsettings.h" -#include "webviewsettings.h" +#include "websettings.h" #include "clearprivatedata.h" #include "commandlineoptions.h" @@ -359,7 +359,7 @@ void MainApplication::loadSettings() } LocationBarSettings::loadSettings(); - WebViewSettings::loadSettings(); + WebSettings::loadSettings(); } void MainApplication::reloadSettings() diff --git a/src/lib/lib.pro b/src/lib/lib.pro index 9ae30faa1..0319e9800 100644 --- a/src/lib/lib.pro +++ b/src/lib/lib.pro @@ -162,14 +162,14 @@ SOURCES += \ popupwindow/popuplocationbar.cpp \ webview/tabbedwebview.cpp \ webview/webview.cpp \ - webview/webviewsettings.cpp \ preferences/pluginlistdelegate.cpp \ popupwindow/popupstatusbarmessage.cpp \ other/licenseviewer.cpp \ bookmarksimport/bookmarksimporticonfetcher.cpp \ other/checkboxdialog.cpp \ network/schemehandler.cpp \ - tools/plaineditwithlines.cpp + tools/plaineditwithlines.cpp \ + webview/websettings.cpp HEADERS += \ webview/tabpreview.h \ @@ -303,7 +303,6 @@ HEADERS += \ webview/tabbedwebview.h \ webview/webview.h \ app/qz_namespace.h \ - webview/webviewsettings.h \ preferences/pluginlistdelegate.h \ popupwindow/popupstatusbarmessage.h \ other/licenseviewer.h \ @@ -311,7 +310,8 @@ HEADERS += \ other/checkboxdialog.h \ network/schemehandler.h \ tools/plaineditwithlines.h \ - sidebar/sidebarinterface.h + sidebar/sidebarinterface.h \ + webview/websettings.h FORMS += \ preferences/autofillmanager.ui \ diff --git a/src/lib/webview/webpage.cpp b/src/lib/webview/webpage.cpp index 1d46ef469..2bdcf3791 100644 --- a/src/lib/webview/webpage.cpp +++ b/src/lib/webview/webpage.cpp @@ -32,6 +32,7 @@ #include "networkmanagerproxy.h" #include "adblockicon.h" #include "iconprovider.h" +#include "websettings.h" #ifdef NONBLOCK_JS_DIALOGS #include "ui_jsconfirm.h" @@ -282,6 +283,52 @@ void WebPage::handleUnsupportedContent(QNetworkReply* reply) reply->deleteLater(); } +void WebPage::handleUnknownProtocol(const QUrl &url) +{ + const QString &protocol = url.scheme(); + + if (WebSettings::blockedProtocols.contains(protocol)) { + qDebug() << "WebPage::handleUnknownProtocol Protocol" << protocol << "is blocked!"; + return; + } + + if (WebSettings::autoOpenProtocols.contains(protocol)) { + QDesktopServices::openUrl(url); + return; + } + + const QString &text = tr("QupZilla cannot handle %1: links. The requested link " + "is Do you want QupZilla to try " + "open this link in system application?
").arg(protocol, url.toString()); + CheckBoxDialog dialog(QDialogButtonBox::Yes | QDialogButtonBox::No, view()); + dialog.setText(text); + dialog.setCheckBoxText(tr("Remember my choice for this protocol")); + dialog.setWindowTitle(tr("External Protocol Request")); + dialog.setIcon(IconProvider::standardIcon(QStyle::SP_MessageBoxQuestion)); + + switch (dialog.exec()) { + case QDialog::Accepted: + if (dialog.isChecked()) { + WebSettings::autoOpenProtocols.append(protocol); + WebSettings::saveSettings(); + } + + QDesktopServices::openUrl(url); + break; + + case QDialog::Rejected: + if (dialog.isChecked()) { + WebSettings::blockedProtocols.append(protocol); + WebSettings::saveSettings(); + } + + break; + + default: + break; + } +} + void WebPage::downloadRequested(const QNetworkRequest &request) { DownloadManager* dManager = mApp->downManager(); @@ -531,6 +578,10 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte case QNetworkReply::UnknownNetworkError: errorString = exOption->errorString.isEmpty() ? tr("Unknown network error") : exOption->errorString; break; + case QNetworkReply::ProtocolUnknownError: + handleUnknownProtocol(exOption->url); + return false; + break; case QNetworkReply::ContentAccessDenied: if (exOption->errorString.startsWith("AdBlockRule")) { if (exOption->frame != erPage->mainFrame()) { //Content in