summaryrefslogtreecommitdiffstats
path: root/src/webview
diff options
context:
space:
mode:
authorAgnieszka Jaworska <agnieszka@elmstonesystems.co.uk>2021-09-21 15:17:55 +0100
committerAgnieszka Jaworska <agnieszka@elmstonesystems.co.uk>2021-12-14 12:33:54 +0000
commit317e13cb2d97001518d7635579d49861f72708df (patch)
tree43aa771a2d79f19a4bed2be39072da435b143d83 /src/webview
parentedc41a87d181c8898184a7b8f21ceb752f41893b (diff)
Add support functions to manage cookies
Setting and deleting cookies, changes for android, darwin and webengine plugins Pick-to: 6.3 Task-number: QTBUG-96204 Change-Id: I4f79d34384e490b70a1e9f89196dd113733d5fe1 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src/webview')
-rw-r--r--src/webview/qabstractwebview_p.h2
-rw-r--r--src/webview/qwebview.cpp17
-rw-r--r--src/webview/qwebview_p.h6
-rw-r--r--src/webview/qwebviewfactory.cpp5
-rw-r--r--src/webview/qwebviewinterface_p.h3
5 files changed, 33 insertions, 0 deletions
diff --git a/src/webview/qabstractwebview_p.h b/src/webview/qabstractwebview_p.h
index 9f57b5a..5f612e3 100644
--- a/src/webview/qabstractwebview_p.h
+++ b/src/webview/qabstractwebview_p.h
@@ -71,6 +71,8 @@ Q_SIGNALS:
void javaScriptResult(int id, const QVariant &result);
void requestFocus(bool focus);
void httpUserAgentChanged(const QString &httpUserAgent);
+ void cookieAdded(const QString &domain, const QString &name);
+ void cookieRemoved(const QString &domain, const QString &name);
protected:
explicit QAbstractWebView(QObject *p = nullptr) : QObject(p) { }
diff --git a/src/webview/qwebview.cpp b/src/webview/qwebview.cpp
index 943218b..85e8522 100644
--- a/src/webview/qwebview.cpp
+++ b/src/webview/qwebview.cpp
@@ -58,6 +58,8 @@ QWebView::QWebView(QObject *p)
connect(d, &QAbstractWebView::requestFocus, this, &QWebView::requestFocus);
connect(d, &QAbstractWebView::javaScriptResult,
this, &QWebView::javaScriptResult);
+ connect(d, &QAbstractWebView::cookieAdded, this, &QWebView::cookieAdded);
+ connect(d, &QAbstractWebView::cookieRemoved, this, &QWebView::cookieRemoved);
}
QWebView::~QWebView()
@@ -173,6 +175,21 @@ void QWebView::runJavaScriptPrivate(const QString &script,
d->runJavaScriptPrivate(script, callbackId);
}
+void QWebView::setCookie(const QString &domain, const QString &name, const QString &value)
+{
+ d->setCookie(domain, name, value);
+}
+
+void QWebView::deleteCookie(const QString &domain, const QString &name)
+{
+ d->deleteCookie(domain, name);
+}
+
+void QWebView::deleteAllCookies()
+{
+ d->deleteAllCookies();
+}
+
void QWebView::onTitleChanged(const QString &title)
{
if (m_title == title)
diff --git a/src/webview/qwebview_p.h b/src/webview/qwebview_p.h
index 46754f8..1472c90 100644
--- a/src/webview/qwebview_p.h
+++ b/src/webview/qwebview_p.h
@@ -101,6 +101,10 @@ public Q_SLOTS:
void reload() override;
void stop() override;
void loadHtml(const QString &html, const QUrl &baseUrl = QUrl()) override;
+ void setCookie(const QString &domain, const QString &name,
+ const QString &value) override;
+ void deleteCookie(const QString &domain, const QString &name) override;
+ void deleteAllCookies() override;
Q_SIGNALS:
void titleChanged();
@@ -110,6 +114,8 @@ Q_SIGNALS:
void javaScriptResult(int id, const QVariant &result);
void requestFocus(bool focus);
void httpUserAgentChanged();
+ void cookieAdded(const QString &domain, const QString &name);
+ void cookieRemoved(const QString &domain, const QString &name);
protected:
void init() override;
diff --git a/src/webview/qwebviewfactory.cpp b/src/webview/qwebviewfactory.cpp
index fdf57bf..3ac3a60 100644
--- a/src/webview/qwebviewfactory.cpp
+++ b/src/webview/qwebviewfactory.cpp
@@ -81,6 +81,11 @@ public:
{ Q_UNUSED(html); Q_UNUSED(baseUrl); }
void runJavaScriptPrivate(const QString &script, int callbackId) override
{ Q_UNUSED(script); Q_UNUSED(callbackId); }
+ void setCookie(const QString &domain, const QString &name, const QString &value) override
+ { Q_UNUSED(domain); Q_UNUSED(name); Q_UNUSED(value); }
+ void deleteCookie(const QString &domain, const QString &name) override
+ { Q_UNUSED(domain); Q_UNUSED(name); }
+ void deleteAllCookies() override {}
};
QAbstractWebView *QWebViewFactory::createWebView()
diff --git a/src/webview/qwebviewinterface_p.h b/src/webview/qwebviewinterface_p.h
index d9e566c..35c5f97 100644
--- a/src/webview/qwebviewinterface_p.h
+++ b/src/webview/qwebviewinterface_p.h
@@ -82,6 +82,9 @@ public:
virtual void runJavaScriptPrivate(const QString &script,
int callbackId) = 0;
+ virtual void setCookie(const QString &domain, const QString &name, const QString &value) = 0;
+ virtual void deleteCookie(const QString &domain, const QString &name) = 0;
+ virtual void deleteAllCookies() = 0;
};
QT_END_NAMESPACE