f83ce1b3ec29bf2612d3759a903c2af45ce024de
[WebKit-https.git] / Source / WebCore / platform / network / curl / CookieJarCurl.cpp
1 /*
2  * Copyright (C) 2011 Apple Inc. All rights reserved.
3  * Copyright (C) 2018 Sony Interactive Entertainment Inc.
4  *
5  *  This library is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU Lesser General Public
7  *  License as published by the Free Software Foundation; either
8  *  version 2 of the License, or (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *  Lesser General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Lesser General Public
16  *  License along with this library; if not, write to the Free Software
17  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19
20 #include "config.h"
21 #include "CookieJarCurl.h"
22
23 #if USE(CURL)
24 #include "Cookie.h"
25 #include "CookieRequestHeaderFieldProxy.h"
26 #include "NetworkStorageSession.h"
27 #include "URL.h"
28
29 #include <wtf/text/WTFString.h>
30
31 namespace WebCore {
32
33 std::pair<String, bool> cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies)
34 {
35     return session.cookieStorage().cookiesForDOM(session, firstParty, url, frameID, pageID, includeSecureCookies);
36 }
37
38 void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& value)
39 {
40     session.cookieStorage().setCookiesFromDOM(session, firstParty, url, frameID, pageID, value);
41 }
42
43 std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies)
44 {
45     return session.cookieStorage().cookieRequestHeaderFieldValue(session, firstParty, url, frameID, pageID, includeSecureCookies);
46 }
47
48 std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const CookieRequestHeaderFieldProxy& headerFieldProxy)
49 {
50     return session.cookieStorage().cookieRequestHeaderFieldValue(session, headerFieldProxy.firstParty, headerFieldProxy.url, headerFieldProxy.frameID, headerFieldProxy.pageID, headerFieldProxy.includeSecureCookies);
51 }
52
53 bool cookiesEnabled(const NetworkStorageSession& session)
54 {
55     return session.cookieStorage().cookiesEnabled(session);
56 }
57
58 bool getRawCookies(const NetworkStorageSession& session, const URL& firstParty, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& rawCookies)
59 {
60     return session.cookieStorage().getRawCookies(session, firstParty, url, frameID, pageID, rawCookies);
61 }
62
63 void deleteCookie(const NetworkStorageSession& session, const URL& url, const String& cookie)
64 {
65     session.cookieStorage().deleteCookie(session, url, cookie);
66 }
67
68 void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames)
69 {
70     session.cookieStorage().getHostnamesWithCookies(session, hostnames);
71 }
72
73 void deleteCookiesForHostnames(const NetworkStorageSession& session, const Vector<String>& cookieHostNames)
74 {
75     session.cookieStorage().deleteCookiesForHostnames(session, cookieHostNames);
76 }
77
78 void deleteAllCookies(const NetworkStorageSession& session)
79 {
80     session.cookieStorage().deleteAllCookies(session);
81 }
82
83 void deleteAllCookiesModifiedSince(const NetworkStorageSession& session, WallTime since)
84 {
85     session.cookieStorage().deleteAllCookiesModifiedSince(session, since);
86 }
87
88 }
89
90 #endif