Messagelib

messageviewer/src/viewer/webengine/loadexternalreferencesurlinterceptor/loadexternalreferencesurlinterceptor.cpp
1 /*
2  SPDX-FileCopyrightText: 2016-2023 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "loadexternalreferencesurlinterceptor.h"
8 #include "remote-content/remotecontentmanager.h"
9 
10 using namespace MessageViewer;
11 
12 LoadExternalReferencesUrlInterceptor::LoadExternalReferencesUrlInterceptor(QObject *parent)
13  : WebEngineViewer::LoadExternalReferencesUrlInterceptor(parent)
14 {
15 }
16 
17 LoadExternalReferencesUrlInterceptor::~LoadExternalReferencesUrlInterceptor() = default;
18 bool LoadExternalReferencesUrlInterceptor::urlIsBlocked(const QUrl &requestedUrl)
19 {
20  const QUrl url = requestedUrl.adjusted(QUrl::RemovePath | QUrl::RemovePort | QUrl::RemoveQuery);
21  bool contains = false;
22  if (MessageViewer::RemoteContentManager::self()->isBlocked(url, contains)) {
23  return true;
24  }
25  return false;
26 }
27 
28 bool LoadExternalReferencesUrlInterceptor::urlIsAuthorized(const QUrl &requestedUrl)
29 {
30  const QUrl url = requestedUrl.adjusted(QUrl::RemovePath | QUrl::RemovePort | QUrl::RemoveQuery);
31  bool contains = false;
32  if (MessageViewer::RemoteContentManager::self()->isAutorized(url, contains)) {
33  return false;
34  }
35  if (!contains) {
36  Q_EMIT urlBlocked(requestedUrl);
37  }
38  return true;
39 }
QUrl adjusted(QUrl::FormattingOptions options) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Mar 22 2023 04:07:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.