Skip to content

Commit

Permalink
[WebKitBrowser] CookieJar updated to 2.42 WebKit API (#265)
Browse files Browse the repository at this point in the history
* webkit_cookie_manager_get_cookie_jar() replaced by webkit_cookie_manager_get_all_cookies() in 2.42

* webkit_cookie_manager_set_cookie_jar replaced by webkit_cookie_manager_replace_cookies in 2.42
  • Loading branch information
VeithMetro authored Dec 1, 2023
1 parent e19f45c commit 7261bca
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions WebKitBrowser/WebKitImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1522,9 +1522,13 @@ static GSourceFuncs _handlerIntervention =
#ifdef WEBKIT_GLIB_API
WebKitWebContext* context = webkit_web_view_get_context(_view);
WebKitCookieManager* manager = webkit_web_context_get_cookie_manager(context);
#if WEBKIT_CHECK_VERSION(2, 42, 0)
webkit_cookie_manager_get_all_cookies(manager, NULL, [](GObject* object, GAsyncResult* result, gpointer user_data) {
GList* cookies_list = webkit_cookie_manager_get_all_cookies_finish(WEBKIT_COOKIE_MANAGER(object), result, nullptr);
#else
webkit_cookie_manager_get_cookie_jar(manager, NULL, [](GObject* object, GAsyncResult* result, gpointer user_data) {
GList* cookies_list = webkit_cookie_manager_get_cookie_jar_finish(WEBKIT_COOKIE_MANAGER(object), result, nullptr);

#endif
std::vector<std::string> cookieVector;
cookieVector.reserve(g_list_length(cookies_list));
for (GList* it = cookies_list; it != NULL; it = g_list_next(it)) {
Expand Down Expand Up @@ -1640,8 +1644,11 @@ static GSourceFuncs _handlerIntervention =

WebKitWebContext* context = webkit_web_view_get_context(_view);
WebKitCookieManager* manager = webkit_web_context_get_cookie_manager(context);
#if WEBKIT_CHECK_VERSION(2, 42, 0)
webkit_cookie_manager_replace_cookies(manager, g_list_reverse(cookies_list), nullptr, nullptr, nullptr);
#else
webkit_cookie_manager_set_cookie_jar(manager, g_list_reverse(cookies_list), nullptr, nullptr, nullptr);

#endif
g_list_free_full(cookies_list, reinterpret_cast<GDestroyNotify>(soup_cookie_free));
#else
auto toWKCookie = [](SoupCookie* cookie) -> WKCookieRef
Expand Down

0 comments on commit 7261bca

Please sign in to comment.