https://bugs.webkit.org/show_bug.cgi?id=174943
Patch by Basuke Suzuki <Basuke.Suzuki@sony.com> on 2017-08-07
Reviewed by Brent Fulgham.
* platform/network/curl/CookieJarCurl.cpp:
(WebCore::CookieJarCurlFileSystem::setCookiesFromDOM):
(WebCore::CookieJarCurlFileSystem::cookiesForDOM):
(WebCore::CookieJarCurlFileSystem::cookieRequestHeaderFieldValue):
(WebCore::CookieJarCurlFileSystem::cookiesEnabled):
(WebCore::CookieJarCurlFileSystem::getRawCookies):
(WebCore::CookieJarCurlFileSystem::deleteCookie):
(WebCore::CookieJarCurlFileSystem::getHostnamesWithCookies):
(WebCore::CookieJarCurlFileSystem::deleteCookiesForHostnames):
(WebCore::CookieJarCurlFileSystem::deleteAllCookies):
(WebCore::CookieJarCurlFileSystem::deleteAllCookiesModifiedSince):
(WebCore::cookiesForDOM):
(WebCore::setCookiesFromDOM):
(WebCore::cookieRequestHeaderFieldValue):
(WebCore::cookiesEnabled):
(WebCore::getRawCookies):
(WebCore::deleteCookie):
(WebCore::getHostnamesWithCookies):
(WebCore::deleteCookiesForHostnames):
(WebCore::deleteAllCookies):
(WebCore::deleteAllCookiesModifiedSince):
* platform/network/curl/CookieJarCurl.h: Added.
* platform/network/curl/CurlContext.cpp:
* platform/network/curl/CurlContext.h:
(WebCore::CurlContext::cookieJar):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220351
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2017-08-07 Basuke Suzuki <Basuke.Suzuki@sony.com>
+
+ [Curl] Add abstraction layer of cookie jar implementation for Curl port
+ https://bugs.webkit.org/show_bug.cgi?id=174943
+
+ Reviewed by Brent Fulgham.
+
+ * platform/network/curl/CookieJarCurl.cpp:
+ (WebCore::CookieJarCurlFileSystem::setCookiesFromDOM):
+ (WebCore::CookieJarCurlFileSystem::cookiesForDOM):
+ (WebCore::CookieJarCurlFileSystem::cookieRequestHeaderFieldValue):
+ (WebCore::CookieJarCurlFileSystem::cookiesEnabled):
+ (WebCore::CookieJarCurlFileSystem::getRawCookies):
+ (WebCore::CookieJarCurlFileSystem::deleteCookie):
+ (WebCore::CookieJarCurlFileSystem::getHostnamesWithCookies):
+ (WebCore::CookieJarCurlFileSystem::deleteCookiesForHostnames):
+ (WebCore::CookieJarCurlFileSystem::deleteAllCookies):
+ (WebCore::CookieJarCurlFileSystem::deleteAllCookiesModifiedSince):
+ (WebCore::cookiesForDOM):
+ (WebCore::setCookiesFromDOM):
+ (WebCore::cookieRequestHeaderFieldValue):
+ (WebCore::cookiesEnabled):
+ (WebCore::getRawCookies):
+ (WebCore::deleteCookie):
+ (WebCore::getHostnamesWithCookies):
+ (WebCore::deleteCookiesForHostnames):
+ (WebCore::deleteAllCookies):
+ (WebCore::deleteAllCookiesModifiedSince):
+ * platform/network/curl/CookieJarCurl.h: Added.
+ * platform/network/curl/CurlContext.cpp:
+ * platform/network/curl/CurlContext.h:
+ (WebCore::CurlContext::cookieJar):
+
2017-08-07 Brady Eidson <beidson@apple.com>
Implement most of ServiceWorkerContainer::addRegistration.
*/
#include "config.h"
-#include "PlatformCookieJar.h"
+#include "CookieJarCurl.h"
#if USE(CURL)
-
#include "Cookie.h"
#include "CurlContext.h"
#include "NotImplemented.h"
return cookieStr.toString();
}
-void setCookiesFromDOM(const NetworkStorageSession&, const URL&, const URL& url, const String& value)
+void CookieJarCurlFileSystem::setCookiesFromDOM(const NetworkStorageSession&, const URL& firstParty, const URL& url, const String& value)
{
CurlHandle curlHandle;
return cookies;
}
-String cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+String CookieJarCurlFileSystem::cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
{
return cookiesForSession(session, firstParty, url, false);
}
-String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+String CookieJarCurlFileSystem::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
{
return cookiesForSession(session, firstParty, url, true);
}
-bool cookiesEnabled(const NetworkStorageSession&, const URL& /*firstParty*/, const URL& /*url*/)
+bool CookieJarCurlFileSystem::cookiesEnabled(const NetworkStorageSession&, const URL& firstParty, const URL&)
{
return true;
}
-bool getRawCookies(const NetworkStorageSession&, const URL& /*firstParty*/, const URL& /*url*/, Vector<Cookie>& rawCookies)
+bool CookieJarCurlFileSystem::getRawCookies(const NetworkStorageSession&, const URL& firstParty, const URL&, Vector<Cookie>& rawCookies)
{
// FIXME: Not yet implemented
rawCookies.clear();
return false; // return true when implemented
}
-void deleteCookie(const NetworkStorageSession&, const URL&, const String&)
+void CookieJarCurlFileSystem::deleteCookie(const NetworkStorageSession&, const URL&, const String&)
{
// FIXME: Not yet implemented
}
-void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>&)
+void CookieJarCurlFileSystem::getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& hostnames)
{
// FIXME: Not yet implemented
}
-void deleteCookiesForHostnames(const NetworkStorageSession&, const Vector<String>&)
+void CookieJarCurlFileSystem::deleteCookiesForHostnames(const NetworkStorageSession&, const Vector<String>& cookieHostNames)
{
// FIXME: Not yet implemented
}
-void deleteAllCookies(const NetworkStorageSession&)
+void CookieJarCurlFileSystem::deleteAllCookies(const NetworkStorageSession&)
{
// FIXME: Not yet implemented
}
-void deleteAllCookiesModifiedSince(const NetworkStorageSession&, std::chrono::system_clock::time_point)
+void CookieJarCurlFileSystem::deleteAllCookiesModifiedSince(const NetworkStorageSession&, std::chrono::system_clock::time_point)
{
// FIXME: Not yet implemented
}
+// dispatcher functions
+
+String cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+{
+ return CurlContext::singleton().cookieJar().cookiesForDOM(session, firstParty, url);
+}
+
+void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url, const String& value)
+{
+ CurlContext::singleton().cookieJar().setCookiesFromDOM(session, firstParty, url, value);
+}
+
+String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+{
+ return CurlContext::singleton().cookieJar().cookieRequestHeaderFieldValue(session, firstParty, url);
+}
+
+bool cookiesEnabled(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+{
+ return CurlContext::singleton().cookieJar().cookiesEnabled(session, firstParty, url);
+}
+
+bool getRawCookies(const NetworkStorageSession& session, const URL& firstParty, const URL& url, Vector<Cookie>& rawCookies)
+{
+ return CurlContext::singleton().cookieJar().getRawCookies(session, firstParty, url, rawCookies);
+}
+
+void deleteCookie(const NetworkStorageSession& session, const URL& url, const String& cookie)
+{
+ CurlContext::singleton().cookieJar().deleteCookie(session, url, cookie);
+}
+
+void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames)
+{
+ CurlContext::singleton().cookieJar().getHostnamesWithCookies(session, hostnames);
+}
+
+void deleteCookiesForHostnames(const NetworkStorageSession& session, const Vector<String>& cookieHostNames)
+{
+ CurlContext::singleton().cookieJar().deleteCookiesForHostnames(session, cookieHostNames);
+}
+
+void deleteAllCookies(const NetworkStorageSession& session)
+{
+ CurlContext::singleton().cookieJar().deleteAllCookies(session);
+}
+
+void deleteAllCookiesModifiedSince(const NetworkStorageSession& session, std::chrono::system_clock::time_point since)
+{
+ CurlContext::singleton().cookieJar().deleteAllCookiesModifiedSince(session, since);
+}
+
}
#endif
--- /dev/null
+/*
+* Copyright (C) 2017 Sony Interactive Entertainment Inc.
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#pragma once
+
+#include "PlatformCookieJar.h"
+
+namespace WebCore {
+
+class Cookie;
+class NetworkStorageSession;
+class URL;
+
+class CookieJarCurl {
+public:
+ virtual String cookiesForDOM(const NetworkStorageSession&, const URL& firstParty, const URL&) = 0;
+ virtual void setCookiesFromDOM(const NetworkStorageSession&, const URL& firstParty, const URL&, const String&) = 0;
+ virtual bool cookiesEnabled(const NetworkStorageSession&, const URL& firstParty, const URL&) = 0;
+ virtual String cookieRequestHeaderFieldValue(const NetworkStorageSession&, const URL& firstParty, const URL&) = 0;
+ virtual bool getRawCookies(const NetworkStorageSession&, const URL& firstParty, const URL&, Vector<Cookie>&) = 0;
+ virtual void deleteCookie(const NetworkStorageSession&, const URL&, const String&) = 0;
+ virtual void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& hostnames) = 0;
+ virtual void deleteCookiesForHostnames(const NetworkStorageSession&, const Vector<String>& cookieHostNames) = 0;
+ virtual void deleteAllCookies(const NetworkStorageSession&) = 0;
+ virtual void deleteAllCookiesModifiedSince(const NetworkStorageSession&, std::chrono::system_clock::time_point) = 0;
+};
+
+class CookieJarCurlFileSystem : public CookieJarCurl {
+ String cookiesForDOM(const NetworkStorageSession&, const URL& firstParty, const URL&) override;
+ void setCookiesFromDOM(const NetworkStorageSession&, const URL& firstParty, const URL&, const String&) override;
+ bool cookiesEnabled(const NetworkStorageSession&, const URL& firstParty, const URL&) override;
+ String cookieRequestHeaderFieldValue(const NetworkStorageSession&, const URL& firstParty, const URL&) override;
+ bool getRawCookies(const NetworkStorageSession&, const URL& firstParty, const URL&, Vector<Cookie>&) override;
+ void deleteCookie(const NetworkStorageSession&, const URL&, const String&) override;
+ void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& hostnames) override;
+ void deleteCookiesForHostnames(const NetworkStorageSession&, const Vector<String>& cookieHostNames) override;
+ void deleteAllCookies(const NetworkStorageSession&) override;
+ void deleteAllCookiesModifiedSince(const NetworkStorageSession&, std::chrono::system_clock::time_point) override;
+};
+
+}
CurlContext::CurlContext()
: m_cookieJarFileName { cookieJarPath() }
, m_certificatePath { certificatePath() }
+, m_cookieJar { std::make_unique<CookieJarCurlFileSystem>() }
{
initCookieSession();
#pragma once
+#include "CookieJarCurl.h"
#include "URL.h"
#include <wtf/Lock.h>
// Cookie
const char* getCookieJarFileName() const { return m_cookieJarFileName.data(); }
void setCookieJarFileName(const char* cookieJarFileName) { m_cookieJarFileName = CString(cookieJarFileName); }
+ CookieJarCurl& cookieJar() { return *m_cookieJar; }
// Certificate
const char* getCertificatePath() const { return m_certificatePath.data(); }
CString m_cookieJarFileName;
CString m_certificatePath;
CurlShareHandle m_shareHandle;
+ std::unique_ptr<CookieJarCurl> m_cookieJar;
bool m_ignoreSSLErrors { false };
CurlContext();