summaryrefslogtreecommitdiffstats
path: root/src/core/api/qwebenginecookiestore.cpp
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2015-12-02 19:38:33 +0100
committerMichal Klocek <michal.klocek@theqtcompany.com>2016-01-15 22:06:53 +0000
commit09ff58b1a91a1472b4aa4c644686fb2e46a3b1ca (patch)
treed3c77a3034e4ddc349150f5e38a686fd569457dd /src/core/api/qwebenginecookiestore.cpp
parent50c423267ee54020a7ddbe3a0f56ddca4653c40a (diff)
Remove callback functions from qwebenginecookiestore
Remove all callback api calls, rename getAllCookies to loadCookies, update documentation. New function name reflects the fact the cookieAdded signal is always emitted when cookies are loaded from the store. Change-Id: Iab7bb04871c7396d2e23306a10084d425426a19f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src/core/api/qwebenginecookiestore.cpp')
-rw-r--r--src/core/api/qwebenginecookiestore.cpp108
1 files changed, 32 insertions, 76 deletions
diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp
index 2938eddb..ab261280 100644
--- a/src/core/api/qwebenginecookiestore.cpp
+++ b/src/core/api/qwebenginecookiestore.cpp
@@ -268,41 +268,26 @@ QWebEngineCookieStore::~QWebEngineCookieStore()
}
/*!
- \fn void setCookieWithCallback(const QNetworkCookie &cookie, FunctorOrLambda resultCallback, const QUrl &origin = QUrl())
-
- Adds \a cookie to the cookie store. When the operation finishes, \a resultCallback will be executed
- on the caller thread.
- It is possible to provide an optional \a origin URL argument to limit the scope of the cookie.
- The provided URL should also include the scheme.
-
- \sa setCookie()
-*/
-
-void QWebEngineCookieStore::setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback<bool> &resultCallback, const QUrl &origin)
-{
- Q_D(QWebEngineCookieStore);
- d->setCookie(resultCallback, cookie, origin);
-}
-
-/*!
- Adds \a cookie to the cookie store. This function is provided for convenience and is
- equivalent to calling setCookieWithCallback() with an empty callback.
+ Adds \a cookie to the cookie store.
It is possible to provide an optional \a origin URL argument to limit the scope of the cookie.
The provided URL should also include the scheme.
- \sa setCookieWithCallback()
+ \note This operation is asynchronous.
*/
void QWebEngineCookieStore::setCookie(const QNetworkCookie &cookie, const QUrl &origin)
{
- setCookieWithCallback(cookie, QWebEngineCallback<bool>(), origin);
+ //TODO: use callbacks or delete dummy ones
+ Q_D(QWebEngineCookieStore);
+ d->setCookie(QWebEngineCallback<bool>(), cookie, origin);
}
/*!
Deletes \a cookie from the cookie store.
It is possible to provide an optional \a origin URL argument to limit the scope of the
cookie to be deleted.
- The provided URL should also include the scheme.
+
+ \note This operation is asynchronous.
*/
void QWebEngineCookieStore::deleteCookie(const QNetworkCookie &cookie, const QUrl &origin)
@@ -312,89 +297,60 @@ void QWebEngineCookieStore::deleteCookie(const QNetworkCookie &cookie, const QUr
}
/*!
- \fn void QWebEngineCookieStore::getAllCookies(FunctorOrLambda resultCallback)
+ Loads all the cookies into the cookie store. The cookieAdded() signal is emitted on every
+ loaded cookie. Cookies are loaded automatically when the store gets initialized, which
+ in most cases happens on loading the first URL. However, calling this function is useful
+ if cookies should be listed before entering the web content.
- Requests all the cookies in the cookie store. When the asynchronous operation finishes,
- \a resultCallback will be called with a QByteArray as the argument containing the cookies.
- This QByteArray can be parsed using QNetworkCookie::parseCookies().
-
- \sa deleteCookie()
+ \note This operation is asynchronous.
*/
-void QWebEngineCookieStore::getAllCookies(const QWebEngineCallback<const QByteArray&> &resultCallback)
+void QWebEngineCookieStore::loadAllCookies()
{
+ //TODO: use callbacks or delete dummy ones
Q_D(QWebEngineCookieStore);
- if (d->m_getAllCookiesPending) {
- d->callbackDirectory.invokeEmpty(resultCallback);
+ if (d->m_getAllCookiesPending)
return;
- }
- d->callbackDirectory.registerCallback(CallbackDirectory::GetAllCookiesCallbackId, resultCallback);
+ d->callbackDirectory.registerCallback(CallbackDirectory::GetAllCookiesCallbackId, QWebEngineCallback<const QByteArray&>());
+ //this will trigger cookieAdded signal
d->getAllCookies();
}
/*!
- \fn void QWebEngineCookieStore::deleteSessionCookiesWithCallback(FunctorOrLambda resultCallback)
-
Deletes all the session cookies in the cookie store. Session cookies do not have an
expiration date assigned to them.
- When the asynchronous operation finishes, \a resultCallback will be called with the
- number of cookies deleted as the argument.
+
+ \note This operation is asynchronous.
+ \sa loadAllCookies()
*/
-void QWebEngineCookieStore::deleteSessionCookiesWithCallback(const QWebEngineCallback<int> &resultCallback)
+void QWebEngineCookieStore::deleteSessionCookies()
{
+ //TODO: use callbacks or delete dummy ones
Q_D(QWebEngineCookieStore);
- if (d->m_deleteAllCookiesPending || d->m_deleteSessionCookiesPending) {
- d->callbackDirectory.invokeEmpty(resultCallback);
+ if (d->m_deleteAllCookiesPending || d->m_deleteSessionCookiesPending)
return;
- }
- d->callbackDirectory.registerCallback(CallbackDirectory::DeleteSessionCookiesCallbackId, resultCallback);
+ d->callbackDirectory.registerCallback(CallbackDirectory::DeleteSessionCookiesCallbackId, QWebEngineCallback<int>());
d->deleteSessionCookies();
}
/*!
- \fn void QWebEngineCookieStore::deleteAllCookiesWithCallback(FunctorOrLambda resultCallback)
-
- Deletes all the cookies in the cookie store. When the asynchronous operation finishes,
- \a resultCallback will be called with the number of cookies deleted as the argument.
-
- \sa deleteSessionCookiesWithCallback(), getAllCookies()
+ Deletes all the cookies in the cookie store.
+ \note This operation is asynchronous.
+ \sa loadAllCookies()
*/
-void QWebEngineCookieStore::deleteAllCookiesWithCallback(const QWebEngineCallback<int> &resultCallback)
+void QWebEngineCookieStore::deleteAllCookies()
{
+ //TODO: use callbacks or delete dummy ones
Q_D(QWebEngineCookieStore);
- if (d->m_deleteAllCookiesPending) {
- d->callbackDirectory.invokeEmpty(resultCallback);
+ if (d->m_deleteAllCookiesPending)
return;
- }
- d->callbackDirectory.registerCallback(CallbackDirectory::DeleteAllCookiesCallbackId, resultCallback);
+ d->callbackDirectory.registerCallback(CallbackDirectory::DeleteAllCookiesCallbackId, QWebEngineCallback<int>());
d->deleteAllCookies();
}
/*!
- Deletes all the session cookies in the cookie store.
-
- \sa deleteSessionCookiesWithCallback()
-*/
-
-void QWebEngineCookieStore::deleteSessionCookies()
-{
- deleteSessionCookiesWithCallback(QWebEngineCallback<int>());
-}
-
-/*!
- Deletes all the cookies in the cookie store.
-
- \sa deleteAllCookiesWithCallback(), getAllCookies()
-*/
-
-void QWebEngineCookieStore::deleteAllCookies()
-{
- deleteAllCookiesWithCallback(QWebEngineCallback<int>());
-}
-
-/*!
\fn void QWebEngineCookieStore::setCookieFilter(FunctorOrLambda filterCallback)
Installs a cookie filter that can reject cookies before they are added to the cookie store.
@@ -404,7 +360,7 @@ void QWebEngineCookieStore::deleteAllCookies()
The callback should not be used to execute heavy tasks since it is running on the
IO thread and therefore blocks the Chromium networking.
- \sa deleteAllCookiesWithCallback(), getAllCookies()
+ \sa deleteAllCookies(), loadAllCookies()
*/
void QWebEngineCookieStore::setCookieFilter(const QWebEngineCallback<QWebEngineCookieStore::FilterRequest&> &filter)
{