summaryrefslogtreecommitdiffstats
path: root/src/core/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/api')
-rw-r--r--src/core/api/core_api.pro10
-rw-r--r--src/core/api/dummy.cpp1
-rw-r--r--src/core/api/qwebenginecallback_p.h8
-rw-r--r--src/core/api/qwebenginecookiestoreclient.cpp151
-rw-r--r--src/core/api/qwebenginecookiestoreclient.h83
-rw-r--r--src/core/api/qwebenginecookiestoreclient_p.h94
6 files changed, 344 insertions, 3 deletions
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index e0a6c2de4..605a6dc3b 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -4,6 +4,7 @@ DESTDIR = $$OUT_PWD/$$getConfigDir()
TEMPLATE = lib
CONFIG += staticlib c++11
+QT += network
# Don't create .prl file for this intermediate library because
# their contents get used when linking against them, breaking
@@ -17,7 +18,9 @@ CONFIG -= create_prl
contains(QT_CONFIG, build_all):CONFIG += build_all
}
-DEFINES += BUILDING_CHROMIUM
+DEFINES += \
+ BUILDING_CHROMIUM \
+ NOMINMAX
CHROMIUM_SRC_DIR = $$QTWEBENGINE_ROOT/$$getChromiumSrcDir()
INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core \
@@ -30,5 +33,8 @@ HEADERS = \
qwebenginecallback_p.h \
qtwebenginecoreglobal.h \
qtwebenginecoreglobal_p.h \
+ qwebenginecookiestoreclient.h \
+ qwebenginecookiestoreclient_p.h \
-SOURCES = dummy.cpp \
+SOURCES = \
+ qwebenginecookiestoreclient.cpp \
diff --git a/src/core/api/dummy.cpp b/src/core/api/dummy.cpp
deleted file mode 100644
index 3c2a8e265..000000000
--- a/src/core/api/dummy.cpp
+++ /dev/null
@@ -1 +0,0 @@
-// Used when we need to compile with no source code
diff --git a/src/core/api/qwebenginecallback_p.h b/src/core/api/qwebenginecallback_p.h
index 9c798acbe..9eb627ad3 100644
--- a/src/core/api/qwebenginecallback_p.h
+++ b/src/core/api/qwebenginecallback_p.h
@@ -72,6 +72,14 @@ public:
}
}
+ enum ReservedCallbackIds {
+ NoCallbackId = 0,
+ DeleteCookieCallbackId,
+
+ // Place reserved id's before this.
+ ReservedCallbackIdsEnd
+ };
+
template<typename T>
void registerCallback(quint64 callbackId, const QWebEngineCallback<T> &callback);
diff --git a/src/core/api/qwebenginecookiestoreclient.cpp b/src/core/api/qwebenginecookiestoreclient.cpp
new file mode 100644
index 000000000..c8b314be9
--- /dev/null
+++ b/src/core/api/qwebenginecookiestoreclient.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebenginecookiestoreclient.h"
+#include "qwebenginecookiestoreclient_p.h"
+
+#include <QByteArray>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QtWebEngineCore;
+
+QWebEngineCookieStoreClientPrivate::QWebEngineCookieStoreClientPrivate(QWebEngineCookieStoreClient* q)
+ : m_nextCallbackId(CallbackDirectory::ReservedCallbackIdsEnd)
+ , delegate(0)
+ , q_ptr(q)
+{
+}
+
+QWebEngineCookieStoreClientPrivate::~QWebEngineCookieStoreClientPrivate()
+{
+
+}
+
+void QWebEngineCookieStoreClientPrivate::processPendingUserCookies()
+{
+ Q_ASSERT(delegate);
+ Q_ASSERT(delegate->hasCookieMonster());
+
+ if (m_pendingUserCookies.isEmpty())
+ return;
+
+ Q_FOREACH (const auto &cookieData, m_pendingUserCookies) {
+ if (cookieData.callbackId == CallbackDirectory::DeleteCookieCallbackId)
+ delegate->deleteCookie(cookieData.cookie, cookieData.origin);
+ else
+ delegate->setCookie(cookieData.callbackId, cookieData.cookie, cookieData.origin);
+ }
+
+ m_pendingUserCookies.clear();
+}
+
+void QWebEngineCookieStoreClientPrivate::setCookie(const QWebEngineCallback<bool> &callback, const QNetworkCookie &cookie, const QUrl &origin)
+{
+ const quint64 currentCallbackId = callback ? m_nextCallbackId++ : static_cast<quint64>(CallbackDirectory::NoCallbackId);
+
+ if (currentCallbackId != CallbackDirectory::NoCallbackId)
+ callbackDirectory.registerCallback(currentCallbackId, callback);
+
+ if (!delegate || !delegate->hasCookieMonster()) {
+ m_pendingUserCookies.append(CookieData{ currentCallbackId, cookie, origin });
+ return;
+ }
+
+ delegate->setCookie(currentCallbackId, cookie, origin);
+}
+
+void QWebEngineCookieStoreClientPrivate::deleteCookie(const QNetworkCookie &cookie, const QUrl &url)
+{
+ if (!delegate || !delegate->hasCookieMonster()) {
+ m_pendingUserCookies.append(CookieData{ CallbackDirectory::DeleteCookieCallbackId, cookie, url });
+ return;
+ }
+
+ delegate->deleteCookie(cookie, url);
+}
+
+void QWebEngineCookieStoreClientPrivate::onSetCallbackResult(qint64 callbackId, bool success)
+{
+ callbackDirectory.invoke(callbackId, success);
+}
+
+void QWebEngineCookieStoreClientPrivate::onCookieChanged(const QNetworkCookie &cookie, bool removed)
+{
+ Q_Q(QWebEngineCookieStoreClient);
+ if (removed)
+ Q_EMIT q->cookieRemoved(cookie);
+ else
+ Q_EMIT q->cookieAdded(cookie);
+}
+
+void QWebEngineCookieStoreClientPrivate::onCookieStoreLoaded()
+{
+ Q_Q(QWebEngineCookieStoreClient);
+ Q_EMIT q->cookieStoreLoaded();
+}
+
+QWebEngineCookieStoreClient::QWebEngineCookieStoreClient(QObject *parent)
+ : QObject(parent)
+ , d_ptr(new QWebEngineCookieStoreClientPrivate(this))
+{
+
+}
+
+QWebEngineCookieStoreClient::~QWebEngineCookieStoreClient()
+{
+
+}
+
+void QWebEngineCookieStoreClient::setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback<bool> &resultCallback, const QUrl &origin)
+{
+ Q_D(QWebEngineCookieStoreClient);
+ d->setCookie(resultCallback, cookie, origin);
+}
+
+void QWebEngineCookieStoreClient::setCookie(const QNetworkCookie &cookie, const QUrl &origin)
+{
+ setCookieWithCallback(cookie, QWebEngineCallback<bool>(), origin);
+}
+
+void QWebEngineCookieStoreClient::deleteCookie(const QNetworkCookie &cookie, const QUrl &origin)
+{
+ Q_D(QWebEngineCookieStoreClient);
+ d->deleteCookie(cookie, origin);
+}
+
+QT_END_NAMESPACE
diff --git a/src/core/api/qwebenginecookiestoreclient.h b/src/core/api/qwebenginecookiestoreclient.h
new file mode 100644
index 000000000..3ab7df14f
--- /dev/null
+++ b/src/core/api/qwebenginecookiestoreclient.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINECOOKIESTORECLIENT_H
+#define QWEBENGINECOOKIESTORECLIENT_H
+
+#include "qtwebenginecoreglobal.h"
+#include "qwebenginecallback.h"
+
+#include <QObject>
+#include <QScopedPointer>
+#include <QNetworkCookie>
+#include <QUrl>
+
+namespace QtWebEngineCore {
+class CookieMonsterDelegateQt;
+}
+
+QT_BEGIN_NAMESPACE
+
+class QWebEngineCookieStoreClientPrivate;
+class QWEBENGINE_EXPORT QWebEngineCookieStoreClient : public QObject {
+ Q_OBJECT
+public:
+ explicit QWebEngineCookieStoreClient(QObject *parent = 0);
+ virtual ~QWebEngineCookieStoreClient();
+
+#ifdef Q_QDOC
+ void setCookieWithCallback(const QNetworkCookie &cookie, FunctorOrLambda resultCallback, const QUrl &origin = QUrl());
+#else
+ void setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback<bool> &resultCallback, const QUrl &origin = QUrl());
+#endif
+ void setCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl());
+ void deleteCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl());
+
+Q_SIGNALS:
+ void cookieAdded(const QNetworkCookie &cookie);
+ void cookieRemoved(const QNetworkCookie &cookie);
+ void cookieStoreLoaded();
+
+private:
+ friend class QtWebEngineCore::CookieMonsterDelegateQt;
+
+ Q_DECLARE_PRIVATE(QWebEngineCookieStoreClient)
+ QScopedPointer<QWebEngineCookieStoreClientPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINECOOKIESTORECLIENT_H
diff --git a/src/core/api/qwebenginecookiestoreclient_p.h b/src/core/api/qwebenginecookiestoreclient_p.h
new file mode 100644
index 000000000..aedb473cd
--- /dev/null
+++ b/src/core/api/qwebenginecookiestoreclient_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINECOOKIESTORECLIENT_P_H
+#define QWEBENGINECOOKIESTORECLIENT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qtwebenginecoreglobal_p.h"
+
+#include "cookie_monster_delegate_qt.h"
+#include "qwebenginecallback_p.h"
+#include "qwebenginecookiestoreclient.h"
+
+#include <QList>
+#include <QMap>
+#include <QNetworkCookie>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+class QWEBENGINE_PRIVATE_EXPORT QWebEngineCookieStoreClientPrivate {
+ struct CookieData {
+ quint64 callbackId;
+ QNetworkCookie cookie;
+ QUrl origin;
+ };
+
+public:
+ Q_DECLARE_PUBLIC(QWebEngineCookieStoreClient)
+ QtWebEngineCore::CallbackDirectory callbackDirectory;
+ QList<CookieData> m_pendingUserCookies;
+ quint64 m_nextCallbackId;
+
+ QtWebEngineCore::CookieMonsterDelegateQt *delegate;
+ QWebEngineCookieStoreClient *q_ptr;
+
+ QWebEngineCookieStoreClientPrivate(QWebEngineCookieStoreClient *q);
+ ~QWebEngineCookieStoreClientPrivate();
+
+ void processPendingUserCookies();
+ void setCookie(const QWebEngineCallback<bool> &callback, const QNetworkCookie &cookie, const QUrl &origin);
+ void deleteCookie(const QNetworkCookie &cookie, const QUrl &url);
+
+ void onSetCallbackResult(qint64 callbackId, bool success);
+ void onCookieChanged(const QNetworkCookie &cookie, bool removed);
+ void onCookieStoreLoaded();
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINECOOKIESTORECLIENT_P_H