Browser: Remove some needless indirection from Cookie-related IPCs

We don't need to forward Cookie-related IPCs from the WebView through
the Tab to the BrowserWindow. We can skip the Tab like we do in other
chromes.

This is primarily to reduce overhead when changing Cookie IPCs in future
patches.
This commit is contained in:
Timothy Flynn 2024-01-26 11:06:23 -05:00 committed by Andreas Kling
parent 8ea4e37c27
commit dcd9962d7b
Notes: sideshowbarker 2024-07-17 09:39:38 +09:00
3 changed files with 9 additions and 49 deletions

View File

@ -361,9 +361,7 @@ void BrowserWindow::build_menus(StringView const man_file)
active_tab().m_history.dump();
}));
debug_menu->add_action(GUI::Action::create("Dump C&ookies", g_icon_bag.cookie, [this](auto&) {
auto& tab = active_tab();
if (tab.on_dump_cookies)
tab.on_dump_cookies();
m_cookie_jar.dump_cookies();
}));
debug_menu->add_action(GUI::Action::create("Dump Loc&al Storage", g_icon_bag.local_storage, [this](auto&) {
active_tab().view().debug_request("dump-local-storage");
@ -578,28 +576,24 @@ Tab& BrowserWindow::create_new_tab(URL const& url, Web::HTML::ActivateTab activa
create_new_window(url);
};
new_tab.on_get_all_cookies = [this](auto& url) {
new_tab.view().on_get_all_cookies = [this](auto& url) {
return m_cookie_jar.get_all_cookies(url);
};
new_tab.on_get_named_cookie = [this](auto& url, auto& name) {
new_tab.view().on_get_named_cookie = [this](auto& url, auto& name) {
return m_cookie_jar.get_named_cookie(url, name);
};
new_tab.on_get_cookie = [this](auto& url, auto source) -> ByteString {
new_tab.view().on_get_cookie = [this](auto& url, auto source) {
return m_cookie_jar.get_cookie(url, source);
};
new_tab.on_set_cookie = [this](auto& url, auto& cookie, auto source) {
new_tab.view().on_set_cookie = [this](auto& url, auto& cookie, auto source) {
m_cookie_jar.set_cookie(url, cookie, source);
};
new_tab.on_dump_cookies = [this]() {
m_cookie_jar.dump_cookies();
};
new_tab.on_update_cookie = [this](auto cookie) {
m_cookie_jar.update_cookie(move(cookie));
new_tab.view().on_update_cookie = [this](auto const& cookie) {
m_cookie_jar.update_cookie(cookie);
};
new_tab.on_get_cookies_entries = [this]() {

View File

@ -479,34 +479,6 @@ Tab::Tab(BrowserWindow& window)
on_favicon_change(icon);
};
view().on_get_all_cookies = [this](auto& url) -> Vector<Web::Cookie::Cookie> {
if (on_get_all_cookies)
return on_get_all_cookies(url);
return {};
};
view().on_get_named_cookie = [this](auto& url, auto& name) -> Optional<Web::Cookie::Cookie> {
if (on_get_named_cookie)
return on_get_named_cookie(url, name);
return {};
};
view().on_get_cookie = [this](auto& url, auto source) -> ByteString {
if (on_get_cookie)
return on_get_cookie(url, source);
return {};
};
view().on_set_cookie = [this](auto& url, auto& cookie, auto source) {
if (on_set_cookie)
on_set_cookie(url, cookie, source);
};
view().on_update_cookie = [this](auto& cookie) {
if (on_update_cookie)
on_update_cookie(cookie);
};
view().on_request_alert = [this](String const& message) {
auto& window = this->window();
@ -975,8 +947,8 @@ void Tab::show_storage_inspector()
storage_window->set_icon(g_icon_bag.cookie);
m_storage_widget = storage_window->set_main_widget<StorageWidget>();
m_storage_widget->on_update_cookie = [this](Web::Cookie::Cookie cookie) {
if (on_update_cookie)
on_update_cookie(move(cookie));
if (view().on_update_cookie)
view().on_update_cookie(move(cookie));
};
}

View File

@ -70,12 +70,6 @@ public:
Function<void(Tab&)> on_tab_close_other_request;
Function<void(const URL&)> on_window_open_request;
Function<void(Gfx::Bitmap const&)> on_favicon_change;
Function<Vector<Web::Cookie::Cookie>(AK::URL const& url)> on_get_all_cookies;
Function<Optional<Web::Cookie::Cookie>(AK::URL const& url, ByteString const& name)> on_get_named_cookie;
Function<ByteString(const URL&, Web::Cookie::Source source)> on_get_cookie;
Function<void(const URL&, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source)> on_set_cookie;
Function<void()> on_dump_cookies;
Function<void(Web::Cookie::Cookie)> on_update_cookie;
Function<Vector<Web::Cookie::Cookie>()> on_get_cookies_entries;
Function<OrderedHashMap<String, String>()> on_get_local_storage_entries;
Function<OrderedHashMap<String, String>()> on_get_session_storage_entries;