Changeset 256651 in webkit
- Timestamp:
- Feb 14, 2020 3:17:39 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r256648 r256651 1 2020-02-14 Pavel Feldman <pavel.feldman@gmail.com> 2 3 [Curl] Implement NetworkStorageSession::get/set/deleteCookie 4 https://bugs.webkit.org/show_bug.cgi?id=207450 5 6 Reviewed by Don Olmstead. 7 8 * platform/network/curl/CookieJarCurl.cpp: 9 (WebCore::CookieJarCurl::getAllCookies const): 10 (WebCore::CookieJarCurl::setCookie const): 11 (WebCore::CookieJarCurl::deleteCookie const): 12 * platform/network/curl/CookieJarCurl.h: 13 * platform/network/curl/CookieJarDB.cpp: 14 (WebCore::CookieJarDB::getAllCookies): 15 * platform/network/curl/CookieJarDB.h: 16 * platform/network/curl/NetworkStorageSessionCurl.cpp: 17 (WebCore::NetworkStorageSession::NetworkStorageSession): 18 (WebCore::NetworkStorageSession::setCookie): 19 (WebCore::NetworkStorageSession::deleteCookie): 20 (WebCore::NetworkStorageSession::getAllCookies): 21 1 22 2020-02-14 Nikos Mouchtaris <nmouchtaris@apple.com> 2 23 -
trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp
r248713 r256651 148 148 } 149 149 150 Vector<Cookie> CookieJarCurl::getAllCookies(const NetworkStorageSession& session) const 151 { 152 CookieJarDB& cookieJarDB = session.cookieDatabase(); 153 return cookieJarDB.getAllCookies(); 154 } 155 156 void CookieJarCurl::setCookie(const NetworkStorageSession& session, const Cookie& cookie) const 157 { 158 CookieJarDB& cookieJarDB = session.cookieDatabase(); 159 cookieJarDB.setCookie(cookie); 160 } 161 162 void CookieJarCurl::deleteCookie(const NetworkStorageSession& session, const Cookie& cookie) const 163 { 164 String url = makeString(cookie.secure ? "https"_s : "http"_s, "://"_s, cookie.domain, cookie.path); 165 CookieJarDB& cookieJarDB = session.cookieDatabase(); 166 cookieJarDB.deleteCookie(url, cookie.name); 167 } 168 150 169 void CookieJarCurl::deleteAllCookiesModifiedSince(const NetworkStorageSession&, WallTime) const 151 170 { -
trunk/Source/WebCore/platform/network/curl/CookieJarCurl.h
r248850 r256651 59 59 void deleteAllCookies(const NetworkStorageSession&) const; 60 60 void deleteAllCookiesModifiedSince(const NetworkStorageSession&, WallTime) const; 61 Vector<Cookie> getAllCookies(const NetworkStorageSession&) const; 62 void setCookie(const NetworkStorageSession&, const Cookie&) const; 63 void deleteCookie(const NetworkStorageSession&, const Cookie&) const; 61 64 }; 62 65 -
trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp
r248846 r256651 446 446 } 447 447 448 Vector<Cookie> CookieJarDB::getAllCookies() 449 { 450 Vector<Cookie> result; 451 if (!isEnabled() || !m_database.isOpen()) 452 return result; 453 const String sql = "SELECT name, value, domain, path, expires, httponly, secure, session FROM Cookie"_s; 454 auto pstmt = makeUnique<SQLiteStatement>(m_database, sql); 455 if (!pstmt) 456 return result; 457 pstmt->prepare(); 458 while (pstmt->step() == SQLITE_ROW) { 459 Cookie cookie; 460 cookie.name = pstmt->getColumnText(0); 461 cookie.value = pstmt->getColumnText(1); 462 cookie.domain = pstmt->getColumnText(2).convertToASCIILowercase(); 463 cookie.path = pstmt->getColumnText(3); 464 cookie.expires = (double)pstmt->getColumnInt64(4) * 1000; 465 cookie.httpOnly = (pstmt->getColumnInt(5) == 1); 466 cookie.secure = (pstmt->getColumnInt(6) == 1); 467 cookie.session = (pstmt->getColumnInt(7) == 1); 468 result.append(WTFMove(cookie)); 469 } 470 pstmt->finalize(); 471 return result; 472 } 473 448 474 bool CookieJarDB::hasHttpOnlyCookie(const String& name, const String& domain, const String& path) 449 475 { -
trunk/Source/WebCore/platform/network/curl/CookieJarDB.h
r248762 r256651 58 58 59 59 Optional<Vector<Cookie>> searchCookies(const URL& firstParty, const URL& requestUrl, const Optional<bool>& httpOnly, const Optional<bool>& secure, const Optional<bool>& session); 60 Vector<Cookie> getAllCookies(); 60 61 bool setCookie(const URL& firstParty, const URL&, const String& cookie, Source); 61 62 bool setCookie(const Cookie&); -
trunk/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp
r254931 r256651 63 63 : m_sessionID(sessionID) 64 64 , m_cookieStorage(makeUniqueRef<CookieJarCurl>()) 65 , m_cookieDatabase(makeUniqueRef<CookieJarDB>(defaultCookieJarPath())) 65 // :memory: creates in-memory database, see https://www.sqlite.org/inmemorydb.html 66 , m_cookieDatabase(makeUniqueRef<CookieJarDB>(sessionID.isEphemeral() ? ":memory:"_s : defaultCookieJarPath())) 66 67 { 67 68 } … … 114 115 } 115 116 116 void NetworkStorageSession::setCookie(const Cookie& )117 { 118 // FIXME: Implement for WebKit to use.119 } 120 121 void NetworkStorageSession::deleteCookie(const Cookie& )122 { 123 // FIXME: Implement for WebKit to use.117 void NetworkStorageSession::setCookie(const Cookie& cookie) 118 { 119 cookieStorage().setCookie(*this, cookie); 120 } 121 122 void NetworkStorageSession::deleteCookie(const Cookie& cookie) 123 { 124 cookieStorage().deleteCookie(*this, cookie); 124 125 } 125 126 … … 153 154 Vector<Cookie> NetworkStorageSession::getAllCookies() 154 155 { 156 return cookieStorage().getAllCookies(*this); 157 } 158 159 void NetworkStorageSession::getHostnamesWithCookies(HashSet<String>& hostnames) 160 { 161 cookieStorage().getHostnamesWithCookies(*this, hostnames); 162 } 163 164 Vector<Cookie> NetworkStorageSession::getCookies(const URL&) 165 { 155 166 // FIXME: Implement for WebKit to use. 156 167 return { }; 157 168 } 158 169 159 void NetworkStorageSession::getHostnamesWithCookies(HashSet<String>& hostnames)160 {161 cookieStorage().getHostnamesWithCookies(*this, hostnames);162 }163 164 Vector<Cookie> NetworkStorageSession::getCookies(const URL&)165 {166 // FIXME: Implement for WebKit to use.167 return { };168 }169 170 170 void NetworkStorageSession::hasCookies(const RegistrableDomain&, CompletionHandler<void(bool)>&& completionHandler) const 171 171 {
Note: See TracChangeset
for help on using the changeset viewer.