1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:07:36 +00:00

Browser+LibWeb: Add hooks for getting and setting cookies

This commit is contained in:
Timothy Flynn 2021-04-11 10:53:15 -04:00 committed by Andreas Kling
parent f0cdb2bf50
commit e54837add5
4 changed files with 26 additions and 0 deletions

View file

@ -26,6 +26,7 @@
#include "BookmarksBarWidget.h"
#include "Browser.h"
#include "CookieJar.h"
#include "Tab.h"
#include "WindowActions.h"
#include <AK/StringBuilder.h>
@ -148,6 +149,8 @@ int main(int argc, char** argv)
bool bookmarksbar_enabled = true;
auto bookmarks_bar = Browser::BookmarksBarWidget::construct(Browser::bookmarks_file_path(), bookmarksbar_enabled);
Browser::CookieJar cookie_jar;
auto window = GUI::Window::construct();
window->resize(640, 480);
window->set_icon(app_icon.bitmap_for_size(16));
@ -216,6 +219,14 @@ int main(int argc, char** argv)
});
};
new_tab.on_get_cookie = [&](auto& url) -> String {
return cookie_jar.get_cookie(url);
};
new_tab.on_set_cookie = [&](auto& url, auto& cookie) {
cookie_jar.set_cookie(url, cookie);
};
new_tab.load(url);
dbgln("Added new tab {:p}, loading {}", &new_tab, url);