Diff
Modified: trunk/Source/WebCore/ChangeLog (112233 => 112234)
--- trunk/Source/WebCore/ChangeLog 2012-03-27 09:34:09 UTC (rev 112233)
+++ trunk/Source/WebCore/ChangeLog 2012-03-27 09:42:59 UTC (rev 112234)
@@ -1,3 +1,37 @@
+2012-03-27 Carlos Garcia Campos <[email protected]>
+
+ [SOUP] Implement missing methods in CookieJarSoup
+ https://bugs.webkit.org/show_bug.cgi?id=82082
+
+ Reviewed by Martin Robinson.
+
+ * platform/network/soup/CookieJarSoup.cpp:
+ (WebCore::defaultCookieJar): Return a global GRefPtr to store the
+ default cookie jar.
+ (WebCore::soupCookieJar): Return the current cookie jar or create
+ a new one.
+ (WebCore::setSoupCookieJar): Set the current cookie jar.
+ (WebCore::setCookies): Fix coding style.
+ (WebCore::cookiesForDocument): Helper function to get the list of
+ cookies as a string.
+ (WebCore::cookies): Use cookiesForDocument().
+ (WebCore::cookieRequestHeaderFieldValue): Ditto.
+ (WebCore::getRawCookies): Get the list of cookies for the given
+ document and url.
+ (WebCore::deleteCookie): Delete the given cookie.
+ (WebCore::getHostnamesWithCookies): Use GOwnPtr.
+ (WebCore::deleteCookiesForHostname): Use GOwnPtr and
+ soup_cookie_domain_matches() instead of comparing the domain
+ directly with the given hostname.
+ (WebCore::deleteAllCookies): Use GOwnPtr.
+ * platform/network/soup/CookieJarSoup.h:
+ * platform/network/soup/GOwnPtrSoup.cpp:
+ (WTF::SoupCookie): Add GOwnPtr template for SoupCookie.
+ * platform/network/soup/GOwnPtrSoup.h:
+ * platform/network/soup/ResourceHandleSoup.cpp:
+ (WebCore::ensureSessionIsInitialized): Use soupCookieJar() instead
+ of defaultCookieJar().
+
2012-03-27 Nikolas Zimmermann <[email protected]>
Enable animVal support for SVGAnimatedBoolean
Modified: trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp (112233 => 112234)
--- trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp 2012-03-27 09:34:09 UTC (rev 112233)
+++ trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp 2012-03-27 09:42:59 UTC (rev 112234)
@@ -29,13 +29,11 @@
#include "KURL.h"
#include "NetworkingContext.h"
#include "ResourceHandle.h"
+#include <wtf/gobject/GRefPtr.h>
#include <wtf/text/CString.h>
namespace WebCore {
-static bool cookiesInitialized;
-static SoupCookieJar* cookieJar;
-
static SoupCookieJar* cookieJarForDocument(const Document* document)
{
if (!document)
@@ -52,29 +50,26 @@
return SOUP_COOKIE_JAR(soup_session_get_feature(context->soupSession(), SOUP_TYPE_COOKIE_JAR));
}
-SoupCookieJar* defaultCookieJar()
+static GRefPtr<SoupCookieJar>& defaultCookieJar()
{
- if (!cookiesInitialized) {
- cookiesInitialized = true;
-
- cookieJar = soup_cookie_jar_new();
- soup_cookie_jar_set_accept_policy(cookieJar, SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY);
- }
-
+ DEFINE_STATIC_LOCAL(GRefPtr<SoupCookieJar>, cookieJar, ());
return cookieJar;
}
-void setDefaultCookieJar(SoupCookieJar* jar)
+SoupCookieJar* soupCookieJar()
{
- cookiesInitialized = true;
+ if (GRefPtr<SoupCookieJar>& jar = defaultCookieJar())
+ return jar.get();
- if (cookieJar)
- g_object_unref(cookieJar);
+ SoupCookieJar* jar = soup_cookie_jar_new();
+ soup_cookie_jar_set_accept_policy(jar, SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY);
+ setSoupCookieJar(jar);
+ return jar;
+}
- cookieJar = jar;
-
- if (cookieJar)
- g_object_ref(cookieJar);
+void setSoupCookieJar(SoupCookieJar* jar)
+{
+ defaultCookieJar() = jar;
}
void setCookies(Document* document, const KURL& url, const String& value)
@@ -84,45 +79,29 @@
return;
GOwnPtr<SoupURI> origin(soup_uri_new(url.string().utf8().data()));
-
GOwnPtr<SoupURI> firstParty(soup_uri_new(document->firstPartyForCookies().string().utf8().data()));
-
- soup_cookie_jar_set_cookie_with_first_party(jar,
- origin.get(),
- firstParty.get(),
- value.utf8().data());
+ soup_cookie_jar_set_cookie_with_first_party(jar, origin.get(), firstParty.get(), value.utf8().data());
}
-String cookies(const Document* document, const KURL& url)
+static String cookiesForDocument(const Document* document, const KURL& url, bool forHTTPHeader)
{
SoupCookieJar* jar = cookieJarForDocument(document);
if (!jar)
return String();
- SoupURI* uri = soup_uri_new(url.string().utf8().data());
- char* cookies = soup_cookie_jar_get_cookies(jar, uri, FALSE);
- soup_uri_free(uri);
+ GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data()));
+ GOwnPtr<char> cookies(soup_cookie_jar_get_cookies(jar, uri.get(), forHTTPHeader));
+ return String::fromUTF8(cookies.get());
+}
- String result(String::fromUTF8(cookies));
- g_free(cookies);
-
- return result;
+String cookies(const Document* document, const KURL& url)
+{
+ return cookiesForDocument(document, url, false);
}
String cookieRequestHeaderFieldValue(const Document* document, const KURL& url)
{
- SoupCookieJar* jar = cookieJarForDocument(document);
- if (!jar)
- return String();
-
- SoupURI* uri = soup_uri_new(url.string().utf8().data());
- char* cookies = soup_cookie_jar_get_cookies(jar, uri, TRUE);
- soup_uri_free(uri);
-
- String result(String::fromUTF8(cookies));
- g_free(cookies);
-
- return result;
+ return cookiesForDocument(document, url, true);
}
bool cookiesEnabled(const Document* document)
@@ -130,54 +109,87 @@
return !!cookieJarForDocument(document);
}
-bool getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
+bool getRawCookies(const Document* document, const KURL& url, Vector<Cookie>& rawCookies)
{
- // FIXME: Not yet implemented
rawCookies.clear();
- return false; // return true when implemented
+ SoupCookieJar* jar = cookieJarForDocument(document);
+ if (!jar)
+ return false;
+
+ GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(jar));
+ if (!cookies)
+ return false;
+
+ GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data()));
+ for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) {
+ GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(iter->data));
+ if (!soup_cookie_applies_to_uri(cookie.get(), uri.get()))
+ continue;
+ // FIXME: we are currently passing false always for session because there's no API to know
+ // whether SoupCookieJar is persistent or not. We could probably add soup_cookie_jar_is_persistent().
+ rawCookies.append(Cookie(String::fromUTF8(cookie->name), String::fromUTF8(cookie->value), String::fromUTF8(cookie->domain),
+ String::fromUTF8(cookie->path), static_cast<double>(soup_date_to_time_t(cookie->expires)) * 1000,
+ cookie->http_only, cookie->secure, false));
+ }
+
+ return true;
}
-void deleteCookie(const Document*, const KURL&, const String&)
+void deleteCookie(const Document* document, const KURL& url, const String& name)
{
- // FIXME: Not yet implemented
+ SoupCookieJar* jar = cookieJarForDocument(document);
+ if (!jar)
+ return;
+
+ GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(jar));
+ if (!cookies)
+ return;
+
+ CString cookieName = name.utf8();
+ GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data()));
+ for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) {
+ GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(iter->data));
+ if (!soup_cookie_applies_to_uri(cookie.get(), uri.get()))
+ continue;
+ if (cookieName == cookie->name)
+ soup_cookie_jar_delete_cookie(jar, cookie.get());
+ }
}
void getHostnamesWithCookies(HashSet<String>& hostnames)
{
- SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
- GSList* cookies = soup_cookie_jar_all_cookies(cookieJar);
- for (GSList* item = cookies; item; item = item->next) {
- SoupCookie* soupCookie = static_cast<SoupCookie*>(item->data);
- if (char* domain = const_cast<char*>(soup_cookie_get_domain(soupCookie)))
- hostnames.add(String::fromUTF8(domain));
+ SoupCookieJar* cookieJar = soupCookieJar();
+ GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar));
+ for (GSList* item = cookies.get(); item; item = g_slist_next(item)) {
+ GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(item->data));
+ if (!cookie->domain)
+ continue;
+ hostnames.add(String::fromUTF8(cookie->domain));
}
-
- soup_cookies_free(cookies);
}
void deleteCookiesForHostname(const String& hostname)
{
CString hostNameString = hostname.utf8();
-
- SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
- GSList* cookies = soup_cookie_jar_all_cookies(cookieJar);
- for (GSList* item = cookies; item; item = item->next) {
- SoupCookie* soupCookie = static_cast<SoupCookie*>(item->data);
- if (hostNameString == soup_cookie_get_domain(soupCookie))
- soup_cookie_jar_delete_cookie(cookieJar, soupCookie);
+ SoupCookieJar* cookieJar = soupCookieJar();
+ GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar));
+ for (GSList* item = cookies.get(); item; item = g_slist_next(item)) {
+ SoupCookie* cookie = static_cast<SoupCookie*>(item->data);
+ if (soup_cookie_domain_matches(cookie, hostNameString.data()))
+ soup_cookie_jar_delete_cookie(cookieJar, cookie);
+ soup_cookie_free(cookie);
}
-
- soup_cookies_free(cookies);
}
void deleteAllCookies()
{
- SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
- GSList* cookies = soup_cookie_jar_all_cookies(cookieJar);
- for (GSList* item = cookies; item; item = item->next)
- soup_cookie_jar_delete_cookie(cookieJar, static_cast<SoupCookie*>(item->data));
-
- soup_cookies_free(cookies);
+ SoupCookieJar* cookieJar = soupCookieJar();
+ GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar));
+ for (GSList* item = cookies.get(); item; item = g_slist_next(item)) {
+ SoupCookie* cookie = static_cast<SoupCookie*>(item->data);
+ soup_cookie_jar_delete_cookie(cookieJar, cookie);
+ soup_cookie_free(cookie);
+ }
}
}
Modified: trunk/Source/WebCore/platform/network/soup/CookieJarSoup.h (112233 => 112234)
--- trunk/Source/WebCore/platform/network/soup/CookieJarSoup.h 2012-03-27 09:34:09 UTC (rev 112233)
+++ trunk/Source/WebCore/platform/network/soup/CookieJarSoup.h 2012-03-27 09:42:59 UTC (rev 112234)
@@ -31,8 +31,10 @@
#include <libsoup/soup.h>
namespace WebCore {
- SoupCookieJar* defaultCookieJar();
- void setDefaultCookieJar(SoupCookieJar* jar);
+
+SoupCookieJar* soupCookieJar();
+void setSoupCookieJar(SoupCookieJar*);
+
}
#endif
Modified: trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.cpp (112233 => 112234)
--- trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.cpp 2012-03-27 09:34:09 UTC (rev 112233)
+++ trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.cpp 2012-03-27 09:42:59 UTC (rev 112234)
@@ -20,6 +20,7 @@
#include "config.h"
#include "GOwnPtrSoup.h"
+#include <libsoup/soup-cookie.h>
#include <libsoup/soup-uri.h>
namespace WTF {
@@ -30,4 +31,10 @@
soup_uri_free(ptr);
}
+template <> void freeOwnedGPtr<SoupCookie>(SoupCookie* ptr)
+{
+ if (ptr)
+ soup_cookie_free(ptr);
}
+
+}
Modified: trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.h (112233 => 112234)
--- trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.h 2012-03-27 09:34:09 UTC (rev 112233)
+++ trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.h 2012-03-27 09:42:59 UTC (rev 112234)
@@ -23,10 +23,12 @@
#include <wtf/gobject/GOwnPtr.h>
typedef struct _SoupURI SoupURI;
+typedef struct _SoupCookie SoupCookie;
namespace WTF {
template<> void freeOwnedGPtr<SoupURI>(SoupURI* ptr);
+template<> void freeOwnedGPtr<SoupCookie>(SoupCookie* ptr);
}
Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (112233 => 112234)
--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp 2012-03-27 09:34:09 UTC (rev 112233)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp 2012-03-27 09:42:59 UTC (rev 112234)
@@ -159,9 +159,9 @@
if (session == ResourceHandle::defaultSession()) {
SoupCookieJar* jar = SOUP_COOKIE_JAR(soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR));
if (!jar)
- soup_session_add_feature(session, SOUP_SESSION_FEATURE(defaultCookieJar()));
+ soup_session_add_feature(session, SOUP_SESSION_FEATURE(soupCookieJar()));
else
- setDefaultCookieJar(jar);
+ setSoupCookieJar(jar);
}
if (!soup_session_get_feature(session, SOUP_TYPE_LOGGER) && LogNetwork.state == WTFLogChannelOn) {
Modified: trunk/Source/WebKit/efl/ChangeLog (112233 => 112234)
--- trunk/Source/WebKit/efl/ChangeLog 2012-03-27 09:34:09 UTC (rev 112233)
+++ trunk/Source/WebKit/efl/ChangeLog 2012-03-27 09:42:59 UTC (rev 112234)
@@ -1,3 +1,18 @@
+2012-03-27 Carlos Garcia Campos <[email protected]>
+
+ [SOUP] Implement missing methods in CookieJarSoup
+ https://bugs.webkit.org/show_bug.cgi?id=82082
+
+ Reviewed by Martin Robinson.
+
+ * ewk/ewk_cookies.cpp:
+ (ewk_cookies_clear): Use soupCookieJar() instead of
+ defaultCookieJar().
+ (ewk_cookies_get_all): Ditto.
+ (ewk_cookies_cookie_del): Ditto.
+ (ewk_cookies_policy_set): Ditto.
+ (ewk_cookies_policy_get): Ditto.
+
2012-03-23 Grzegorz Czajkowski <[email protected]>
[EFL][DRT] Implement LayoutTestController's methods related with editing.
Modified: trunk/Source/WebKit/efl/ewk/ewk_cookies.cpp (112233 => 112234)
--- trunk/Source/WebKit/efl/ewk/ewk_cookies.cpp 2012-03-27 09:34:09 UTC (rev 112233)
+++ trunk/Source/WebKit/efl/ewk/ewk_cookies.cpp 2012-03-27 09:42:59 UTC (rev 112234)
@@ -47,7 +47,7 @@
if (oldjar)
soup_session_remove_feature(session, oldjar);
- WebCore::setDefaultCookieJar(cookieJar);
+ WebCore::setSoupCookieJar(cookieJar);
soup_session_add_feature(session, SOUP_SESSION_FEATURE(cookieJar));
return true;
@@ -57,7 +57,7 @@
{
GSList* list;
GSList* p;
- SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
+ SoupCookieJar* cookieJar = WebCore::soupCookieJar();
list = soup_cookie_jar_all_cookies(cookieJar);
for (p = list; p; p = p->next)
@@ -71,7 +71,7 @@
Eina_List* result = 0;
GSList* list;
GSList* p;
- SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
+ SoupCookieJar* cookieJar = WebCore::soupCookieJar();
list = soup_cookie_jar_all_cookies(cookieJar);
for (p = list; p; p = p->next) {
@@ -97,7 +97,7 @@
EINA_SAFETY_ON_NULL_RETURN(cookie);
GSList* list;
GSList* p;
- SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
+ SoupCookieJar* cookieJar = WebCore::soupCookieJar();
SoupCookie* cookie1 = soup_cookie_new(
cookie->name, cookie->value, cookie->domain, cookie->path, -1);
@@ -126,7 +126,7 @@
void ewk_cookies_policy_set(Ewk_Cookie_Policy cookiePolicy)
{
- SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
+ SoupCookieJar* cookieJar = WebCore::soupCookieJar();
SoupCookieJarAcceptPolicy policy;
policy = SOUP_COOKIE_JAR_ACCEPT_ALWAYS;
@@ -148,7 +148,7 @@
Ewk_Cookie_Policy ewk_cookies_policy_get(void)
{
Ewk_Cookie_Policy ewkPolicy = EWK_COOKIE_JAR_ACCEPT_ALWAYS;
- SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
+ SoupCookieJar* cookieJar = WebCore::soupCookieJar();
SoupCookieJarAcceptPolicy policy;
policy = soup_cookie_jar_get_accept_policy(cookieJar);
Modified: trunk/Source/WebKit2/ChangeLog (112233 => 112234)
--- trunk/Source/WebKit2/ChangeLog 2012-03-27 09:34:09 UTC (rev 112233)
+++ trunk/Source/WebKit2/ChangeLog 2012-03-27 09:42:59 UTC (rev 112234)
@@ -1,5 +1,17 @@
2012-03-27 Carlos Garcia Campos <[email protected]>
+ [SOUP] Implement missing methods in CookieJarSoup
+ https://bugs.webkit.org/show_bug.cgi?id=82082
+
+ Reviewed by Martin Robinson.
+
+ * WebProcess/Cookies/soup/WebCookieManagerSoup.cpp:
+ (WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy): Use
+ soupCookieJar() instead of defaultCookieJar().
+ (WebKit::WebCookieManager::platformGetHTTPCookieAcceptPolicy): Ditto.
+
+2012-03-27 Carlos Garcia Campos <[email protected]>
+
[GTK] Add method webkit_web_resource_get_data() to WebKit2 GTK+ API
https://bugs.webkit.org/show_bug.cgi?id=79667
Modified: trunk/Source/WebKit2/WebProcess/Cookies/soup/WebCookieManagerSoup.cpp (112233 => 112234)
--- trunk/Source/WebKit2/WebProcess/Cookies/soup/WebCookieManagerSoup.cpp 2012-03-27 09:34:09 UTC (rev 112233)
+++ trunk/Source/WebKit2/WebProcess/Cookies/soup/WebCookieManagerSoup.cpp 2012-03-27 09:42:59 UTC (rev 112234)
@@ -35,7 +35,7 @@
void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
{
- SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
+ SoupCookieJar* cookieJar = WebCore::soupCookieJar();
SoupCookieJarAcceptPolicy soupPolicy;
soupPolicy = SOUP_COOKIE_JAR_ACCEPT_ALWAYS;
@@ -55,7 +55,7 @@
HTTPCookieAcceptPolicy WebCookieManager::platformGetHTTPCookieAcceptPolicy()
{
- SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
+ SoupCookieJar* cookieJar = WebCore::soupCookieJar();
SoupCookieJarAcceptPolicy soupPolicy;
HTTPCookieAcceptPolicy policy;