target_sources(privacy-browser PRIVATE
main.cpp
MouseEventFilter.cpp
- UrlRequestInterceptor.cpp
)
# Add the Qt logging category. This will create the `debug.h` header file.
# Add the subdirectories.
add_subdirectory(dialogs)
add_subdirectory(helpers)
+add_subdirectory(interceptors)
add_subdirectory(ui.rc)
add_subdirectory(views)
add_subdirectory(windows)
+++ /dev/null
-/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
- *
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
- *
- * Privacy Browser PC 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.
- *
- * Privacy Browser PC 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 Privacy Browser PC. If not, see <http://www.gnu.org/licenses/>.
- */
-
-// Application headers.
-#include "UrlRequestInterceptor.h"
-
-// The default constructor.
-UrlRequestInterceptor::UrlRequestInterceptor(QObject *parentObjectPointer) : QWebEngineUrlRequestInterceptor(parentObjectPointer) {}
-
-void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlRequestInfo)
-{
- // Handle the request according to the navigation type.
- switch (urlRequestInfo.navigationType())
- {
- case QWebEngineUrlRequestInfo::NavigationTypeLink:
- case QWebEngineUrlRequestInfo::NavigationTypeTyped:
- {
- // 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();
-
- // Reapply the domain settings if the host is changing.
- if (requestingHost != requestedHost)
- {
- emit applyDomainSettings(requestedHost);
- }
- }
-
- break;
- }
-
- default:
- // Do nothing.
- break;
- }
-
- // Handle the request according to the resource type.
- switch (urlRequestInfo.resourceType())
- {
- // A naughty HTTP ping request.
- case QWebEngineUrlRequestInfo::ResourceTypePing:
- {
- // Block HTTP ping requests.
- urlRequestInfo.block(true);
-
- break;
- }
-
- default:
- {
- // Do nothing.
- break;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
- *
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
- *
- * Privacy Browser PC 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.
- *
- * Privacy Browser PC 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 Privacy Browser PC. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef URLREQUESTINTERCEPTOR_H
-#define URLREQUESTINTERCEPTOR_H
-
-// Qt framework headers.
-#include <QtWebEngineCore>
-
-class UrlRequestInterceptor : public QWebEngineUrlRequestInterceptor
-{
- // Include the Q_OBJECT macro.
- Q_OBJECT
-
-public:
- // The default constructor.
- UrlRequestInterceptor(QObject *parentObjectPointer = 0);
-
- // The public functions.
- void interceptRequest(QWebEngineUrlRequestInfo &urlRequestInfo) override;
-
-signals:
- // The signals.
- void applyDomainSettings(const QString hostname) const;
-};
-#endif
--- /dev/null
+# Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+#
+# This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+#
+# Privacy Browser PC 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.
+#
+# Privacy Browser PC 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 Privacy Browser PC. If not, see <http://www.gnu.org/licenses/>.
+
+
+# List the sources to include in the executable.
+target_sources(privacy-browser PRIVATE
+ UrlRequestInterceptor.cpp
+)
--- /dev/null
+/*
+ * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ *
+ * Privacy Browser PC 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.
+ *
+ * Privacy Browser PC 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 Privacy Browser PC. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// Application headers.
+#include "UrlRequestInterceptor.h"
+
+// The default constructor.
+UrlRequestInterceptor::UrlRequestInterceptor(QObject *parentObjectPointer) : QWebEngineUrlRequestInterceptor(parentObjectPointer) {}
+
+void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlRequestInfo)
+{
+ // Handle the request according to the navigation type.
+ switch (urlRequestInfo.navigationType())
+ {
+ case QWebEngineUrlRequestInfo::NavigationTypeLink:
+ case QWebEngineUrlRequestInfo::NavigationTypeTyped:
+ case QWebEngineUrlRequestInfo::NavigationTypeBackForward:
+ case QWebEngineUrlRequestInfo::NavigationTypeRedirect:
+ {
+ // 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();
+
+ // Reapply the domain settings if the host is changing.
+ if (requestingHost != requestedHost)
+ {
+ emit applyDomainSettings(requestedHost);
+ }
+ }
+
+ break;
+ }
+
+ default:
+ // Do nothing.
+ break;
+ }
+
+ // Handle the request according to the resource type.
+ switch (urlRequestInfo.resourceType())
+ {
+ // A naughty HTTP ping request.
+ case QWebEngineUrlRequestInfo::ResourceTypePing:
+ {
+ // Block HTTP ping requests.
+ urlRequestInfo.block(true);
+
+ break;
+ }
+
+ default:
+ {
+ // Do nothing.
+ break;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ *
+ * Privacy Browser PC 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.
+ *
+ * Privacy Browser PC 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 Privacy Browser PC. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef URLREQUESTINTERCEPTOR_H
+#define URLREQUESTINTERCEPTOR_H
+
+// Qt framework headers.
+#include <QtWebEngineCore>
+
+class UrlRequestInterceptor : public QWebEngineUrlRequestInterceptor
+{
+ // Include the Q_OBJECT macro.
+ Q_OBJECT
+
+public:
+ // The default constructor.
+ UrlRequestInterceptor(QObject *parentObjectPointer = 0);
+
+ // The public functions.
+ void interceptRequest(QWebEngineUrlRequestInfo &urlRequestInfo) override;
+
+signals:
+ // The signals.
+ void applyDomainSettings(const QString hostname) const;
+};
+#endif
#include "MouseEventFilter.h"
#include "Settings.h"
#include "ui_BrowserView.h"
-#include "UrlRequestInterceptor.h"
#include "helpers/DomainsDatabaseHelper.h"
#include "helpers/SearchEngineHelper.h"
#include "helpers/UserAgentHelper.h"
+#include "interceptors/UrlRequestInterceptor.h"
#include "windows/BrowserWindow.h"
// Qt framework headers.
// Set the user agent.
webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getResultingDomainSettingsUserAgent(domainRecord.field(DomainsDatabaseHelper::USER_AGENT).value().toString()));
- // Check if a custom zoom factor is set. This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
+ // Check if a custom zoom factor is set.
if (domainRecord.field(DomainsDatabaseHelper::ZOOM_FACTOR).value().toInt())
{
// Store the current zoom factor.
currentZoomFactor = Settings::zoomFactor();
}
- // Set the zoom factor.
+ // Set the zoom factor. The use of `currentZoomFactor` can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
webEngineViewPointer->setZoomFactor(currentZoomFactor);
// Apply the domain settings palette to the URL line edit.
// Set the user agent.
webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getUserAgentFromDatabaseName(Settings::userAgent()));
- // Store the current zoom factor.
+ // Store the current zoom factor. This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
currentZoomFactor = Settings::zoomFactor();
// Set the zoom factor.
- webEngineViewPointer->setZoomFactor(currentZoomFactor);
+ webEngineViewPointer->setZoomFactor(Settings::zoomFactor());
// Apply the no domain settings palette to the URL line edit.
emit updateDomainSettingsIndicator(false);
webEngineViewPointer->reload();
}
-void BrowserView::applyOnTheFlyZoomFactor(const double &zoomFactor) const
+// This can be const once <https://redmine.stoutner.com/issues/799> has been resolved.
+void BrowserView::applyOnTheFlyZoomFactor(const double &zoomFactor)
{
+ // Update the current zoom factor. This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
+ currentZoomFactor = zoomFactor;
+
// Set the zoom factor.
webEngineViewPointer->setZoomFactor(zoomFactor);
}
explicit BrowserView(QWidget *parent);
// The public functions.
- void applyOnTheFlyZoomFactor(const double &zoomFactor) const;
+ void applyOnTheFlyZoomFactor(const double &zoomFactor);
void loadInitialWebsite();
signals:
void BrowserWindow::updateOnTheFlyZoomFactor(const double &zoomFactor)
{
// Set the current zoom factor.
- currentZoomFactor = Settings::zoomFactor();
+ currentZoomFactor = zoomFactor;
// Update the zoom factor action text, formatting the double with 2 decimal places.
zoomFactorActionPointer->setText(ki18nc("@action", "Zoom Factor - %1").subs(zoomFactor, 0, '0', 2).toString());