url_request_interceptor.cpp 933 B

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #ifdef YUZU_USE_QT_WEB_ENGINE
  4. #include "yuzu/util/url_request_interceptor.h"
  5. UrlRequestInterceptor::UrlRequestInterceptor(QObject* p) : QWebEngineUrlRequestInterceptor(p) {}
  6. UrlRequestInterceptor::~UrlRequestInterceptor() = default;
  7. void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) {
  8. const auto resource_type = info.resourceType();
  9. switch (resource_type) {
  10. case QWebEngineUrlRequestInfo::ResourceTypeMainFrame:
  11. requested_url = info.requestUrl();
  12. emit FrameChanged();
  13. break;
  14. case QWebEngineUrlRequestInfo::ResourceTypeSubFrame:
  15. case QWebEngineUrlRequestInfo::ResourceTypeXhr:
  16. emit FrameChanged();
  17. break;
  18. default:
  19. break;
  20. }
  21. }
  22. QUrl UrlRequestInterceptor::GetRequestedURL() const {
  23. return requested_url;
  24. }
  25. #endif