Messagelib

networkurlinterceptormanager.cpp
1 /*
2  SPDX-FileCopyrightText: 2016-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "networkurlinterceptormanager.h"
8 #include "networkurlinterceptorpluginmanager.h"
9 
10 using namespace WebEngineViewer;
11 
12 class WebEngineViewer::NetworkUrlInterceptorManagerPrivate
13 {
14 public:
15  NetworkUrlInterceptorManagerPrivate(QWebEngineView *webEngine, KActionCollection *ac, NetworkUrlInterceptorManager *qq)
16  : q(qq)
17  {
18  createInterfaces(webEngine, ac);
19  }
20 
21  Q_REQUIRED_RESULT QList<QAction *> interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const;
22  void createInterfaces(QWebEngineView *webEngine, KActionCollection *ac);
24 
25 private:
27 };
28 
29 QList<QAction *> NetworkUrlInterceptorManagerPrivate::interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const
30 {
31  QList<QAction *> lstActions;
32  for (WebEngineViewer::NetworkPluginUrlInterceptorInterface *interface : std::as_const(mListInterface)) {
33  lstActions.append(interface->interceptorUrlActions(result));
34  }
35  return lstActions;
36 }
37 
38 void NetworkUrlInterceptorManagerPrivate::createInterfaces(QWebEngineView *webEngine, KActionCollection *ac)
39 {
40  for (NetworkPluginUrlInterceptor *plugin : NetworkUrlInterceptorPluginManager::self()->pluginsList()) {
41  if (plugin->isEnabled()) {
42  WebEngineViewer::NetworkPluginUrlInterceptorInterface *interface = plugin->createInterface(webEngine, q);
43  interface->createActions(ac);
44  mListInterface.append(interface);
45  }
46  }
47 }
48 
49 NetworkUrlInterceptorManager::NetworkUrlInterceptorManager(QWebEngineView *webEngine, KActionCollection *ac, QObject *parent)
50  : QObject(parent)
51  , d(new NetworkUrlInterceptorManagerPrivate(webEngine, ac, this))
52 {
53 }
54 
55 NetworkUrlInterceptorManager::~NetworkUrlInterceptorManager() = default;
56 
57 QVector<WebEngineViewer::NetworkPluginUrlInterceptorInterface *> NetworkUrlInterceptorManager::interfaceList() const
58 {
59  return d->mListInterface;
60 }
61 
62 QList<QAction *> NetworkUrlInterceptorManager::interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const
63 {
64  return d->interceptorUrlActions(result);
65 }
The NetworkPluginUrlInterceptor class.
The WebHitTestResult class.
void append(const T &value)
The NetworkUrlInterceptorManager class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 23:04:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.