mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-01 06:07:59 +00:00
Ladybird+LibWebView: Migrate file APIs to LibWebView callbacks
This also sets the default callback to do what every non-Serenity browser is doing, rather than copy-pasting this callback into every implementation. The callback is still available for any platform which might want to override the default behavior. For example, OOPWV now overrides this callback to use FileSystemAccessClient.
This commit is contained in:
@@ -28,6 +28,15 @@ OutOfProcessWebView::OutOfProcessWebView()
|
||||
set_focus_policy(GUI::FocusPolicy::StrongFocus);
|
||||
|
||||
create_client();
|
||||
|
||||
on_request_file = [this](auto const& path, auto request_id) {
|
||||
auto file = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), path);
|
||||
|
||||
if (file.is_error())
|
||||
client().async_handle_file_return(file.error().code(), {}, request_id);
|
||||
else
|
||||
client().async_handle_file_return(0, IPC::File(file.value().stream()), request_id);
|
||||
};
|
||||
}
|
||||
|
||||
OutOfProcessWebView::~OutOfProcessWebView() = default;
|
||||
@@ -231,15 +240,6 @@ void OutOfProcessWebView::notify_server_did_leave_tooltip_area(Badge<WebContentC
|
||||
GUI::Application::the()->hide_tooltip();
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_file(Badge<WebContentClient>, DeprecatedString const& path, i32 request_id)
|
||||
{
|
||||
auto file = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), path);
|
||||
if (file.is_error())
|
||||
client().async_handle_file_return(file.error().code(), {}, request_id);
|
||||
else
|
||||
client().async_handle_file_return(0, IPC::File(file.value().stream()), request_id);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::did_scroll()
|
||||
{
|
||||
client().async_set_viewport_rect(visible_content_rect());
|
||||
|
||||
Reference in New Issue
Block a user