diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 66abd33ec2..5c93903571 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -554,6 +556,26 @@ Tab::Tab(BrowserWindow& window) m_dialog = nullptr; }; + view().on_request_file_picker = [this](auto allow_multiple_files) { + // FIXME: GUI::FilePicker does not allow selecting multiple files at once. + (void)allow_multiple_files; + + Vector selected_files; + auto& window = this->window(); + + auto create_selected_file = [&](auto file_path) { + if (auto file = Web::HTML::SelectedFile::from_file_path(file_path); file.is_error()) + warnln("Unable to open file {}: {}", file_path, file.error()); + else + selected_files.append(file.release_value()); + }; + + if (auto path = GUI::FilePicker::get_open_filepath(&window, "Select file"); path.has_value()) + create_selected_file(path.release_value()); + + view().file_picker_closed(std::move(selected_files)); + }; + m_select_dropdown = GUI::Menu::construct(); m_select_dropdown->on_visibility_change = [this](bool visible) { if (!visible && !m_select_dropdown_closed_by_action) diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index ab7a8e8ed6..77f1c68038 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -107,7 +107,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::create(arguments)); auto const man_file = "/usr/share/man/man1/Applications/Browser.md"sv; - Config::pledge_domain("Browser"); + Config::pledge_domains({ "Browser", "FileManager" }); Config::monitor_domain("Browser"); // Connect to LaunchServer immediately and let it know that we won't ask for anything other than opening @@ -126,8 +126,10 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/tmp/session/%sid/portal/sql", "rw")); TRY(Core::System::unveil("/home", "rwc")); TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/etc/group", "r")); TRY(Core::System::unveil("/etc/passwd", "r")); TRY(Core::System::unveil("/etc/timezone", "r")); + TRY(Core::System::unveil("/etc/FileIconProvider.ini", "r")); TRY(Core::System::unveil("/bin/BrowserSettings", "x")); TRY(Core::System::unveil("/bin/Browser", "x")); TRY(Core::System::unveil(nullptr, nullptr));