Diff
Modified: trunk/Source/WebCore/ChangeLog (256650 => 256651)
--- trunk/Source/WebCore/ChangeLog 2020-02-14 23:05:10 UTC (rev 256650)
+++ trunk/Source/WebCore/ChangeLog 2020-02-14 23:17:39 UTC (rev 256651)
@@ -1,3 +1,24 @@
+2020-02-14 Pavel Feldman <pavel.feld...@gmail.com>
+
+ [Curl] Implement NetworkStorageSession::get/set/deleteCookie
+ https://bugs.webkit.org/show_bug.cgi?id=207450
+
+ Reviewed by Don Olmstead.
+
+ * platform/network/curl/CookieJarCurl.cpp:
+ (WebCore::CookieJarCurl::getAllCookies const):
+ (WebCore::CookieJarCurl::setCookie const):
+ (WebCore::CookieJarCurl::deleteCookie const):
+ * platform/network/curl/CookieJarCurl.h:
+ * platform/network/curl/CookieJarDB.cpp:
+ (WebCore::CookieJarDB::getAllCookies):
+ * platform/network/curl/CookieJarDB.h:
+ * platform/network/curl/NetworkStorageSessionCurl.cpp:
+ (WebCore::NetworkStorageSession::NetworkStorageSession):
+ (WebCore::NetworkStorageSession::setCookie):
+ (WebCore::NetworkStorageSession::deleteCookie):
+ (WebCore::NetworkStorageSession::getAllCookies):
+
2020-02-14 Nikos Mouchtaris <nmouchta...@apple.com>
WebKit support for Apple Pay Buttons with custom corner radii
Modified: trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp (256650 => 256651)
--- trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp 2020-02-14 23:05:10 UTC (rev 256650)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp 2020-02-14 23:17:39 UTC (rev 256651)
@@ -147,6 +147,25 @@
cookieJarDB.deleteAllCookies();
}
+Vector<Cookie> CookieJarCurl::getAllCookies(const NetworkStorageSession& session) const
+{
+ CookieJarDB& cookieJarDB = session.cookieDatabase();
+ return cookieJarDB.getAllCookies();
+}
+
+void CookieJarCurl::setCookie(const NetworkStorageSession& session, const Cookie& cookie) const
+{
+ CookieJarDB& cookieJarDB = session.cookieDatabase();
+ cookieJarDB.setCookie(cookie);
+}
+
+void CookieJarCurl::deleteCookie(const NetworkStorageSession& session, const Cookie& cookie) const
+{
+ String url = "" ? "https"_s : "http"_s, "://"_s, cookie.domain, cookie.path);
+ CookieJarDB& cookieJarDB = session.cookieDatabase();
+ cookieJarDB.deleteCookie(url, cookie.name);
+}
+
void CookieJarCurl::deleteAllCookiesModifiedSince(const NetworkStorageSession&, WallTime) const
{
// FIXME: Not yet implemented
Modified: trunk/Source/WebCore/platform/network/curl/CookieJarCurl.h (256650 => 256651)
--- trunk/Source/WebCore/platform/network/curl/CookieJarCurl.h 2020-02-14 23:05:10 UTC (rev 256650)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarCurl.h 2020-02-14 23:17:39 UTC (rev 256651)
@@ -58,6 +58,9 @@
void deleteCookiesForHostnames(const NetworkStorageSession&, const Vector<String>& cookieHostNames) const;
void deleteAllCookies(const NetworkStorageSession&) const;
void deleteAllCookiesModifiedSince(const NetworkStorageSession&, WallTime) const;
+ Vector<Cookie> getAllCookies(const NetworkStorageSession&) const;
+ void setCookie(const NetworkStorageSession&, const Cookie&) const;
+ void deleteCookie(const NetworkStorageSession&, const Cookie&) const;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp (256650 => 256651)
--- trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp 2020-02-14 23:05:10 UTC (rev 256650)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp 2020-02-14 23:17:39 UTC (rev 256651)
@@ -445,6 +445,32 @@
return results;
}
+Vector<Cookie> CookieJarDB::getAllCookies()
+{
+ Vector<Cookie> result;
+ if (!isEnabled() || !m_database.isOpen())
+ return result;
+ const String sql = "SELECT name, value, domain, path, expires, httponly, secure, session FROM Cookie"_s;
+ auto pstmt = makeUnique<SQLiteStatement>(m_database, sql);
+ if (!pstmt)
+ return result;
+ pstmt->prepare();
+ while (pstmt->step() == SQLITE_ROW) {
+ Cookie cookie;
+ cookie.name = pstmt->getColumnText(0);
+ cookie.value = pstmt->getColumnText(1);
+ cookie.domain = pstmt->getColumnText(2).convertToASCIILowercase();
+ cookie.path = pstmt->getColumnText(3);
+ cookie.expires = (double)pstmt->getColumnInt64(4) * 1000;
+ cookie.httpOnly = (pstmt->getColumnInt(5) == 1);
+ cookie.secure = (pstmt->getColumnInt(6) == 1);
+ cookie.session = (pstmt->getColumnInt(7) == 1);
+ result.append(WTFMove(cookie));
+ }
+ pstmt->finalize();
+ return result;
+}
+
bool CookieJarDB::hasHttpOnlyCookie(const String& name, const String& domain, const String& path)
{
auto& statement = preparedStatement(CHECK_EXISTS_HTTPONLY_COOKIE_SQL);
Modified: trunk/Source/WebCore/platform/network/curl/CookieJarDB.h (256650 => 256651)
--- trunk/Source/WebCore/platform/network/curl/CookieJarDB.h 2020-02-14 23:05:10 UTC (rev 256650)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarDB.h 2020-02-14 23:17:39 UTC (rev 256651)
@@ -57,6 +57,7 @@
CookieAcceptPolicy acceptPolicy() const { return m_acceptPolicy; }
Optional<Vector<Cookie>> searchCookies(const URL& firstParty, const URL& requestUrl, const Optional<bool>& httpOnly, const Optional<bool>& secure, const Optional<bool>& session);
+ Vector<Cookie> getAllCookies();
bool setCookie(const URL& firstParty, const URL&, const String& cookie, Source);
bool setCookie(const Cookie&);
Modified: trunk/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp (256650 => 256651)
--- trunk/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp 2020-02-14 23:05:10 UTC (rev 256650)
+++ trunk/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp 2020-02-14 23:17:39 UTC (rev 256651)
@@ -62,7 +62,8 @@
NetworkStorageSession::NetworkStorageSession(PAL::SessionID sessionID)
: m_sessionID(sessionID)
, m_cookieStorage(makeUniqueRef<CookieJarCurl>())
- , m_cookieDatabase(makeUniqueRef<CookieJarDB>(defaultCookieJarPath()))
+ // :memory: creates in-memory database, see https://www.sqlite.org/inmemorydb.html
+ , m_cookieDatabase(makeUniqueRef<CookieJarDB>(sessionID.isEphemeral() ? ":memory:"_s : defaultCookieJarPath()))
{
}
@@ -113,14 +114,14 @@
// FIXME: Implement for WebKit to use.
}
-void NetworkStorageSession::setCookie(const Cookie&)
+void NetworkStorageSession::setCookie(const Cookie& cookie)
{
- // FIXME: Implement for WebKit to use.
+ cookieStorage().setCookie(*this, cookie);
}
-void NetworkStorageSession::deleteCookie(const Cookie&)
+void NetworkStorageSession::deleteCookie(const Cookie& cookie)
{
- // FIXME: Implement for WebKit to use.
+ cookieStorage().deleteCookie(*this, cookie);
}
void NetworkStorageSession::deleteCookie(const URL& url, const String& cookie) const
@@ -152,8 +153,7 @@
Vector<Cookie> NetworkStorageSession::getAllCookies()
{
- // FIXME: Implement for WebKit to use.
- return { };
+ return cookieStorage().getAllCookies(*this);
}
void NetworkStorageSession::getHostnamesWithCookies(HashSet<String>& hostnames)