mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +00:00
LibWebView: Add method to remove all cookies globally
The inspector widget has this functionality, but it's limited to the site you're currently viewing. This commit adds an option for removing all cookies globally. Previously, the workaround was to open a sqlite shell and run: `DELETE FROM Cookies;` on the database yourself.
This commit is contained in:
parent
49a7a0f378
commit
dc34aeb764
Notes:
github-actions[bot]
2025-01-05 13:59:35 +00:00
Author: https://github.com/rmg-x Commit: https://github.com/LadybirdBrowser/ladybird/commit/dc34aeb764b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3141 Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 17 additions and 0 deletions
|
@ -174,6 +174,11 @@ void CookieJar::dump_cookies()
|
|||
dbgln("{} cookies stored\n{}", m_transient_storage.size(), builder.string_view());
|
||||
}
|
||||
|
||||
void CookieJar::clear_all_cookies()
|
||||
{
|
||||
m_transient_storage.expire_and_purge_all_cookies();
|
||||
}
|
||||
|
||||
Vector<Web::Cookie::Cookie> CookieJar::get_all_cookies()
|
||||
{
|
||||
Vector<Web::Cookie::Cookie> cookies;
|
||||
|
@ -639,6 +644,16 @@ UnixDateTime CookieJar::TransientStorage::purge_expired_cookies(Optional<AK::Dur
|
|||
return now;
|
||||
}
|
||||
|
||||
void CookieJar::TransientStorage::expire_and_purge_all_cookies()
|
||||
{
|
||||
for (auto& [key, value] : m_cookies) {
|
||||
value.expiry_time = UnixDateTime::earliest();
|
||||
set_cookie(key, value);
|
||||
}
|
||||
|
||||
purge_expired_cookies();
|
||||
}
|
||||
|
||||
void CookieJar::PersistedStorage::insert_cookie(Web::Cookie::Cookie const& cookie)
|
||||
{
|
||||
database.execute_statement(
|
||||
|
|
|
@ -48,6 +48,7 @@ class CookieJar {
|
|||
size_t size() const { return m_cookies.size(); }
|
||||
|
||||
UnixDateTime purge_expired_cookies(Optional<AK::Duration> offset = {});
|
||||
void expire_and_purge_all_cookies();
|
||||
|
||||
auto take_dirty_cookies() { return move(m_dirty_cookies); }
|
||||
|
||||
|
@ -91,6 +92,7 @@ public:
|
|||
void set_cookie(const URL::URL& url, Web::Cookie::ParsedCookie const& parsed_cookie, Web::Cookie::Source source);
|
||||
void update_cookie(Web::Cookie::Cookie);
|
||||
void dump_cookies();
|
||||
void clear_all_cookies();
|
||||
Vector<Web::Cookie::Cookie> get_all_cookies();
|
||||
Vector<Web::Cookie::Cookie> get_all_cookies(URL::URL const& url);
|
||||
Optional<Web::Cookie::Cookie> get_named_cookie(URL::URL const& url, StringView name);
|
||||
|
|
Loading…
Add table
Reference in a new issue