1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
From 067155d53af52b0b6e26801fa3a7ec59a93aeb7f Mon Sep 17 00:00:00 2001
From: David Rosca <nowrep@gmail.com>
Date: Wed, 20 Mar 2019 12:01:01 +0100
Subject: NetworkManager: Fix QtWebEngine warning about registering schemes
---
src/lib/app/mainapplication.cpp | 2 ++
src/lib/network/networkmanager.cpp | 26 +++++++++++++++-----------
src/lib/network/networkmanager.h | 2 ++
3 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp
index 1e89d16..d6c622f 100644
--- a/src/lib/app/mainapplication.cpp
+++ b/src/lib/app/mainapplication.cpp
@@ -281,6 +281,8 @@ MainApplication::MainApplication(int &argc, char** argv)
Settings::createSettings(DataPaths::currentProfilePath() + QLatin1String("/settings.ini"));
+ NetworkManager::registerSchemes();
+
m_webProfile = isPrivate() ? new QWebEngineProfile(this) : QWebEngineProfile::defaultProfile();
connect(m_webProfile, &QWebEngineProfile::downloadRequested, this, &MainApplication::downloadRequested);
diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp
index 773e116..0c11aff 100644
--- a/src/lib/network/networkmanager.cpp
+++ b/src/lib/network/networkmanager.cpp
@@ -52,17 +52,6 @@ NetworkManager::NetworkManager(QObject *parent)
// Create scheme handlers
m_extensionScheme = new ExtensionSchemeManager();
-#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0)
- QWebEngineUrlScheme falkonScheme("falkon");
- falkonScheme.setFlags(QWebEngineUrlScheme::SecureScheme | QWebEngineUrlScheme::ContentSecurityPolicyIgnored);
- falkonScheme.setSyntax(QWebEngineUrlScheme::Syntax::Path);
- QWebEngineUrlScheme::registerScheme(falkonScheme);
- QWebEngineUrlScheme extensionScheme("extension");
- extensionScheme.setFlags(QWebEngineUrlScheme::SecureScheme | QWebEngineUrlScheme::ContentSecurityPolicyIgnored);
- extensionScheme.setSyntax(QWebEngineUrlScheme::Syntax::Path);
- QWebEngineUrlScheme::registerScheme(extensionScheme);
-#endif
-
mApp->webProfile()->installUrlSchemeHandler(QByteArrayLiteral("falkon"), new FalkonSchemeHandler());
mApp->webProfile()->installUrlSchemeHandler(QByteArrayLiteral("extension"), m_extensionScheme);
WebPage::addSupportedScheme(QSL("falkon"));
@@ -309,6 +298,21 @@ void NetworkManager::shutdown()
mApp->webProfile()->setRequestInterceptor(nullptr);
}
+// static
+void NetworkManager::registerSchemes()
+{
+#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0)
+ QWebEngineUrlScheme falkonScheme("falkon");
+ falkonScheme.setFlags(QWebEngineUrlScheme::SecureScheme | QWebEngineUrlScheme::ContentSecurityPolicyIgnored);
+ falkonScheme.setSyntax(QWebEngineUrlScheme::Syntax::Path);
+ QWebEngineUrlScheme::registerScheme(falkonScheme);
+ QWebEngineUrlScheme extensionScheme("extension");
+ extensionScheme.setFlags(QWebEngineUrlScheme::SecureScheme | QWebEngineUrlScheme::ContentSecurityPolicyIgnored);
+ extensionScheme.setSyntax(QWebEngineUrlScheme::Syntax::Path);
+ QWebEngineUrlScheme::registerScheme(extensionScheme);
+#endif
+}
+
QNetworkReply *NetworkManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
{
QNetworkRequest req = request;
diff --git a/src/lib/network/networkmanager.h b/src/lib/network/networkmanager.h
index af7475b..638b263 100644
--- a/src/lib/network/networkmanager.h
+++ b/src/lib/network/networkmanager.h
@@ -48,6 +48,8 @@ public:
void loadSettings();
void shutdown();
+ static void registerSchemes();
+
protected:
QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData) override;
--
cgit v1.1
|