2 * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
6 * Privacy Browser PC is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Privacy Browser PC is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Privacy Browser PC. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef PRIVACYWEBENGINEVIEW_H
21 #define PRIVACYWEBENGINEVIEW_H
23 // Application headers.
24 #include "structs/RequestStruct.h"
26 // KDE framework headers.
29 // Qt toolkit headers.
32 #include <QNetworkCookie>
33 #include <QWebEngineFindTextResult>
34 #include <QWebEngineView>
36 class PrivacyWebEngineView : public QWebEngineView
38 // Include the Q_OBJECT macro.
42 // The default constructor.
43 explicit PrivacyWebEngineView(QWidget *parentWidgetPointer = nullptr);
45 // The public variables.
46 int blockedRequests = 0;
47 std::list<QNetworkCookie> *cookieListPointer = new std::list<QNetworkCookie>;
48 double defaultZoomFactor = 1.00;
49 QString domainSettingsName = QLatin1String("");
50 QIcon favoriteIcon = QIcon::fromTheme(QLatin1String("globe"), QIcon::fromTheme(QLatin1String("applications-internet")));
51 bool findCaseSensitive = false;
52 QString findString = QLatin1String("");
53 QWebEngineFindTextResult findTextResult = QWebEngineFindTextResult();
54 int httpAuthenticationDialogsDisplayed = 0;
55 bool isLoading = false;
56 int loadProgressInt = -1;
57 bool localStorageEnabled = false;
58 QList<RequestStruct *> *requestsListPointer = new QList<RequestStruct *>;
60 // The public functions.
61 void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
65 void numberOfCookiesChanged(const int numberOfCookies) const;
66 void displayHttpPingBlockedDialog(const QString &httpPingUrl) const;
67 void requestBlocked(const int blockedRequests) const;
68 void updateUi(const PrivacyWebEngineView *privacyWebEngineViewPointer) const;
72 void addCookieToList(const QNetworkCookie &cookie) const;
73 void removeCookieFromList(const QNetworkCookie &cookie) const;
77 void applyDomainSettingsWithoutReloading(const QString &hostname);
78 void clearRequestsList();
79 void displayHttpPingDialog(const QString &httpPingUrl) const;
80 void handleAuthenticationRequest(const QUrl &requestUrl, QAuthenticator *authenticatorPointer);
81 void storeRequest(RequestStruct *requestStructPointer);
84 // The private variables.
85 KLineEdit *passwordLineEditPointer;
86 KLineEdit *usernameLineEditPointer;
87 QWebEngineProfile *webEngineProfilePointer;
88 QWebEngineSettings *webEngineSettingsPointer;
91 // The protected functions.
92 void contextMenuEvent(QContextMenuEvent *contextMenuEvent) override;
93 QWebEngineView* createWindow(QWebEnginePage::WebWindowType webWindowType) override;