SPDX-License-Identifier: GPL-3.0-or-later
-SPDX-FileCopyrightText: 2016-2017, 2021-2024 Soren Stoutner <soren@stoutner.com>
+SPDX-FileCopyrightText: 2016-2017, 2021-2025 Soren Stoutner <soren@stoutner.com>
This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
+<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+<https://www.gnu.org/licenses/why-not-lgpl.html>.
<?xml version="1.0" ?>
<!--
- SPDX-License-Identifier: GPL-3.0-or-later
- SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
+ SPDX-License-Identifier: GFDL-1.3-no-invariants-or-later
+ SPDX-FileCopyrightText: 2023-2025 Soren Stoutner <soren@stoutner.com>
This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
- This program is free software: you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation, either version 3 of the License, or (at your option) any later
- version.
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.3
+ or any later version published by the Free Software Foundation;
+ with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see <https://www.gnu.org/licenses/>. -->
+ You should have received a copy of the GNU Free Documentation License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. -->
<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" "dtd/kdedbx45.dtd" [
<!-- Privacy Browser’s name -->
</authorgroup>
<copyright>
- <year>2016-2017, 2021-2024</year>
+ <year>2016-2017, 2021-2025</year>
<holder>&Soren.Stoutner;</holder>
</copyright>
<title>Credits and License</title>
<para>
- Privacy Browser PC copyright 2016-2017, 2021-2024 Soren Stoutner <ulink url="mailto:soren@stoutner.com">soren@stoutner.com</ulink>.
+ Privacy Browser PC copyright 2016-2017, 2021-2025 Soren Stoutner <ulink url="mailto:soren@stoutner.com">soren@stoutner.com</ulink>.
</para>
<!-- Program. -->
# SPDX-License-Identifier: GPL-3.0-or-later
-# SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
+# SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
#
# This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
#
# Install Privacy Browser according to the instructions in the desktop file, specifying the permissions.
install(PROGRAMS com.stoutner.privacybrowser.desktop DESTINATION ${KDE_INSTALL_APPDIR} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-# Install the metadata file.
-install(FILES com.stoutner.privacybrowser.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
+# Install the metainfo file.
+install(FILES com.stoutner.privacybrowser.metainfo.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
# Install the notifyrc file.
install(FILES privacybrowser.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFYRCDIR})
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
- SPDX-License-Identifier: GPL-3.0-or-later
- SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
-
- This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
-
- This program is free software: you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation, either version 3 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see <https://www.gnu.org/licenses/>. -->
-
-<!-- The XML specification can be found at <https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html>. -->
-<!-- Information about validation tags can be found at <https://www.freedesktop.org/software/appstream/docs/chap-Validation.html>. -->
-<!-- The file can be validated using `appstreamcli validate com.stoutner.privacybrowser.appdata.xml`. -->
-<component type="desktop-application">
- <id>com.stoutner.privacybrowser</id>
-
- <metadata_license>GFDL-1.3</metadata_license>
-
- <name>Privacy Browser</name>
-
- <summary>A web browser that respects your privacy</summary>
-
- <description>
- <p>
- Privacy Browser is a web browser based on Qt WebEngine with a focus on privacy and security.
- Features like JavaScript and cookies are disabled by default but are easy to automatically enable on-the-fly or by domain.
- </p>
- </description>
-
- <project_license>GPL-3.0-or-later</project_license>
-
- <developer id="com.stoutner">
- <name>Soren Stoutner</name>
- </developer>
-
- <categories>
- <category>Network</category>
- <category>WebBrowser</category>
- </categories>
-
- <url type="homepage">https://www.stoutner.com/privacy-browser-pc/</url>
- <url type="bugtracker">https://redmine.stoutner.com/projects/privacy-browser-pc/issues</url>
- <url type="donation">https://www.stoutner.com/donations/</url>
- <url type="contact">https://redmine.stoutner.com/projects/privacy-browser-pc/boards</url>
-
- <launchable type="desktop-id">com.stoutner.privacybrowser.desktop</launchable>
-
- <releases>
- <release version="0.7" date="2024-12-11">
- <description>
- <p>Migrate to KDE 6.</p>
- <p>Colorize the requests counter background.</p>
- <p>Restore the current URL text when switching tabs.</p>
- <p>Update the zoom icons.</p>
- <p>Adjust some of the default dialog sizes to be smaller.</p>
- <p>Update the domains database in all windows when it changes.</p>
- <p>Add an option to delete all domains settings at once.</p>
- </description>
- </release>
-
- <release version="0.6.2" date="2024-09-30">
- <description>
- <p>Fix a PIE/PIC crash in the Ubuntu packages (hopefully).</p>
- <p>Add entries to open in other browsers to the window and context menus.</p>
- <p>Make the Requests Detail dialog scrollable.</p>
- </description>
- </release>
-
- <release version="0.6.1" date="2024-08-21">
- <description>
- <p>Fix the domain settings dialog not fitting on small screens.</p>
- <p>Apply domain settings even when the main URL is explicitly allowed by the filter lists.</p>
- </description>
- </release>
-
- <release version="0.6" date="2024-07-15">
- <description>
- <p>Add filter lists.</p>
- <p>Add URL syntax highlighting.</p>
- <p>Add a DevTools interface.</p>
- <p>Implement opening and saving of MHT web archives.</p>
- <p>Handle HTTP authentication.</p>
- <p>Remember the download directory.</p>
- <p>Update bookmarks in all windows when modified.</p>
- <p>Display Unicode URLs in Punycode.</p>
- <p>Multiple small improvements to the code and the user experience.</p>
- </description>
- </release>
-
- <release version="0.5" date="2023-10-12">
- <description>
- <p>Add bookmarks.</p>
- <p>Add zoom controls to the status bar and a default zoom shortcut.</p>
- <p>Add keyboard shortcuts for the URL toolbar actions.</p>
- <p>Add an action to view page source.</p>
- <p>Change the domain settings combo boxes to list enabled above disabled.</p>
- <p>File downloads can now show the size before the download begins.</p>
- <p>Add PIE (Position Independent Executable) compiler flags.</p>
- <p>Fix a bug that sometimes allowed multiple domain settings to be created.</p>
- <p>Fix the download notification not being cleared on Xfce.</p>
- </description>
- </release>
-
- <release version="0.4" date="2023-06-13">
- <description>
- <p>Add a setting to control spatial navigation.</p>
- <p>Add an action to reload and bypass cache.</p>
- <p>Fix a crash if one Privacy Browser window is closed while a tab within it is loading.</p>
- <p>Add keyboard+click commands to the Handbook.</p>
- </description>
- </release>
-
- <release version="0.3" date="2023-05-08">
- <description>
- <p>Add the changelog to the Handbook.</p>
- <p>Add the missing current domain settings icon on Gnome and Xfce.</p>
- <p>Make changes to build on Guix.</p>
- </description>
- </release>
-
- <release version="0.2" date="2023-04-17">
- <description>
- <p>Fix a crash on GNOME when downloading a file with local storage disabled.</p>
- <p>Fix problems with missing icons on GNOME.</p>
- <p>Display an animated favorite icon while a webpage is loading.</p>
- <p>Fix the Handbook on non-KDE systems.</p>
- <p>Change the order of entries in the WebEngine context menu.</p>
- <p>Make spellcheck languages easier to click on.</p>
- <p>Only generate a HTTP ping dialog if the request is made by the current tab.</p>
- <p>Add a section to the Handbook about HTTP pings.</p>
- </description>
- </release>
-
- <release version="0.1" date="2023-03-11">
- <description>
- <p>Initial release.</p>
- </description>
- </release>
- </releases>
-
- <provides>
- <binary>privacybrowser</binary>
- </provides>
-
- <screenshots>
- <screenshot type="default">
- <image type="source">https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blob_plain;f=doc/privacybrowser-window.png;hb=HEAD</image>
- <caption>The main Privacy Browser window.</caption>
- </screenshot>
- </screenshots>
-
- <update_contact>soren@stoutner.com</update_contact>
-
- <!-- This content rating was generated from <https://hughsie.github.io/oars/generate.html>. -->
- <content_rating type="oars-1.0" />
-</component>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ SPDX-License-Identifier: GPL-3.0-or-later
+ SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
+
+ This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
+
+ This program is free software: you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation, either version 3 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <https://www.gnu.org/licenses/>. -->
+
+<!-- The XML specification can be found at <https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html>. -->
+<!-- Information about validation tags can be found at <https://www.freedesktop.org/software/appstream/docs/chap-Validation.html>. -->
+<!-- The file can be validated using `appstreamcli validate com.stoutner.privacybrowser.appdata.xml`. -->
+<component type="desktop-application">
+ <id>com.stoutner.privacybrowser</id>
+
+ <metadata_license>GFDL-1.3</metadata_license>
+
+ <name>Privacy Browser</name>
+
+ <summary>A web browser that respects your privacy</summary>
+
+ <description>
+ <p>
+ Privacy Browser is a web browser based on Qt WebEngine with a focus on privacy and security.
+ Features like JavaScript and cookies are disabled by default but are easy to automatically enable on-the-fly or by domain.
+ </p>
+ </description>
+
+ <project_license>GPL-3.0-or-later</project_license>
+
+ <developer id="com.stoutner">
+ <name>Soren Stoutner</name>
+ </developer>
+
+ <categories>
+ <category>Network</category>
+ <category>WebBrowser</category>
+ </categories>
+
+ <url type="homepage">https://www.stoutner.com/privacy-browser-pc/</url>
+ <url type="bugtracker">https://redmine.stoutner.com/projects/privacy-browser-pc/issues</url>
+ <url type="donation">https://www.stoutner.com/donations/</url>
+ <url type="contact">https://redmine.stoutner.com/projects/privacy-browser-pc/boards</url>
+
+ <launchable type="desktop-id">com.stoutner.privacybrowser.desktop</launchable>
+
+ <releases>
+ <release version="0.7" date="2024-12-11">
+ <description>
+ <p>Migrate to KDE 6.</p>
+ <p>Colorize the requests counter background.</p>
+ <p>Restore the current URL text when switching tabs.</p>
+ <p>Update the zoom icons.</p>
+ <p>Adjust some of the default dialog sizes to be smaller.</p>
+ <p>Update the domains database in all windows when it changes.</p>
+ <p>Add an option to delete all domains settings at once.</p>
+ </description>
+ </release>
+
+ <release version="0.6.2" date="2024-09-30">
+ <description>
+ <p>Fix a PIE/PIC crash in the Ubuntu packages (hopefully).</p>
+ <p>Add entries to open in other browsers to the window and context menus.</p>
+ <p>Make the Requests Detail dialog scrollable.</p>
+ </description>
+ </release>
+
+ <release version="0.6.1" date="2024-08-21">
+ <description>
+ <p>Fix the domain settings dialog not fitting on small screens.</p>
+ <p>Apply domain settings even when the main URL is explicitly allowed by the filter lists.</p>
+ </description>
+ </release>
+
+ <release version="0.6" date="2024-07-15">
+ <description>
+ <p>Add filter lists.</p>
+ <p>Add URL syntax highlighting.</p>
+ <p>Add a DevTools interface.</p>
+ <p>Implement opening and saving of MHT web archives.</p>
+ <p>Handle HTTP authentication.</p>
+ <p>Remember the download directory.</p>
+ <p>Update bookmarks in all windows when modified.</p>
+ <p>Display Unicode URLs in Punycode.</p>
+ <p>Multiple small improvements to the code and the user experience.</p>
+ </description>
+ </release>
+
+ <release version="0.5" date="2023-10-12">
+ <description>
+ <p>Add bookmarks.</p>
+ <p>Add zoom controls to the status bar and a default zoom shortcut.</p>
+ <p>Add keyboard shortcuts for the URL toolbar actions.</p>
+ <p>Add an action to view page source.</p>
+ <p>Change the domain settings combo boxes to list enabled above disabled.</p>
+ <p>File downloads can now show the size before the download begins.</p>
+ <p>Add PIE (Position Independent Executable) compiler flags.</p>
+ <p>Fix a bug that sometimes allowed multiple domain settings to be created.</p>
+ <p>Fix the download notification not being cleared on Xfce.</p>
+ </description>
+ </release>
+
+ <release version="0.4" date="2023-06-13">
+ <description>
+ <p>Add a setting to control spatial navigation.</p>
+ <p>Add an action to reload and bypass cache.</p>
+ <p>Fix a crash if one Privacy Browser window is closed while a tab within it is loading.</p>
+ <p>Add keyboard+click commands to the Handbook.</p>
+ </description>
+ </release>
+
+ <release version="0.3" date="2023-05-08">
+ <description>
+ <p>Add the changelog to the Handbook.</p>
+ <p>Add the missing current domain settings icon on Gnome and Xfce.</p>
+ <p>Make changes to build on Guix.</p>
+ </description>
+ </release>
+
+ <release version="0.2" date="2023-04-17">
+ <description>
+ <p>Fix a crash on GNOME when downloading a file with local storage disabled.</p>
+ <p>Fix problems with missing icons on GNOME.</p>
+ <p>Display an animated favorite icon while a webpage is loading.</p>
+ <p>Fix the Handbook on non-KDE systems.</p>
+ <p>Change the order of entries in the WebEngine context menu.</p>
+ <p>Make spellcheck languages easier to click on.</p>
+ <p>Only generate a HTTP ping dialog if the request is made by the current tab.</p>
+ <p>Add a section to the Handbook about HTTP pings.</p>
+ </description>
+ </release>
+
+ <release version="0.1" date="2023-03-11">
+ <description>
+ <p>Initial release.</p>
+ </description>
+ </release>
+ </releases>
+
+ <provides>
+ <binary>privacybrowser</binary>
+ </provides>
+
+ <screenshots>
+ <screenshot type="default">
+ <image type="source">https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blob_plain;f=doc/privacybrowser-window.png;hb=HEAD</image>
+ <caption>The main Privacy Browser window.</caption>
+ </screenshot>
+ </screenshots>
+
+ <update_contact>soren@stoutner.com</update_contact>
+
+ <!-- This content rating was generated from <https://hughsie.github.io/oars/generate.html>. -->
+ <content_rating type="oars-1.0" />
+</component>
/* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
*
// Populate the zoom factor combo box.
zoomFactorComboBoxPointer->setCurrentIndex(zoomFactorComboBoxIndex);
+ // Get the combo box palette.
+ QPalette comboBoxPalette = zoomFactorComboBoxPointer->palette();
+
+ // Get the combo box window color.
+ QColor comboBoxWindowColor = comboBoxPalette.color(QPalette::Window);
+
+ // Set the combo box window color back to the palette. This makes the system think the palette has changed.
+ comboBoxPalette.setColor(QPalette::Window, comboBoxWindowColor);
+
+ // Explicitly set the combo box palette. Because the system thinks the palette has been changed, and because the combo box palette is being explicitly set,
+ // the system will not propagate the highlighted palette from the widget pointer palette down to the combo box. <https://redmine.stoutner.com/issues/1252>
+ zoomFactorComboBoxPointer->setPalette(comboBoxPalette);
+
// Populate the custom zoom factor spin box according to the zoom factor combo box.
if (zoomFactorComboBoxIndex == 0) // System default zoom factor is selected.
{
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
- Copyright © 2016-2017,2021-2022 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2016-2017, 2021-2022 Soren Stoutner <soren@stoutner.com>.
This file is derived from `security` and `language`, which are part of the Android Material icon set. They are released under the Apache License 2.0. <https://fonts.google.com/icons>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
- Copyright © 2016-2017,2021-2022 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2016-2017, 2021-2022 Soren Stoutner <soren@stoutner.com>.
This file is derived from `security` and `language`, which are part of the Android Material icon set. They are released under the Apache License 2.0. <https://fonts.google.com/icons>
</svg>
<!--
- Copyright 2016-2017,2021-2023 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2016-2017, 2021-2023 Soren Stoutner <soren@stoutner.com>.
This file is derived from `security` and `language`, which are part of the Android Material icon set. They are released under the Apache License 2.0. <https://fonts.google.com/icons>
</svg>
<!--
- Copyright 2016-2017,2021-2023 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2016-2017, 2021-2023 Soren Stoutner <soren@stoutner.com>.
This file is derived from `security` and `language`, which are part of the Android Material icon set. They are released under the Apache License 2.0. <https://fonts.google.com/icons>
/* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
*
{
case QWebEngineUrlRequestInfo::NavigationTypeLink:
case QWebEngineUrlRequestInfo::NavigationTypeTyped:
- case QWebEngineUrlRequestInfo::NavigationTypeBackForward:
- // case QWebEngineUrlRequestInfo::NavigationTypeReload: This can be uncommented once https://redmine.stoutner.com/issues/821 has been fixed.
+ case QWebEngineUrlRequestInfo::NavigationTypeFormSubmitted:
case QWebEngineUrlRequestInfo::NavigationTypeRedirect:
+ case QWebEngineUrlRequestInfo::NavigationTypeOther:
+ {
+ // Only check the hosts if the main URL is changing.
+ if (urlRequestInfo.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame)
+ {
+ // Get the request URL.
+ QUrl requestUrl = urlRequestInfo.requestUrl();
+
+ // Reapply the domain settings if the host is changing.
+ if (privacyWebEngineViewPointer->currentHost != requestUrl.host())
+ {
+ // Apply domain settings, after which the request will be loaded. `false` indicates that history is not being navigated.
+ Q_EMIT applyDomainSettings(requestUrl, false);
+
+ // Block this copy of the request.
+ urlRequestInfo.block(true);
+ }
+ }
+
+ break;
+ }
+
+ case QWebEngineUrlRequestInfo::NavigationTypeBackForward:
{
// Only check the hosts if the main URL is changing.
if (urlRequestInfo.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame)
{
- // Get the hosts.
- QString requestingHost = urlRequestInfo.initiator().host();
- QString requestedHost = urlRequestInfo.requestUrl().host();
+ // Get the request URL.
+ QUrl requestUrl = urlRequestInfo.requestUrl();
// Reapply the domain settings if the host is changing.
- if (requestingHost != requestedHost)
- Q_EMIT applyDomainSettings(requestedHost);
+ if (privacyWebEngineViewPointer->currentHost != requestUrl.host())
+ {
+ // Apply domain settings, after which the request will be loaded. `true` indicates that history is being navigated.
+ Q_EMIT applyDomainSettings(requestUrl, true);
+ }
}
break;
/* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
*
Q_SIGNALS:
// The signals.
- void applyDomainSettings(const QString &hostname) const;
+ void applyDomainSettings(const QUrl &url, const bool navigatingHistory) const;
void displayHttpPingDialog(const QString &httpPingUrl) const;
void newMainFrameResource() const;
void requestProcessed(RequestStruct *requestStruct) const;
/* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
*
// Populate additional about data info.
aboutData.setBugAddress("https://redmine.stoutner.com/projects/privacy-browser-pc/issues");
- aboutData.setCopyrightStatement(i18nc("Copyright", "Copyright 2016-2017, 2021-2024 Soren Stoutner <soren@stoutner.com>"));
+ aboutData.setCopyrightStatement(i18nc("Copyright", "Copyright 2016-2017, 2021-2025 Soren Stoutner <soren@stoutner.com>"));
aboutData.setDesktopFileName(QLatin1String("com.stoutner.privacybrowser"));
aboutData.setHomepage(QLatin1String("https://www.stoutner.com/privacy-browser-pc/"));
//aboutData.setLicense(KAboutLicense::GPL_V3, KAboutLicense::OrLaterVersions); <https://redmine.stoutner.com/issues/822>
/* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
*
webEngineProfilePointer->setUrlRequestInterceptor(urlRequestInterceptorPointer);
// Connect the URL request interceptor signals.
- connect(urlRequestInterceptorPointer, SIGNAL(applyDomainSettings(const QString&)), this, SLOT(applyDomainSettingsWithoutReloading(const QString&)));
+ connect(urlRequestInterceptorPointer, SIGNAL(applyDomainSettings(const QUrl&, const bool)), this, SLOT(applyDomainSettings(const QUrl&, const bool)));
connect(urlRequestInterceptorPointer, SIGNAL(newMainFrameResource()), this, SLOT(clearRequestsList()));
connect(urlRequestInterceptorPointer, SIGNAL(displayHttpPingDialog(const QString&)), this, SLOT(displayHttpPingDialog(const QString&)));
connect(urlRequestInterceptorPointer, SIGNAL(requestProcessed(RequestStruct*)), this, SLOT(storeRequest(RequestStruct*)));
Q_EMIT numberOfCookiesChanged(cookieListPointer->size());
}
-void PrivacyWebEngineView::applyDomainSettingsWithoutReloading(const QString &hostname)
+void PrivacyWebEngineView::applyDomainSettings(const QUrl &newUrl, const bool navigatingHistory)
{
- // Apply the domain settings `false` does not reload the website.
- applyDomainSettings(hostname, false);
-}
+ // Store the current host.
+ currentHost = newUrl.host();
-void PrivacyWebEngineView::applyDomainSettings(const QString &hostname, const bool reloadWebsite)
-{
- // Get the record for the hostname.
- QSqlQuery domainQuery = DomainsDatabase::getDomainQuery(hostname);
+ // Create a user agent changed tracker.
+ bool userAgentChanged = false;
- // Check if the hostname has domain settings.
- if (domainQuery.isValid()) // The hostname has domain settings.
+ // Get the record for the current host.
+ QSqlQuery domainQuery = DomainsDatabase::getDomainQuery(currentHost);
+
+ // Check if the current host has domain settings.
+ if (domainQuery.isValid()) // The current host has domain settings.
{
// Store the domain settings name.
domainSettingsName = domainQuery.value(DomainsDatabase::DOMAIN_NAME).toString();
case (DomainsDatabase::DISABLED): webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, false); break;
}
- // Set the user agent.
- webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getResultingDomainSettingsUserAgent(domainQuery.value(DomainsDatabase::USER_AGENT).toString()));
+ // Get the domain settings user agent.
+ QString domainSettingsUserAgent = UserAgentHelper::getResultingDomainSettingsUserAgent(domainQuery.value(DomainsDatabase::USER_AGENT).toString());
+
+ // Determine if the user agent is changing.
+ if (webEngineProfilePointer->httpUserAgent() != domainSettingsUserAgent)
+ userAgentChanged = true;
+
+ // Set the user agent. Setting the user agent, even if it isn't changing, causes the pre-rendered page to enter a locked state where reload doesn't work.
+ webEngineProfilePointer->setHttpUserAgent(domainSettingsUserAgent);
// Set the UltraPrivacy status.
switch (domainQuery.value(DomainsDatabase::ULTRAPRIVACY).toInt())
defaultZoomFactor = Settings::zoomFactor();
}
}
- else // The hostname does not have domain settings.
+ else // The current host does not have domain settings.
{
// Reset the domain settings name.
domainSettingsName = QLatin1String("");
// Set DOM storage. In QWebEngineSettings it is called Local Storage.
webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, Settings::domStorageEnabled());
- // Set the user agent.
- webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getUserAgentFromDatabaseName(Settings::userAgent()));
+ // Get the default user agent.
+ QString defaultUserAgent = UserAgentHelper::getUserAgentFromDatabaseName(Settings::userAgent());
+
+ // Determine if the user agent is changing.
+ if (webEngineProfilePointer->httpUserAgent() != defaultUserAgent)
+ userAgentChanged = true;
+
+ // Set the user agent. Setting the user agent, even if it isn't changing, causes the pre-rendered page to enter a locked state where reload doesn't work.
+ webEngineProfilePointer->setHttpUserAgent(defaultUserAgent);
// Set the status for each filter list.
ultraPrivacyEnabled = Settings::ultraPrivacyEnabled();
// Set the current zoom factor.
setZoomFactor(defaultZoomFactor);
- // Reload the website if requested.
- if (reloadWebsite)
- reload();
-
// Reset the HTTP authentication dialog counter.
httpAuthenticationDialogsDisplayed = 0;
// Update the UI.
Q_EMIT updateUi(this);
+
+ // Reload the URL.
+ // This works around a bug in Qt WebEngine that causes massive problems when the user agent is changed after the page has started pre-rendering. <https://redmine.stoutner.com/issues/821>
+ if (navigatingHistory)
+ {
+ // Get a handle for the WebEngine history.
+ QWebEngineHistory *webEngineHistoryPointer = history();
+
+ // Navigate the history according to the status of the user agent.
+ if (userAgentChanged) // The user agent changed.
+ {
+ // Go back once. This current navigation will fail, but the next one will succeed.
+ //back();
+
+ if (webEngineHistoryPointer->canGoBack() && (newUrl == webEngineHistoryPointer->backItem().url()))
+ {
+ // Go back twice. The first one will fail, but the second will succeed.
+ back();
+ }
+ else
+ {
+ // Go forward twice. The first one will fail, but the second will succeed.
+ forward();
+ }
+ }
+ else // The user agent did not change.
+ {
+ // The WebEngine history will think it has loaded the final URL, and will be in the correct location, but it will have been interrupted and reloaded the original URL.
+ // The solution is to direct the WebEngine history to offset one and then return, which will actually load the correct URL because `applyDomainSettings` will not be triggered.
+ if (webEngineHistoryPointer->canGoForward())
+ {
+ // Go forward and back one.
+ forward();
+ back();
+ }
+ else
+ {
+ // Go back and forward one.
+ back();
+ forward();
+ }
+ }
+ } else {
+ // Load the new URL again.
+ load(newUrl);
+ }
}
void PrivacyWebEngineView::clearRequestsList()
Q_EMIT requestBlocked(blockedRequestsVector);
}
-void PrivacyWebEngineView::contextMenuEvent(QContextMenuEvent *contextMenuEvent) {
+void PrivacyWebEngineView::contextMenuEvent(QContextMenuEvent *contextMenuEvent)
+{
// Get a handle for the WebEngine page.
QWebEnginePage *webEnginePagePointer = page();
contextMenu->popup(contextMenuEvent->globalPos());
}
-QWebEngineView* PrivacyWebEngineView::createWindow(QWebEnginePage::WebWindowType webWindowType) {
+QWebEngineView* PrivacyWebEngineView::createWindow(QWebEnginePage::WebWindowType webWindowType)
+{
// Get a handle for the browser window.
BrowserWindow *browserWindowPointer = qobject_cast<BrowserWindow*>(window());
// Store the new URL string (which changes when a new page is loaded as the current URL text. This is important when loading a new tab from a link. <https://redmine.stoutner.com/issues/1228>
currentUrlText = newUrl.toString();
}
+
/* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
*
// The public variables.
QVector<int> blockedRequestsVector = {0, 0, 0, 0, 0, 0};
std::list<QNetworkCookie> *cookieListPointer = new std::list<QNetworkCookie>;
+ QString currentHost = QLatin1String("");
QString currentUrlText = QLatin1String("");
double defaultZoomFactor = 1.00;
QString domainSettingsName = QLatin1String("");
bool ultraListEnabled = true;
bool ultraPrivacyEnabled = true;
- // The public functions.
- void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
-
Q_SIGNALS:
// The signals.
void numberOfCookiesChanged(const int numberOfCookies) const;
public Q_SLOTS:
// The public slots.
void addCookieToList(const QNetworkCookie &cookie) const;
+ void applyDomainSettings(const QUrl &newUrl, const bool navigatingHistory);
void removeCookieFromList(const QNetworkCookie &cookie) const;
private Q_SLOTS:
// The private slots.
- void applyDomainSettingsWithoutReloading(const QString &hostname);
void clearRequestsList();
void displayHttpPingDialog(const QString &httpPingUrl) const;
void handleAuthenticationRequest(const QUrl &requestUrl, QAuthenticator *authenticatorPointer);
/* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
*
// Get the WebEngine view pointer.
PrivacyWebEngineView *privacyWebEngineViewPointer = qTabWidgetPointer->widget(i)->findChild<PrivacyWebEngineView *>();
- // Apply the domain settings settings to each page.
- privacyWebEngineViewPointer->applyDomainSettings(privacyWebEngineViewPointer->url().host(), true);
+ // Apply the domain settings settings to each page. `false` indicates that history is not being navigated.
+ privacyWebEngineViewPointer->applyDomainSettings(privacyWebEngineViewPointer->url(), false);
}
}