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 // KDE framework headers.
26 // Qt toolkit headers.
28 #include <QNetworkCookie>
29 #include <QWebEngineFindTextResult>
30 #include <QWebEngineView>
32 class PrivacyWebEngineView : public QWebEngineView
34 // Include the Q_OBJECT macro.
38 // The default constructor.
39 explicit PrivacyWebEngineView(QWidget *parentWidgetPointer = nullptr);
41 // The public variables.
42 std::list<QNetworkCookie> *cookieListPointer = new std::list<QNetworkCookie>;
43 double defaultZoomFactor = 1.00;
44 QString domainSettingsName = QLatin1String("");
45 QIcon favoriteIcon = QIcon::fromTheme(QLatin1String("globe"), QIcon::fromTheme(QLatin1String("applications-internet")));
46 bool findCaseSensitive = false;
47 QString findString = QLatin1String("");
48 QWebEngineFindTextResult findTextResult = QWebEngineFindTextResult();
49 int httpAuthenticationDialogsDisplayed = 0;
50 bool isLoading = false;
51 int loadProgressInt = -1;
52 bool localStorageEnabled = false;
54 // The public functions.
55 void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
59 void displayHttpPingBlockedDialog(const QString &httpPingUrl) const;
60 void updateCookiesAction(const int numberOfCookies) const;
61 void updateUi(const PrivacyWebEngineView *privacyWebEngineViewPointer) const;
65 void addCookieToList(const QNetworkCookie &cookie) const;
66 void removeCookieFromList(const QNetworkCookie &cookie) const;
70 void applyDomainSettingsWithoutReloading(const QString &hostname);
71 void displayHttpPingDialog(const QString &httpPingUrl) const;
72 void handleAuthenticationRequest(const QUrl &requestUrl, QAuthenticator *authenticatorPointer);
75 // The private variables.
76 KLineEdit *passwordLineEditPointer;
77 KLineEdit *usernameLineEditPointer;
78 QWebEngineProfile *webEngineProfilePointer;
79 QWebEngineSettings *webEngineSettingsPointer;
82 // The protected functions.
83 void contextMenuEvent(QContextMenuEvent *contextMenuEvent) override;
84 QWebEngineView* createWindow(QWebEnginePage::WebWindowType webWindowType) override;