Changeset 112234 in webkit
- Timestamp:
- Mar 27, 2012 2:42:59 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r112231 r112234 1 2012-03-27 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [SOUP] Implement missing methods in CookieJarSoup 4 https://bugs.webkit.org/show_bug.cgi?id=82082 5 6 Reviewed by Martin Robinson. 7 8 * platform/network/soup/CookieJarSoup.cpp: 9 (WebCore::defaultCookieJar): Return a global GRefPtr to store the 10 default cookie jar. 11 (WebCore::soupCookieJar): Return the current cookie jar or create 12 a new one. 13 (WebCore::setSoupCookieJar): Set the current cookie jar. 14 (WebCore::setCookies): Fix coding style. 15 (WebCore::cookiesForDocument): Helper function to get the list of 16 cookies as a string. 17 (WebCore::cookies): Use cookiesForDocument(). 18 (WebCore::cookieRequestHeaderFieldValue): Ditto. 19 (WebCore::getRawCookies): Get the list of cookies for the given 20 document and url. 21 (WebCore::deleteCookie): Delete the given cookie. 22 (WebCore::getHostnamesWithCookies): Use GOwnPtr. 23 (WebCore::deleteCookiesForHostname): Use GOwnPtr and 24 soup_cookie_domain_matches() instead of comparing the domain 25 directly with the given hostname. 26 (WebCore::deleteAllCookies): Use GOwnPtr. 27 * platform/network/soup/CookieJarSoup.h: 28 * platform/network/soup/GOwnPtrSoup.cpp: 29 (WTF::SoupCookie): Add GOwnPtr template for SoupCookie. 30 * platform/network/soup/GOwnPtrSoup.h: 31 * platform/network/soup/ResourceHandleSoup.cpp: 32 (WebCore::ensureSessionIsInitialized): Use soupCookieJar() instead 33 of defaultCookieJar(). 34 1 35 2012-03-27 Nikolas Zimmermann <nzimmermann@rim.com> 2 36 -
trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp
r107854 r112234 30 30 #include "NetworkingContext.h" 31 31 #include "ResourceHandle.h" 32 #include <wtf/gobject/GRefPtr.h> 32 33 #include <wtf/text/CString.h> 33 34 34 35 namespace WebCore { 35 36 static bool cookiesInitialized;37 static SoupCookieJar* cookieJar;38 36 39 37 static SoupCookieJar* cookieJarForDocument(const Document* document) … … 53 51 } 54 52 55 SoupCookieJar*defaultCookieJar()53 static GRefPtr<SoupCookieJar>& defaultCookieJar() 56 54 { 57 if (!cookiesInitialized) { 58 cookiesInitialized = true; 59 60 cookieJar = soup_cookie_jar_new(); 61 soup_cookie_jar_set_accept_policy(cookieJar, SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY); 62 } 63 55 DEFINE_STATIC_LOCAL(GRefPtr<SoupCookieJar>, cookieJar, ()); 64 56 return cookieJar; 65 57 } 66 58 67 void setDefaultCookieJar(SoupCookieJar* jar)59 SoupCookieJar* soupCookieJar() 68 60 { 69 cookiesInitialized = true; 61 if (GRefPtr<SoupCookieJar>& jar = defaultCookieJar()) 62 return jar.get(); 70 63 71 if (cookieJar) 72 g_object_unref(cookieJar); 64 SoupCookieJar* jar = soup_cookie_jar_new(); 65 soup_cookie_jar_set_accept_policy(jar, SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY); 66 setSoupCookieJar(jar); 67 return jar; 68 } 73 69 74 cookieJar = jar; 75 76 if (cookieJar) 77 g_object_ref(cookieJar); 70 void setSoupCookieJar(SoupCookieJar* jar) 71 { 72 defaultCookieJar() = jar; 78 73 } 79 74 … … 85 80 86 81 GOwnPtr<SoupURI> origin(soup_uri_new(url.string().utf8().data())); 87 88 82 GOwnPtr<SoupURI> firstParty(soup_uri_new(document->firstPartyForCookies().string().utf8().data())); 89 90 soup_cookie_jar_set_cookie_with_first_party(jar, 91 origin.get(), 92 firstParty.get(), 93 value.utf8().data()); 83 soup_cookie_jar_set_cookie_with_first_party(jar, origin.get(), firstParty.get(), value.utf8().data()); 94 84 } 95 85 96 String cookies(const Document* document, const KURL& url)86 static String cookiesForDocument(const Document* document, const KURL& url, bool forHTTPHeader) 97 87 { 98 88 SoupCookieJar* jar = cookieJarForDocument(document); … … 100 90 return String(); 101 91 102 SoupURI* uri = soup_uri_new(url.string().utf8().data()); 103 char* cookies = soup_cookie_jar_get_cookies(jar, uri, FALSE); 104 soup_uri_free(uri); 92 GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data())); 93 GOwnPtr<char> cookies(soup_cookie_jar_get_cookies(jar, uri.get(), forHTTPHeader)); 94 return String::fromUTF8(cookies.get()); 95 } 105 96 106 String result(String::fromUTF8(cookies)); 107 g_free(cookies); 108 109 return result; 97 String cookies(const Document* document, const KURL& url) 98 { 99 return cookiesForDocument(document, url, false); 110 100 } 111 101 112 102 String cookieRequestHeaderFieldValue(const Document* document, const KURL& url) 113 103 { 114 SoupCookieJar* jar = cookieJarForDocument(document); 115 if (!jar) 116 return String(); 117 118 SoupURI* uri = soup_uri_new(url.string().utf8().data()); 119 char* cookies = soup_cookie_jar_get_cookies(jar, uri, TRUE); 120 soup_uri_free(uri); 121 122 String result(String::fromUTF8(cookies)); 123 g_free(cookies); 124 125 return result; 104 return cookiesForDocument(document, url, true); 126 105 } 127 106 … … 131 110 } 132 111 133 bool getRawCookies(const Document* , const KURL&, Vector<Cookie>& rawCookies)112 bool getRawCookies(const Document* document, const KURL& url, Vector<Cookie>& rawCookies) 134 113 { 135 // FIXME: Not yet implemented136 114 rawCookies.clear(); 137 return false; // return true when implemented 115 SoupCookieJar* jar = cookieJarForDocument(document); 116 if (!jar) 117 return false; 118 119 GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(jar)); 120 if (!cookies) 121 return false; 122 123 GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data())); 124 for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) { 125 GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(iter->data)); 126 if (!soup_cookie_applies_to_uri(cookie.get(), uri.get())) 127 continue; 128 // FIXME: we are currently passing false always for session because there's no API to know 129 // whether SoupCookieJar is persistent or not. We could probably add soup_cookie_jar_is_persistent(). 130 rawCookies.append(Cookie(String::fromUTF8(cookie->name), String::fromUTF8(cookie->value), String::fromUTF8(cookie->domain), 131 String::fromUTF8(cookie->path), static_cast<double>(soup_date_to_time_t(cookie->expires)) * 1000, 132 cookie->http_only, cookie->secure, false)); 133 } 134 135 return true; 138 136 } 139 137 140 void deleteCookie(const Document* , const KURL&, const String&)138 void deleteCookie(const Document* document, const KURL& url, const String& name) 141 139 { 142 // FIXME: Not yet implemented 140 SoupCookieJar* jar = cookieJarForDocument(document); 141 if (!jar) 142 return; 143 144 GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(jar)); 145 if (!cookies) 146 return; 147 148 CString cookieName = name.utf8(); 149 GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data())); 150 for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) { 151 GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(iter->data)); 152 if (!soup_cookie_applies_to_uri(cookie.get(), uri.get())) 153 continue; 154 if (cookieName == cookie->name) 155 soup_cookie_jar_delete_cookie(jar, cookie.get()); 156 } 143 157 } 144 158 145 159 void getHostnamesWithCookies(HashSet<String>& hostnames) 146 160 { 147 SoupCookieJar* cookieJar = WebCore::defaultCookieJar(); 148 GSList* cookies = soup_cookie_jar_all_cookies(cookieJar); 149 for (GSList* item = cookies; item; item = item->next) { 150 SoupCookie* soupCookie = static_cast<SoupCookie*>(item->data); 151 if (char* domain = const_cast<char*>(soup_cookie_get_domain(soupCookie))) 152 hostnames.add(String::fromUTF8(domain)); 161 SoupCookieJar* cookieJar = soupCookieJar(); 162 GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); 163 for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { 164 GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(item->data)); 165 if (!cookie->domain) 166 continue; 167 hostnames.add(String::fromUTF8(cookie->domain)); 153 168 } 154 155 soup_cookies_free(cookies);156 169 } 157 170 … … 159 172 { 160 173 CString hostNameString = hostname.utf8(); 161 162 SoupCookieJar* cookieJar = WebCore::defaultCookieJar();163 GSList* cookies = soup_cookie_jar_all_cookies(cookieJar);164 for (GSList* item = cookies; item; item = item->next) {165 SoupCookie* soupCookie = static_cast<SoupCookie*>(item->data);166 if (hostNameString == soup_cookie_get_domain(soupCookie))167 soup_cookie_jar_delete_cookie(cookieJar, soupCookie);174 SoupCookieJar* cookieJar = soupCookieJar(); 175 GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); 176 for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { 177 SoupCookie* cookie = static_cast<SoupCookie*>(item->data); 178 if (soup_cookie_domain_matches(cookie, hostNameString.data())) 179 soup_cookie_jar_delete_cookie(cookieJar, cookie); 180 soup_cookie_free(cookie); 168 181 } 169 170 soup_cookies_free(cookies);171 182 } 172 183 173 184 void deleteAllCookies() 174 185 { 175 SoupCookieJar* cookieJar = WebCore::defaultCookieJar(); 176 GSList* cookies = soup_cookie_jar_all_cookies(cookieJar); 177 for (GSList* item = cookies; item; item = item->next) 178 soup_cookie_jar_delete_cookie(cookieJar, static_cast<SoupCookie*>(item->data)); 179 180 soup_cookies_free(cookies); 186 SoupCookieJar* cookieJar = soupCookieJar(); 187 GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); 188 for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { 189 SoupCookie* cookie = static_cast<SoupCookie*>(item->data); 190 soup_cookie_jar_delete_cookie(cookieJar, cookie); 191 soup_cookie_free(cookie); 192 } 181 193 } 182 194 -
trunk/Source/WebCore/platform/network/soup/CookieJarSoup.h
r41139 r112234 32 32 33 33 namespace WebCore { 34 SoupCookieJar* defaultCookieJar(); 35 void setDefaultCookieJar(SoupCookieJar* jar); 34 35 SoupCookieJar* soupCookieJar(); 36 void setSoupCookieJar(SoupCookieJar*); 37 36 38 } 37 39 -
trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.cpp
r95901 r112234 21 21 #include "GOwnPtrSoup.h" 22 22 23 #include <libsoup/soup-cookie.h> 23 24 #include <libsoup/soup-uri.h> 24 25 … … 31 32 } 32 33 34 template <> void freeOwnedGPtr<SoupCookie>(SoupCookie* ptr) 35 { 36 if (ptr) 37 soup_cookie_free(ptr); 33 38 } 39 40 } -
trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.h
r111354 r112234 24 24 25 25 typedef struct _SoupURI SoupURI; 26 typedef struct _SoupCookie SoupCookie; 26 27 27 28 namespace WTF { 28 29 29 30 template<> void freeOwnedGPtr<SoupURI>(SoupURI* ptr); 31 template<> void freeOwnedGPtr<SoupCookie>(SoupCookie* ptr); 30 32 31 33 } -
trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
r110669 r112234 160 160 SoupCookieJar* jar = SOUP_COOKIE_JAR(soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR)); 161 161 if (!jar) 162 soup_session_add_feature(session, SOUP_SESSION_FEATURE( defaultCookieJar()));162 soup_session_add_feature(session, SOUP_SESSION_FEATURE(soupCookieJar())); 163 163 else 164 set DefaultCookieJar(jar);164 setSoupCookieJar(jar); 165 165 } 166 166 -
trunk/Source/WebKit/efl/ChangeLog
r111835 r112234 1 2012-03-27 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [SOUP] Implement missing methods in CookieJarSoup 4 https://bugs.webkit.org/show_bug.cgi?id=82082 5 6 Reviewed by Martin Robinson. 7 8 * ewk/ewk_cookies.cpp: 9 (ewk_cookies_clear): Use soupCookieJar() instead of 10 defaultCookieJar(). 11 (ewk_cookies_get_all): Ditto. 12 (ewk_cookies_cookie_del): Ditto. 13 (ewk_cookies_policy_set): Ditto. 14 (ewk_cookies_policy_get): Ditto. 15 1 16 2012-03-23 Grzegorz Czajkowski <g.czajkowski@samsung.com> 2 17 -
trunk/Source/WebKit/efl/ewk/ewk_cookies.cpp
r109205 r112234 48 48 soup_session_remove_feature(session, oldjar); 49 49 50 WebCore::set DefaultCookieJar(cookieJar);50 WebCore::setSoupCookieJar(cookieJar); 51 51 soup_session_add_feature(session, SOUP_SESSION_FEATURE(cookieJar)); 52 52 … … 58 58 GSList* list; 59 59 GSList* p; 60 SoupCookieJar* cookieJar = WebCore:: defaultCookieJar();60 SoupCookieJar* cookieJar = WebCore::soupCookieJar(); 61 61 62 62 list = soup_cookie_jar_all_cookies(cookieJar); … … 72 72 GSList* list; 73 73 GSList* p; 74 SoupCookieJar* cookieJar = WebCore:: defaultCookieJar();74 SoupCookieJar* cookieJar = WebCore::soupCookieJar(); 75 75 76 76 list = soup_cookie_jar_all_cookies(cookieJar); … … 98 98 GSList* list; 99 99 GSList* p; 100 SoupCookieJar* cookieJar = WebCore:: defaultCookieJar();100 SoupCookieJar* cookieJar = WebCore::soupCookieJar(); 101 101 SoupCookie* cookie1 = soup_cookie_new( 102 102 cookie->name, cookie->value, cookie->domain, cookie->path, -1); … … 127 127 void ewk_cookies_policy_set(Ewk_Cookie_Policy cookiePolicy) 128 128 { 129 SoupCookieJar* cookieJar = WebCore:: defaultCookieJar();129 SoupCookieJar* cookieJar = WebCore::soupCookieJar(); 130 130 SoupCookieJarAcceptPolicy policy; 131 131 … … 149 149 { 150 150 Ewk_Cookie_Policy ewkPolicy = EWK_COOKIE_JAR_ACCEPT_ALWAYS; 151 SoupCookieJar* cookieJar = WebCore:: defaultCookieJar();151 SoupCookieJar* cookieJar = WebCore::soupCookieJar(); 152 152 SoupCookieJarAcceptPolicy policy; 153 153 -
trunk/Source/WebKit2/ChangeLog
r112227 r112234 1 2012-03-27 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [SOUP] Implement missing methods in CookieJarSoup 4 https://bugs.webkit.org/show_bug.cgi?id=82082 5 6 Reviewed by Martin Robinson. 7 8 * WebProcess/Cookies/soup/WebCookieManagerSoup.cpp: 9 (WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy): Use 10 soupCookieJar() instead of defaultCookieJar(). 11 (WebKit::WebCookieManager::platformGetHTTPCookieAcceptPolicy): Ditto. 12 1 13 2012-03-27 Carlos Garcia Campos <cgarcia@igalia.com> 2 14 -
trunk/Source/WebKit2/WebProcess/Cookies/soup/WebCookieManagerSoup.cpp
r100362 r112234 36 36 void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) 37 37 { 38 SoupCookieJar* cookieJar = WebCore:: defaultCookieJar();38 SoupCookieJar* cookieJar = WebCore::soupCookieJar(); 39 39 SoupCookieJarAcceptPolicy soupPolicy; 40 40 … … 56 56 HTTPCookieAcceptPolicy WebCookieManager::platformGetHTTPCookieAcceptPolicy() 57 57 { 58 SoupCookieJar* cookieJar = WebCore:: defaultCookieJar();58 SoupCookieJar* cookieJar = WebCore::soupCookieJar(); 59 59 SoupCookieJarAcceptPolicy soupPolicy; 60 60
Note: See TracChangeset
for help on using the changeset viewer.