Vector<ParsedCookie*> CookieParser::parse(const String& cookies) { unsigned cookieStart, cookieEnd = 0; double curTime = currentTime(); Vector<ParsedCookie*, 4> parsedCookies; unsigned cookiesLength = cookies.length(); if (!cookiesLength) // Code below doesn't handle this case return parsedCookies; // Iterate over the header to parse all the cookies. while (cookieEnd <= cookiesLength) { cookieStart = cookieEnd; // Find a cookie separator. while (cookieEnd <= cookiesLength && !isCookieHeaderSeparator(cookies[cookieEnd])) cookieEnd++; // Detect an empty cookie and go to the next one. if (cookieStart == cookieEnd) { ++cookieEnd; continue; } if (cookieEnd < cookiesLength && isCookieHeaderSeparator(cookies[cookieEnd])) ++cookieEnd; ParsedCookie* cookie = parseOneCookie(cookies, cookieStart, cookieEnd - 1, curTime); if (cookie) parsedCookies.append(cookie); } return parsedCookies; }
Vector<Cookie*> CookieParser::parse(const String& cookies) { unsigned cookieStart, cookieEnd = 0; double curTime = currentTime(); Vector<Cookie*, 4> parsedCookies; // Iterate over the header to parse all the cookies. while (cookieEnd <= cookies.length()) { cookieStart = cookieEnd; // Find a cookie separator. while (cookieEnd <= cookies.length() && !isCookieHeaderSeparator(cookies[cookieEnd])) cookieEnd++; Cookie* cookie = parseOneCookie(cookies, cookieStart, cookieEnd - 1, curTime); if (cookie) parsedCookies.append(cookie); } return parsedCookies; }
void CookieManager::setCookieInPrivateMode(const URL& url, const String& value, CookieFilter filter) { if (m_acceptPolicy == Never) return; RefPtr<ParsedCookie> cookie = parseOneCookie(url, value); if (!cookie || cookie->name().isEmpty()) return; if (filter == NoHttpOnlyCookies && cookie->isHttpOnly()) return; Vector<String> domain; cookie->domain().split(".", false, domain); m_privateCookiesTree->insert(cookie, domain, m_backingStore.get(), filter, OnlyInMemory); if (m_cookieChangeCallback) m_cookieChangeCallback(); }
PassRefPtr<ParsedCookie> CookieParser::parseOneCookie(const String& cookie) { return parseOneCookie(cookie, 0, cookie.length() - 1, currentTime()); }