From 5ca4d8903f952bf65a6bb9168f77773af050afe8 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 13 Nov 2018 18:07:40 +0100 Subject: [PATCH] Remove the requestInterceptor. This is useless. It was use to rewrite http request to zim request and have the custumUrlShemeHandler handle the request. However, we now want to open http request in a external browser. And it is already the case, the http requests are never intercepted. --- kiwix-desktop.pro | 2 -- src/kiwixapp.h | 3 --- src/requestinterceptor.cpp | 22 ---------------------- src/requestinterceptor.h | 14 -------------- src/webview.cpp | 1 - 5 files changed, 42 deletions(-) delete mode 100644 src/requestinterceptor.cpp delete mode 100644 src/requestinterceptor.h diff --git a/kiwix-desktop.pro b/kiwix-desktop.pro index ad23ff6..d6862bc 100644 --- a/kiwix-desktop.pro +++ b/kiwix-desktop.pro @@ -47,7 +47,6 @@ SOURCES += \ src/blobbuffer.cpp \ src/library.cpp \ src/topwidget.cpp \ - src/requestinterceptor.cpp \ src/urlschemehandler.cpp \ src/webview.cpp \ src/searchbar.cpp \ @@ -67,7 +66,6 @@ HEADERS += \ src/library.h \ src/topwidget.h \ src/kconstants.h \ - src/requestinterceptor.h \ src/urlschemehandler.h \ src/webview.h \ src/searchbar.h \ diff --git a/src/kiwixapp.h b/src/kiwixapp.h index 789b2e0..ea2459e 100644 --- a/src/kiwixapp.h +++ b/src/kiwixapp.h @@ -8,7 +8,6 @@ #include "tabbar.h" #include "tocsidebar.h" #include "urlschemehandler.h" -#include "requestinterceptor.h" #include #include @@ -64,7 +63,6 @@ public: void showMessage(const QString& message); UrlSchemeHandler* getSchemeHandler() { return &m_schemeHandler; } - RequestInterceptor* getRequestInterceptor() { return &m_requestInterceptor; } Library* getLibrary() { return &m_library; } MainWindow* getMainWindow() { return mp_mainWindow; } kiwix::Downloader* getDownloader() { return mp_downloader; } @@ -93,7 +91,6 @@ private: QErrorMessage* mp_errorDialog; UrlSchemeHandler m_schemeHandler; - RequestInterceptor m_requestInterceptor; QAction* mpa_actions[MAX_ACTION]; }; diff --git a/src/requestinterceptor.cpp b/src/requestinterceptor.cpp deleted file mode 100644 index 34d2aaa..0000000 --- a/src/requestinterceptor.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "requestinterceptor.h" - -#include -#include -#include - -RequestInterceptor::RequestInterceptor() -{ - -} - - -void RequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) -{ - auto url = info.requestUrl(); - auto urlString = url.toString(); - if (urlString.startsWith("http://")) { - urlString.replace(0, 7, "zim://"); - } - info.redirect(QUrl(urlString)); -} - diff --git a/src/requestinterceptor.h b/src/requestinterceptor.h deleted file mode 100644 index 8c60244..0000000 --- a/src/requestinterceptor.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef REQUESTINTERCEPTOR_H -#define REQUESTINTERCEPTOR_H - -#include - - -class RequestInterceptor : public QWebEngineUrlRequestInterceptor -{ -public: - RequestInterceptor(); - virtual void interceptRequest(QWebEngineUrlRequestInfo &info); -}; - -#endif // REQUESTINTERCEPTOR_H diff --git a/src/webview.cpp b/src/webview.cpp index 658da89..bb643b3 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -13,7 +13,6 @@ WebView::WebView(QWidget *parent) auto profile = page()->profile(); auto app = KiwixApp::instance(); profile->installUrlSchemeHandler("zim", app->getSchemeHandler()); - profile->setRequestInterceptor(app->getRequestInterceptor()); QObject::connect(this, &QWebEngineView::urlChanged, this, &WebView::onUrlChanged); }