Use an off-the-record profile. https://redmine.stoutner.com/issues/825
authorSoren Stoutner <soren@stoutner.com>
Mon, 11 Apr 2022 22:07:58 +0000 (15:07 -0700)
committerSoren Stoutner <soren@stoutner.com>
Mon, 11 Apr 2022 22:07:58 +0000 (15:07 -0700)
src/views/BrowserView.cpp

index edcd26c0f42276cd77ceb88efc1b65adcdc131b4..fb2473a6977c406deb3221bcadac4ca5394409d9 100644 (file)
@@ -43,10 +43,17 @@ BrowserView::BrowserView(QWidget *parent) : QWidget(parent)
     // Get handles for the views.
     webEngineViewPointer = browserViewUi.webEngineView;
 
+    // Create an off-the-record profile (the default when no profile name is specified).
+    webEngineProfilePointer = new QWebEngineProfile(QStringLiteral(""));
+
+    // Create a WebEngine page.
+    QWebEnginePage *webEnginePagePointer = new QWebEnginePage(webEngineProfilePointer);
+
+    // Set the WebEngine page.
+    webEngineViewPointer->setPage(webEnginePagePointer);
+
     // Get handles for the aspects of the WebEngine.
-    QWebEnginePage *webEnginePagePointer = webEngineViewPointer->page();
     webEngineHistoryPointer = webEnginePagePointer->history();
-    webEngineProfilePointer = webEnginePagePointer->profile();
     webEngineSettingsPointer = webEngineViewPointer->settings();
 
     // Update the URL line edit when the URL changes.
@@ -75,9 +82,6 @@ BrowserView::BrowserView(QWidget *parent) : QWidget(parent)
     // Reapply the domain settings when the host changes.
     connect(urlRequestInterceptorPointer, SIGNAL(applyDomainSettings(QString)), this, SLOT(applyDomainSettingsWithoutReloading(QString)));
 
-    // Disable the cache.
-    webEngineProfilePointer->setHttpCacheType(QWebEngineProfile::NoCache);
-
     // Don't allow JavaScript to open windows.
     webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, false);