mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
Ladybird+LibWeb+WebContent: Port the did_request_cookie
IPC to String
This commit is contained in:
parent
dcd9962d7b
commit
85b8971a80
Notes:
sideshowbarker
2024-07-17 14:33:07 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/85b8971a80 Pull-request: https://github.com/SerenityOS/serenity/pull/22951
@ -636,7 +636,7 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
|
||||
return [delegate cookieJar].get_named_cookie(url, name);
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_get_cookie = [](auto const& url, auto source) -> ByteString {
|
||||
m_web_view_bridge->on_get_cookie = [](auto const& url, auto source) {
|
||||
auto* delegate = (ApplicationDelegate*)[NSApp delegate];
|
||||
return [delegate cookieJar].get_cookie(url, source);
|
||||
};
|
||||
|
@ -541,7 +541,7 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab)
|
||||
return m_cookie_jar.get_named_cookie(url, name);
|
||||
};
|
||||
|
||||
tab->view().on_get_cookie = [this](auto& url, auto source) -> ByteString {
|
||||
tab->view().on_get_cookie = [this](auto& url, auto source) {
|
||||
return m_cookie_jar.get_cookie(url, source);
|
||||
};
|
||||
|
||||
|
@ -2006,7 +2006,7 @@ void Document::completely_finish_loading()
|
||||
|
||||
String Document::cookie(Cookie::Source source)
|
||||
{
|
||||
return MUST(String::from_byte_string(page().client().page_did_request_cookie(m_url, source)));
|
||||
return page().client().page_did_request_cookie(m_url, source);
|
||||
}
|
||||
|
||||
void Document::set_cookie(StringView cookie_string, Cookie::Source source)
|
||||
|
@ -1431,7 +1431,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
|
||||
// FIXME: Getting to the page client reliably is way too complicated, and going via the document won't work in workers.
|
||||
auto document = Bindings::host_defined_environment_settings_object(realm).responsible_document();
|
||||
if (!document)
|
||||
return ByteString::empty();
|
||||
return String {};
|
||||
return document->page().client().page_did_request_cookie(http_request->current_url(), Cookie::Source::Http);
|
||||
})();
|
||||
|
||||
|
@ -16,9 +16,9 @@ LoadRequest LoadRequest::create_for_url_on_page(const AK::URL& url, Page* page)
|
||||
request.set_url(url);
|
||||
|
||||
if (page) {
|
||||
ByteString cookie = page->client().page_did_request_cookie(url, Cookie::Source::Http);
|
||||
auto cookie = page->client().page_did_request_cookie(url, Cookie::Source::Http);
|
||||
if (!cookie.is_empty())
|
||||
request.set_header("Cookie", cookie);
|
||||
request.set_header("Cookie", cookie.to_byte_string());
|
||||
request.set_page(*page);
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ public:
|
||||
virtual void page_did_request_dismiss_dialog() { }
|
||||
virtual Vector<Web::Cookie::Cookie> page_did_request_all_cookies(AK::URL const&) { return {}; }
|
||||
virtual Optional<Web::Cookie::Cookie> page_did_request_named_cookie(AK::URL const&, ByteString const&) { return {}; }
|
||||
virtual ByteString page_did_request_cookie(const AK::URL&, Cookie::Source) { return {}; }
|
||||
virtual String page_did_request_cookie(const AK::URL&, Cookie::Source) { return {}; }
|
||||
virtual void page_did_set_cookie(const AK::URL&, Cookie::ParsedCookie const&, Cookie::Source) { }
|
||||
virtual void page_did_update_cookie(Web::Cookie::Cookie) { }
|
||||
virtual void page_did_update_resource_count(i32) { }
|
||||
|
@ -80,7 +80,7 @@ CookieJar::CookieJar(TransientStorage storage)
|
||||
{
|
||||
}
|
||||
|
||||
ByteString CookieJar::get_cookie(const URL& url, Web::Cookie::Source source)
|
||||
String CookieJar::get_cookie(const URL& url, Web::Cookie::Source source)
|
||||
{
|
||||
purge_expired_cookies();
|
||||
|
||||
@ -100,7 +100,7 @@ ByteString CookieJar::get_cookie(const URL& url, Web::Cookie::Source source)
|
||||
builder.appendff("{}={}", cookie.name, cookie.value);
|
||||
}
|
||||
|
||||
return builder.to_byte_string();
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
void CookieJar::set_cookie(const URL& url, Web::Cookie::ParsedCookie const& parsed_cookie, Web::Cookie::Source source)
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
static ErrorOr<CookieJar> create(Database&);
|
||||
static CookieJar create();
|
||||
|
||||
ByteString get_cookie(const URL& url, Web::Cookie::Source source);
|
||||
String get_cookie(const URL& url, Web::Cookie::Source source);
|
||||
void set_cookie(const URL& url, Web::Cookie::ParsedCookie const& parsed_cookie, Web::Cookie::Source source);
|
||||
void update_cookie(Web::Cookie::Cookie);
|
||||
void dump_cookies();
|
||||
|
@ -153,7 +153,7 @@ public:
|
||||
Function<void(i32 start_index, Vector<ByteString> const& message_types, Vector<ByteString> const& messages)> on_received_console_messages;
|
||||
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 AK::URL& url, Web::Cookie::Source source)> on_get_cookie;
|
||||
Function<String(const AK::URL& url, Web::Cookie::Source source)> on_get_cookie;
|
||||
Function<void(const AK::URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source)> on_set_cookie;
|
||||
Function<void(Web::Cookie::Cookie const& cookie)> on_update_cookie;
|
||||
Function<void(i32 count_waiting)> on_resource_status_change;
|
||||
|
@ -313,7 +313,7 @@ Messages::WebContentClient::DidRequestCookieResponse WebContentClient::did_reque
|
||||
{
|
||||
if (m_view.on_get_cookie)
|
||||
return m_view.on_get_cookie(url, static_cast<Web::Cookie::Source>(source));
|
||||
return ByteString {};
|
||||
return String {};
|
||||
}
|
||||
|
||||
void WebContentClient::did_set_cookie(AK::URL const& url, Web::Cookie::ParsedCookie const& cookie, u8 source)
|
||||
|
@ -468,7 +468,7 @@ Optional<Web::Cookie::Cookie> PageClient::page_did_request_named_cookie(URL cons
|
||||
return client().did_request_named_cookie(url, name);
|
||||
}
|
||||
|
||||
ByteString PageClient::page_did_request_cookie(const URL& url, Web::Cookie::Source source)
|
||||
String PageClient::page_did_request_cookie(const URL& url, Web::Cookie::Source source)
|
||||
{
|
||||
auto response = client().send_sync_but_allow_failure<Messages::WebContentClient::DidRequestCookie>(move(url), static_cast<u8>(source));
|
||||
if (!response) {
|
||||
|
@ -114,7 +114,7 @@ private:
|
||||
virtual void page_did_change_favicon(Gfx::Bitmap const&) override;
|
||||
virtual Vector<Web::Cookie::Cookie> page_did_request_all_cookies(URL const&) override;
|
||||
virtual Optional<Web::Cookie::Cookie> page_did_request_named_cookie(URL const&, ByteString const&) override;
|
||||
virtual ByteString page_did_request_cookie(const URL&, Web::Cookie::Source) override;
|
||||
virtual String page_did_request_cookie(const URL&, Web::Cookie::Source) override;
|
||||
virtual void page_did_set_cookie(const URL&, Web::Cookie::ParsedCookie const&, Web::Cookie::Source) override;
|
||||
virtual void page_did_update_cookie(Web::Cookie::Cookie) override;
|
||||
virtual void page_did_update_resource_count(i32) override;
|
||||
|
@ -54,7 +54,7 @@ endpoint WebContentClient
|
||||
did_change_favicon(Gfx::ShareableBitmap favicon) =|
|
||||
did_request_all_cookies(URL url) => (Vector<Web::Cookie::Cookie> cookies)
|
||||
did_request_named_cookie(URL url, ByteString name) => (Optional<Web::Cookie::Cookie> cookie)
|
||||
did_request_cookie(URL url, u8 source) => (ByteString cookie)
|
||||
did_request_cookie(URL url, u8 source) => (String cookie)
|
||||
did_set_cookie(URL url, Web::Cookie::ParsedCookie cookie, u8 source) => ()
|
||||
did_update_cookie(Web::Cookie::Cookie cookie) =|
|
||||
did_update_resource_count(i32 count_waiting) =|
|
||||
|
@ -168,7 +168,7 @@ private:
|
||||
on_scroll_to_point(position);
|
||||
};
|
||||
|
||||
on_get_cookie = [this](auto const& url, auto source) -> ByteString {
|
||||
on_get_cookie = [this](auto const& url, auto source) {
|
||||
return m_cookie_jar.get_cookie(url, source);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user