diff options
author | Lucas CHOLLET <lucas.chollet@free.fr> | 2022-02-26 17:50:31 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-06-27 20:22:15 +0100 |
commit | 662711fa26de109d4c8fe1d93f17e1983d66ebf3 (patch) | |
tree | c138ed6b424be28e01db85e74f81f5a31632d6f4 /Userland/Libraries/LibWebView/OutOfProcessWebView.cpp | |
parent | 1ba9c821fbfc54562e10981a3403aa25fb6079b3 (diff) | |
download | serenity-662711fa26de109d4c8fe1d93f17e1983d66ebf3.zip |
Browser+LibWeb+WebContent: Allow Browser to load local files
To achieve this goal:
- The Browser unveils "/tmp/portal/filesystemaccess"
- Pass the page through LoadRequest => ResourceLoader
- ResourceLoader requests a file to the FileSystemAccessServer via IPC
- OutOfProcessWebView handles it and sends a file descriptor back to
the Page.
Diffstat (limited to 'Userland/Libraries/LibWebView/OutOfProcessWebView.cpp')
-rw-r--r-- | Userland/Libraries/LibWebView/OutOfProcessWebView.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index 1e248aed52..ed6967f567 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -7,6 +7,7 @@ #include "OutOfProcessWebView.h" #include "WebContentClient.h" #include <AK/String.h> +#include <LibFileSystemAccessClient/Client.h> #include <LibGUI/Application.h> #include <LibGUI/Desktop.h> #include <LibGUI/InputBox.h> @@ -400,6 +401,15 @@ void OutOfProcessWebView::notify_server_did_update_resource_count(i32 count_wait on_resource_status_change(count_waiting); } +void OutOfProcessWebView::notify_server_did_request_file(Badge<WebContentClient>, String const& path, i32 request_id) +{ + auto file = FileSystemAccessClient::Client::the().try_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()->leak_fd()), request_id); +} + void OutOfProcessWebView::did_scroll() { client().async_set_viewport_rect(visible_content_rect()); |