void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies) { #ifdef HAVE_LIBSOUP_2_29_90 SoupSession* session = webkit_get_default_session(); SoupCookieJar* jar = reinterpret_cast<SoupCookieJar*>(soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR)); /* If the jar was not created - we create it on demand, i.e, just in case we have HTTP requests - then we must create it here in order to set the proper accept policy */ if (!jar) { jar = soup_cookie_jar_new(); soup_session_add_feature(session, SOUP_SESSION_FEATURE(jar)); g_object_unref(jar); } SoupCookieJarAcceptPolicy policy; if (alwaysAcceptCookies) policy = SOUP_COOKIE_JAR_ACCEPT_ALWAYS; else policy = SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY; g_object_set(G_OBJECT(jar), SOUP_COOKIE_JAR_ACCEPT_POLICY, policy, NULL); #endif }
/** * Sets the path where the cookies are going to be stored. Use @c NULL for keep * them just in memory. * * @param filename path to the cookies.txt file. * * @return @c EINA_FALSE if it wasn't possible to create the cookie jar, * @c EINA_FALSE otherwise. */ Eina_Bool ewk_cookies_file_set(const char *filename) { #if USE(SOUP) SoupCookieJar* cookieJar = 0; if (filename) cookieJar = soup_cookie_jar_text_new(filename, FALSE); else cookieJar = soup_cookie_jar_new(); if (!cookieJar) return EINA_FALSE; soup_cookie_jar_set_accept_policy(cookieJar, SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY); SoupSession* session = WebCore::ResourceHandle::defaultSession(); SoupSessionFeature* oldjar = soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR); if (oldjar) soup_session_remove_feature(session, oldjar); WebCore::setDefaultCookieJar(cookieJar); soup_session_add_feature(session, SOUP_SESSION_FEATURE(cookieJar)); return EINA_TRUE; #else return EINA_FALSE; #endif }
SoupCookieJar* createPrivateBrowsingCookieJar() { SoupCookieJar* jar = soup_cookie_jar_new(); soup_cookie_jar_set_accept_policy(jar, SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY); return jar; }
SoupCookieJar* soupCookieJar() { if (GRefPtr<SoupCookieJar>& jar = defaultCookieJar()) return jar.get(); SoupCookieJar* jar = soup_cookie_jar_new(); soup_cookie_jar_set_accept_policy(jar, SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY); setSoupCookieJar(jar); return jar; }
Eina_Bool ewk_cookies_file_set(const char* filename) { SoupCookieJar* cookieJar = 0; if (filename) cookieJar = soup_cookie_jar_text_new(filename, FALSE); else cookieJar = soup_cookie_jar_new(); if (!cookieJar) return false; soup_cookie_jar_set_accept_policy(cookieJar, SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY); WebCore::SoupNetworkSession::defaultSession().setCookieJar(cookieJar); WebCore::setSoupCookieJar(cookieJar); g_object_unref(cookieJar); return true; }
void setup_cookies(void) { char file[PATH_MAX]; set_hook((void *)&_soup_cookie_jar_add_cookie, "soup_cookie_jar_add_cookie"); set_hook((void *)&_soup_cookie_jar_delete_cookie, "soup_cookie_jar_delete_cookie"); #if defined __MINGW32__ /* windows hooking is a horror show, nothing to see here move along */ fixup_windows_hooks(); #endif if (cookies_enabled == 0) return; /* * the following code is intricate due to overriding several libsoup * functions. * do not alter order of these operations. */ /* rejected cookies */ if (save_rejected_cookies) snprintf(rc_fname, sizeof file, "%s" PS "%s", work_dir, XT_REJECT_FILE); /* persistent cookies */ snprintf(file, sizeof file, "%s" PS "%s", work_dir, XT_COOKIE_FILE); p_cookiejar = soup_cookie_jar_text_new(file, read_only_cookies); /* session cookies */ s_cookiejar = soup_cookie_jar_new(); g_object_set(G_OBJECT(s_cookiejar), SOUP_COOKIE_JAR_ACCEPT_POLICY, cookie_policy, (void *)NULL); transfer_cookies(); soup_session_add_feature(session, (SoupSessionFeature*)s_cookiejar); }
void setup(void) { SoupSession *s; char *proxy; char *new_proxy; SoupURI *puri; /* clean up any zombies immediately */ sigchld(0); gtk_init(NULL, NULL); if (!g_thread_supported()) g_thread_init(NULL); dpy = GDK_DISPLAY(); session = webkit_get_default_session(); uriprop = XInternAtom(dpy, "_SURF_URI", False); findprop = XInternAtom(dpy, "_SURF_FIND", False); /* create dirs and files */ cookiefile = buildpath(cookiefile); dldir = buildpath(dldir); scriptfile = buildpath(scriptfile); stylefile = buildpath(stylefile); /* cookie persistance */ s = webkit_get_default_session(); cookies = soup_cookie_jar_new(); soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookies)); g_signal_connect(cookies, "changed", G_CALLBACK(changecookie), NULL); if((proxy = getenv("http_proxy")) && strcmp(proxy, "")) { new_proxy = g_strrstr(proxy, "http://") ? g_strdup(proxy) : g_strdup_printf("http://%s", proxy); puri = soup_uri_new(new_proxy); g_object_set(G_OBJECT(s), "proxy-uri", puri, NULL); soup_uri_free(puri); g_free(new_proxy); } reloadcookies(); }