Messagelib

webenginenavigationrequestinterceptor.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 "webenginenavigationrequestinterceptor.h"
8 #include "webenginepage.h"
9 using namespace WebEngineViewer;
10 
11 WebEngineNavigationRequestInterceptor::WebEngineNavigationRequestInterceptor(QWebEnginePage *page)
12  : QWebEnginePage(page)
13  , mTargetPage(page)
14 {
15 }
16 
17 WebEngineNavigationRequestInterceptor::~WebEngineNavigationRequestInterceptor() = default;
18 
19 bool WebEngineNavigationRequestInterceptor::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
20 {
21  Q_UNUSED(isMainFrame)
22  auto page = qobject_cast<WebEnginePage *>(mTargetPage);
23  if (type == NavigationTypeLinkClicked && page) {
24  Q_EMIT page->urlClicked(url);
25  return false;
26  }
27  return false;
28 }
The WebEnginePage class.
Definition: webenginepage.h:21
T qobject_cast(QObject *object)
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Dec 5 2021 23:04:55 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.