[webkit-gtk] Cookies API in WebKit2
Carlos Garcia Campos
cgarcia at igalia.com
Mon Mar 26 01:40:43 PDT 2012
In WebKit1 we don't need specific API for cookies (as well as most of
the network features) because we provide the SoupSession and users can
deal directly with soup API. In WebKit2, the SoupSession object is in
the Web Process so it can't be exposed by the API. So, the idea is to
provide specific API for network features in the WebKit2 GTK+ API. It
seems there are plans to move the network from the Web Process to the UI
Process at some point, but nothing real at this moment. If that
eventually happens, any API we add now won't change anyway, it would
just be updated to use the SoupSession directly instead of using IPC
messages.
So, the first network feature I have started to look into is Cookies
API. There's already API in WebKit2 to deal with cookies, although it's
not possible to get the list of cookies. WebKit2 API allows to:
- Get the list of hostnames with cookies
- Remove all cookies for a given hostname
- Remove all cookies
- Set/get the cookies policy
- Watch cookies for changes. It just notifies that cookies changed,
without any detail about what changed.
This means web browsers won't be able to show the detailed list of
cookies like ephy does, and individual cookies can't be removed either.
Personally I've never needed to remove a single cookie, I usually remove
all cookies or all the cookies for a given domain. So, I think the API
is enough, although we can always add specific IPC messages to get the
list of cookies if it's really needed. When patches for bugs #82081 and
#82082 land it will be possible to see the detailed list of cookies and
remove individual cookies from the web inspector, so another possibility
for web browsers that want to implement such advance feature is to
launch the web inspector.
The other problem we need to solve is that the soup feature has to be
created in the web process, so we need to add specific API and IPC
messages to tell the web process how to create the jar (whether it's a
text or sqlite and the file path of the text/database file). Soup-sqlite
is part for soup-gnome, so we can't use it directly. Dan confirmed that
moving it out of soup-gnome would be an abi break, so we should probably
have to add our own soup feature for sqlite cookies, by copy-pasting
soup code. It's not a lot of code and Dan told me it doesn't change
often, so I don't think it would be a big problem.
So, I propose to add the following API:
WebKitWebContext
-------------------------
WebKitCookieManager *webkit_web_context_get_cookie_manager (WebKitWebContext *web_context);
WebKitCookieManager
-----------------------------
WebKitCookieManager::changed
typedef enum {
WEBKIT_COOKIE_STORAGE_TEXT,
WEBKIT_COOKIE_STORAGE_SQLITE
} WebKitCookieStorage;
void webkit_cookie_manager_set_storage (WebKitCookieManager *cookie_manager,
const gchar *storage_path,
WebKitCookieStorage storage);
typedef enum {
WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS,
WEBKIT_COOKIE_POLICY_ACCEPT_NEVER,
WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY
} WebKitCookieAcceptPolicy;
void webkit_cookie_manager_set_accept_policy (WebKitCookieManager *cookie_manager,
WebKitCookieAcceptPolicy policy);
void webkit_cookie_manager_get_accept_policy (WebKitCookieManager *cookie_manager,
GAsyncReadyCallback callback,
gpointer user_data);
WebKitCookieAcceptPolicy webkit_cookie_manager_get_accept_policy_finish (WebKitCookieManager *cookie_manager,
GAsyncResult *result,
GError **error);
void webkit_cookie_manager_get_domains_with_cookies (WebKitCookieManager *cookie_manager,
GAsyncReadyCallback callback,
gpointer user_data);
GList *webkit_cookie_manager_get_domains_with_cookies_finish (WebKitCookieManager *cookie_manager,
GAsyncResult *result,
GError **error);
void webkit_cookie_manager_delete_domain_cookies (WebKitCookieManager *cookie_manager,
const gchar *domain);
void webkit_cookie_manager_delete_all_cookies (WebKitCookieManager *cookie_manager);
When set_storage is not called, the default jar will be used, like
current code does, which stores the cookies in memory. The changed
signal doesn't contain any information about what changed, because the
WebKit2 C API doesn't provide it, so it would be used to refresh the
list of domains with cookies.
Opinions?
--
Carlos Garcia Campos
http://pgp.rediris.es:11371/pks/lookup?op=get&search=0xF3D322D0EC4582C3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.webkit.org/pipermail/webkit-gtk/attachments/20120326/d7f0e061/attachment.bin>
More information about the webkit-gtk
mailing list