7#include "webengineview.h"
8#include "checkphishingurl/localdatabasemanager.h"
9#include "webenginemanagescript.h"
10#include "webenginenavigationrequestinterceptor.h"
11#include "webengineviewer_debug.h"
18using namespace WebEngineViewer;
20class WebEngineViewer::WebEngineViewPrivate
28 ~WebEngineViewPrivate()
30 delete mWebEngineNavigatorInterceptor;
31 mWebEngineNavigatorInterceptor =
nullptr;
32 delete mWebEngineNavigatorInterceptorView;
33 mWebEngineNavigatorInterceptorView =
nullptr;
36 void renderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus
status)
39 case QWebEnginePage::NormalTerminationStatus:
42 case QWebEnginePage::AbnormalTerminationStatus:
43 qCInfo(WEBENGINEVIEWER_LOG) <<
"WebEngine render process terminated abnormally";
45 case QWebEnginePage::CrashedTerminationStatus:
46 qCInfo(WEBENGINEVIEWER_LOG) <<
"WebEngine render process crashed";
48 case QWebEnginePage::KilledTerminationStatus:
49 qCInfo(WEBENGINEVIEWER_LOG) <<
"WebEngine render process killed";
55 if (++mCrashCount < 6) {
62 qreal mSavedRelativePosition = -1;
63 QWidget *mCurrentWidget =
nullptr;
64 WebEngineNavigationRequestInterceptor *mWebEngineNavigatorInterceptor =
nullptr;
73WebEngineView::WebEngineView(
QWidget *parent)
74 : QWebEngineView(parent)
75 , d(new WebEngineViewer::WebEngineViewPrivate(this))
77 installEventFilter(
this);
79 connect(
this, &QWebEngineView::renderProcessTerminated,
this, [
this](QWebEnginePage::RenderProcessTerminationStatus
status) {
80 d->renderProcessTerminated(
status);
82 connect(
this, &QWebEngineView::loadFinished,
this, [
this]() {
90WebEngineView::~WebEngineView() =
default;
92void WebEngineView::forwardWheelEvent(
QWheelEvent *event)
97void WebEngineView::forwardKeyPressEvent(
QKeyEvent *event)
102void WebEngineView::forwardKeyReleaseEvent(
QKeyEvent *event)
107void WebEngineView::forwardMousePressEvent(
QMouseEvent *event)
112void WebEngineView::forwardMouseMoveEvent(
QMouseEvent *event)
117void WebEngineView::forwardMouseReleaseEvent(
QMouseEvent *event)
126 parentWidget()->installEventFilter(
this);
132 if (focusProxy() && d->mCurrentWidget != focusProxy()) {
133 d->mCurrentWidget = focusProxy();
134 d->mCurrentWidget->installEventFilter(
this);
140 if (obj == d->mCurrentWidget) {
141#define HANDLE_EVENT(f, t) \
143 bool wasAccepted = event->isAccepted(); \
144 event->setAccepted(false); \
145 f(static_cast<t *>(event)); \
146 bool ret = event->isAccepted(); \
147 event->setAccepted(wasAccepted); \
151 switch (
event->type()) {
153 HANDLE_EVENT(forwardKeyPressEvent,
QKeyEvent)
155 HANDLE_EVENT(forwardKeyReleaseEvent,
QKeyEvent)
159 HANDLE_EVENT(forwardMouseReleaseEvent,
QMouseEvent)
172 switch (
event->type()) {
185 return QWebEngineView::eventFilter(obj, event);
188QWebEngineView *WebEngineView::createWindow(QWebEnginePage::WebWindowType type)
191 delete d->mWebEngineNavigatorInterceptor;
192 delete d->mWebEngineNavigatorInterceptorView;
195 d->mWebEngineNavigatorInterceptor =
new WebEngineNavigationRequestInterceptor(this->page());
196 d->mWebEngineNavigatorInterceptorView->setPage(d->mWebEngineNavigatorInterceptor);
197 return d->mWebEngineNavigatorInterceptorView;
200void WebEngineView::clearRelativePosition()
202 d->mSavedRelativePosition = -1;
205void WebEngineView::saveRelativePosition()
207 if (d->mSavedRelativePosition != -1) {
208 d->mSavedRelativePosition = page()->scrollPosition().toPoint().y();
212qreal WebEngineView::relativePosition()
const
214 qCDebug(WEBENGINEVIEWER_LOG) <<
"Relative Position" << d->mSavedRelativePosition;
215 return d->mSavedRelativePosition;
220 if (!d->mPhishingDatabase) {
222 d->mPhishingDatabase->initialize();
224 return d->mPhishingDatabase;
227#include "moc_webengineview.cpp"
The LocalDataBaseManager class.
Q_SCRIPTABLE CaptureState status()
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)