X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Fviews%2FBrowserView.cpp;fp=src%2Fviews%2FBrowserView.cpp;h=b5c915bc1b1e9e3556b3b5c8501dd5643a372d20;hp=07ce5f5d897039339513fa075e6ed401d3d67906;hb=9b6cee96126484925bec4f4ab30c2b880df687fe;hpb=8933c941521c591a962034ecf3486c9143bf1f80 diff --git a/src/views/BrowserView.cpp b/src/views/BrowserView.cpp index 07ce5f5..b5c915b 100644 --- a/src/views/BrowserView.cpp +++ b/src/views/BrowserView.cpp @@ -120,6 +120,27 @@ BrowserView::~BrowserView() webEnginePagePointer->deleteLater(); } +// The cookie is copied instead of referenced so that changes made to the cookie do not create a race condition with the display of the cookie in the dialog. +void BrowserView::addCookieToStore(QNetworkCookie cookie) const +{ + // Create a url. + QUrl url; + + // Check to see if the domain does not start with a `.` because Qt makes this harder than it should be. + if (!cookie.domain().startsWith(QStringLiteral("."))) + { + // Populate the URL. + url.setHost(cookie.domain()); + url.setScheme(QStringLiteral("https")); + + // Clear the domain from the cookie. + cookie.setDomain(QStringLiteral("")); + } + + // Add the cookie to the store. + webEngineCookieStorePointer->setCookie(cookie, url); +} + void BrowserView::applyApplicationSettings() { // Set the search engine URL.