bool getRawCookies(const Document*, const KURL& url, Vector<Cookie>& rawCookies) { rawCookies.clear(); CFHTTPCookieStorageRef cookieStorage = currentCookieStorage(); if (!cookieStorage) return false; RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL()); bool sendSecureCookies = url.protocolIs("https"); RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(cookieStorage, urlCF.get(), sendSecureCookies)); CFIndex count = CFArrayGetCount(cookiesCF.get()); rawCookies.reserveCapacity(count); for (CFIndex i = 0; i < count; i++) { CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(cookiesCF.get(), i); String name = CFHTTPCookieGetName(cookie); String value = CFHTTPCookieGetValue(cookie); String domain = CFHTTPCookieGetDomain(cookie); String path = CFHTTPCookieGetPath(cookie); double expires = (CFDateGetAbsoluteTime(CFHTTPCookieGetExpiratonDate(cookie)) + kCFAbsoluteTimeIntervalSince1970) * 1000; bool httpOnly = CFHTTPCookieIsHTTPOnly(cookie); bool secure = CFHTTPCookieIsSecure(cookie); bool session = false; // FIXME: Need API for if a cookie is a session cookie. rawCookies.uncheckedAppend(Cookie(name, value, domain, path, expires, httpOnly, secure, session)); } return true; }
JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(CFHTTPCookieGetValue) (JNIEnv *env, jclass that, jintLong arg0) { jintLong rc = 0; WebKit_win32_NATIVE_ENTER(env, that, CFHTTPCookieGetValue_FUNC); rc = (jintLong)CFHTTPCookieGetValue((CFHTTPCookieRef)arg0); WebKit_win32_NATIVE_EXIT(env, that, CFHTTPCookieGetValue_FUNC); return rc; }