summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Morph2020-11-23 00:06:31 -0500
committerGravatar Morph2020-12-18 10:33:28 -0500
commit5836786246464a16f1d122d1c9a7c8fcb1f0e272 (patch)
treede5f0f0fb1b9b8518d3b76b77420d0e90f36be89 /src
parentbootmanager: Add a check whether loading is complete (diff)
downloadyuzu-5836786246464a16f1d122d1c9a7c8fcb1f0e272.tar.gz
yuzu-5836786246464a16f1d122d1c9a7c8fcb1f0e272.tar.xz
yuzu-5836786246464a16f1d122d1c9a7c8fcb1f0e272.zip
util: Add URL Request Interceptor for QWebEngine
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/CMakeLists.txt2
-rw-r--r--src/yuzu/util/url_request_interceptor.cpp32
-rw-r--r--src/yuzu/util/url_request_interceptor.h30
3 files changed, 64 insertions, 0 deletions
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt
index b16b54032..f3e527e94 100644
--- a/src/yuzu/CMakeLists.txt
+++ b/src/yuzu/CMakeLists.txt
@@ -141,6 +141,8 @@ add_executable(yuzu
141 util/limitable_input_dialog.h 141 util/limitable_input_dialog.h
142 util/sequence_dialog/sequence_dialog.cpp 142 util/sequence_dialog/sequence_dialog.cpp
143 util/sequence_dialog/sequence_dialog.h 143 util/sequence_dialog/sequence_dialog.h
144 util/url_request_interceptor.cpp
145 util/url_request_interceptor.h
144 util/util.cpp 146 util/util.cpp
145 util/util.h 147 util/util.h
146 compatdb.cpp 148 compatdb.cpp
diff --git a/src/yuzu/util/url_request_interceptor.cpp b/src/yuzu/util/url_request_interceptor.cpp
new file mode 100644
index 000000000..2d491d8c0
--- /dev/null
+++ b/src/yuzu/util/url_request_interceptor.cpp
@@ -0,0 +1,32 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#ifdef YUZU_USE_QT_WEB_ENGINE
6
7#include "yuzu/util/url_request_interceptor.h"
8
9UrlRequestInterceptor::UrlRequestInterceptor(QObject* p) : QWebEngineUrlRequestInterceptor(p) {}
10
11UrlRequestInterceptor::~UrlRequestInterceptor() = default;
12
13void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) {
14 const auto resource_type = info.resourceType();
15
16 switch (resource_type) {
17 case QWebEngineUrlRequestInfo::ResourceTypeMainFrame:
18 requested_url = info.requestUrl();
19 emit FrameChanged();
20 break;
21 case QWebEngineUrlRequestInfo::ResourceTypeSubFrame:
22 case QWebEngineUrlRequestInfo::ResourceTypeXhr:
23 emit FrameChanged();
24 break;
25 }
26}
27
28QUrl UrlRequestInterceptor::GetRequestedURL() const {
29 return requested_url;
30}
31
32#endif
diff --git a/src/yuzu/util/url_request_interceptor.h b/src/yuzu/util/url_request_interceptor.h
new file mode 100644
index 000000000..8a7f7499f
--- /dev/null
+++ b/src/yuzu/util/url_request_interceptor.h
@@ -0,0 +1,30 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#ifdef YUZU_USE_QT_WEB_ENGINE
8
9#include <QObject>
10#include <QWebEngineUrlRequestInterceptor>
11
12class UrlRequestInterceptor : public QWebEngineUrlRequestInterceptor {
13 Q_OBJECT
14
15public:
16 explicit UrlRequestInterceptor(QObject* p = nullptr);
17 ~UrlRequestInterceptor() override;
18
19 void interceptRequest(QWebEngineUrlRequestInfo& info) override;
20
21 QUrl GetRequestedURL() const;
22
23signals:
24 void FrameChanged();
25
26private:
27 QUrl requested_url;
28};
29
30#endif