]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Fix HTTP authentication dialogs displaying indefinitely. https://redmine.stoutner...
authorSoren Stoutner <soren@stoutner.com>
Fri, 22 Mar 2024 20:31:39 +0000 (13:31 -0700)
committerSoren Stoutner <soren@stoutner.com>
Fri, 22 Mar 2024 20:31:39 +0000 (13:31 -0700)
src/widgets/PrivacyWebEngineView.cpp
src/widgets/PrivacyWebEngineView.h
src/widgets/TabWidget.cpp

index 6080288e4f5b4238404e8e13795e305f2fd9c65e..42c331fec5340447ed05da6433a6475db30f7de4 100644 (file)
@@ -221,6 +221,9 @@ void PrivacyWebEngineView::applyDomainSettings(const QString &hostname, const bo
     if (reloadWebsite)
         reload();
 
+    // Reset the HTTP authentication dialog counter.
+    httpAuthenticationDialogsDisplayed = 0;
+
     // Update the UI.
     emit updateUi(this);
 }
@@ -305,11 +308,17 @@ void PrivacyWebEngineView::displayHttpPingDialog(const QString &httpPingUrl) con
 
 void PrivacyWebEngineView::handleAuthenticationRequest(const QUrl &requestUrl, QAuthenticator *authenticatorPointer)
 {
-    // Instantiate an HTTP authentication dialog.
-    HttpAuthenticationDialog *httpAuthenticationDialogPointer = new HttpAuthenticationDialog(parentWidget(), requestUrl, authenticatorPointer);
+    // Only display the HTTP authentication dialog if it hasn't already been displayed three times for this URL.
+    if (httpAuthenticationDialogsDisplayed < 3) {
+        // Increment the HTTP authentication dialog display counter.
+        ++httpAuthenticationDialogsDisplayed;
+
+        // Instantiate an HTTP authentication dialog.
+        HttpAuthenticationDialog *httpAuthenticationDialogPointer = new HttpAuthenticationDialog(parentWidget(), requestUrl, authenticatorPointer);
 
-    // Display the dialog.  This must be `exec()` instead of `show()` so that the website doesn't proceed before populating the authentication pointer.
-    httpAuthenticationDialogPointer->exec();
+        // Display the dialog.  This must be `exec()` instead of `show()` so that the website doesn't proceed before populating the authentication pointer.
+        httpAuthenticationDialogPointer->exec();
+    }
 }
 
 void PrivacyWebEngineView::removeCookieFromList(const QNetworkCookie &cookie) const
index 4f621ce86097009c2b680d668285f35c1b3b69d3..95cc69f5b67d8397b030c27a6f987c5d8e7fc715 100644 (file)
@@ -46,6 +46,7 @@ public:
     bool findCaseSensitive = false;
     QString findString = QLatin1String("");
     QWebEngineFindTextResult findTextResult = QWebEngineFindTextResult();
+    int httpAuthenticationDialogsDisplayed = 0;
     bool isLoading = false;
     int loadProgressInt = -1;
     bool localStorageEnabled = false;
index bdc541c6bbb187877ff137aac6d2d477c171711a..f65c79ea2177b404eef157f441245dab7175ed73 100644 (file)
@@ -906,6 +906,9 @@ void TabWidget::printWebpage(QPrinter *printerPointer) const
 
 void TabWidget::refresh() const
 {
+    // Reset the HTTP authentication dialog counter.
+    currentPrivacyWebEngineViewPointer->httpAuthenticationDialogsDisplayed = 0;
+
     // Reload the website.
     currentPrivacyWebEngineViewPointer->reload();
 }