mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:07:45 +00:00
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.
This commit is contained in:
parent
1ba9c821fb
commit
662711fa26
21 changed files with 165 additions and 14 deletions
|
@ -16,6 +16,6 @@ set(GENERATED_SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibWebView webview)
|
||||
target_link_libraries(LibWebView LibGfx LibGUI LibImageDecoderClient LibIPC LibProtocol LibWeb)
|
||||
target_link_libraries(LibWebView LibFileSystemAccessClient LibGfx LibGUI LibImageDecoderClient LibIPC LibProtocol LibWeb)
|
||||
|
||||
add_subdirectory(DumpLayoutTree)
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -112,6 +112,7 @@ public:
|
|||
String notify_server_did_request_cookie(Badge<WebContentClient>, const AK::URL& url, Web::Cookie::Source source);
|
||||
void notify_server_did_set_cookie(Badge<WebContentClient>, const AK::URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source);
|
||||
void notify_server_did_update_resource_count(i32 count_waiting);
|
||||
void notify_server_did_request_file(Badge<WebContentClient>, String const& path, i32);
|
||||
|
||||
private:
|
||||
OutOfProcessWebView();
|
||||
|
|
|
@ -200,4 +200,9 @@ void WebContentClient::did_update_resource_count(i32 count_waiting)
|
|||
m_view.notify_server_did_update_resource_count(count_waiting);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_file(String const& path, i32 request_id)
|
||||
{
|
||||
m_view.notify_server_did_request_file({}, path, request_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ private:
|
|||
virtual Messages::WebContentClient::DidRequestCookieResponse did_request_cookie(AK::URL const&, u8) override;
|
||||
virtual void did_set_cookie(AK::URL const&, Web::Cookie::ParsedCookie const&, u8) override;
|
||||
virtual void did_update_resource_count(i32 count_waiting) override;
|
||||
virtual void did_request_file(String const& path, i32) override;
|
||||
|
||||
OutOfProcessWebView& m_view;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue