From 7d8ed91a7c1153d3c4c8c5a1199a7ebb9b4612b2 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 23 May 2020 20:34:04 +0100 Subject: browser_window: Implement cookie counter This is a fairly inefficient approach to counting the cookies in use by a page, but it'll do for now. Signed-off-by: Daniel Silverstone --- desktop/browser_window.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'desktop') diff --git a/desktop/browser_window.c b/desktop/browser_window.c index 74d79eabe..ea84e195e 100644 --- a/desktop/browser_window.c +++ b/desktop/browser_window.c @@ -4780,8 +4780,17 @@ browser_window_get_ssl_chain(struct browser_window *bw, int browser_window_get_cookie_count( const struct browser_window *bw) { - /** \todo Implement cookie count */ - return 0; + char *cookies = urldb_get_cookie(browser_window_access_url(bw), true); + int count = 0; + + for (char *c = cookies; *c != '\0'; c++) { + if (*c == ';') + count++; + } + + free(cookies); + + return count; } /* Exported interface, documented in browser_window.h */ -- cgit v1.2.3