diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index 8f047d1c36..3fca0fe607 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -49,7 +50,7 @@ static ByteString bookmarks_file_path() return builder.to_byte_string(); } -BrowserWindow::BrowserWindow(WebView::CookieJar& cookie_jar, Vector const& initial_urls) +BrowserWindow::BrowserWindow(WebView::CookieJar& cookie_jar, Vector const& initial_urls, StringView const man_file) : m_cookie_jar(cookie_jar) , m_window_actions(*this) { @@ -138,13 +139,13 @@ BrowserWindow::BrowserWindow(WebView::CookieJar& cookie_jar, Vector const& m_window_actions.vertical_tabs_action().set_checked(vertical_tabs); m_tab_widget->set_tab_position(vertical_tabs ? TabPosition::Left : TabPosition::Top); - build_menus(); + build_menus(man_file); for (size_t i = 0; i < initial_urls.size(); ++i) create_new_tab(initial_urls[i], (i == 0) ? Web::HTML::ActivateTab::Yes : Web::HTML::ActivateTab::No); } -void BrowserWindow::build_menus() +void BrowserWindow::build_menus(StringView const man_file) { auto file_menu = add_menu("&File"_string); file_menu->add_action(WindowActions::the().create_new_tab_action()); @@ -445,6 +446,9 @@ void BrowserWindow::build_menus() auto help_menu = add_menu("&Help"_string); help_menu->add_action(GUI::CommonActions::make_command_palette_action(this)); + help_menu->add_action(GUI::CommonActions::make_help_action([man_file](auto&) { + Desktop::Launcher::open(URL::create_with_file_scheme(man_file), "/bin/Help"); + })); help_menu->add_action(WindowActions::the().about_action()); } diff --git a/Userland/Applications/Browser/BrowserWindow.h b/Userland/Applications/Browser/BrowserWindow.h index 10aa9ef62c..86c4df4f06 100644 --- a/Userland/Applications/Browser/BrowserWindow.h +++ b/Userland/Applications/Browser/BrowserWindow.h @@ -51,9 +51,9 @@ public: void broadcast_window_size(Gfx::IntSize); private: - BrowserWindow(WebView::CookieJar&, Vector const&); + BrowserWindow(WebView::CookieJar&, Vector const&, StringView const); - void build_menus(); + void build_menus(StringView const); ErrorOr load_search_engines(GUI::Menu& settings_menu); void set_window_title_for_tab(Tab const&); diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index b0f8751a10..ab7a8e8ed6 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -105,6 +105,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(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::monitor_domain("Browser"); @@ -113,6 +114,7 @@ ErrorOr serenity_main(Main::Arguments arguments) // the user's downloads directory. // FIXME: This should go away with a standalone download manager at some point. TRY(Desktop::Launcher::add_allowed_url(URL::create_with_file_scheme(Core::StandardPaths::downloads_directory()))); + TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_scheme(man_file) })); TRY(Desktop::Launcher::seal_allowlist()); TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw")); @@ -171,7 +173,7 @@ ErrorOr serenity_main(Main::Arguments arguments) initial_urls.append(Browser::g_home_url); auto cookie_jar = TRY(WebView::CookieJar::create(*database)); - auto window = Browser::BrowserWindow::construct(cookie_jar, initial_urls); + auto window = Browser::BrowserWindow::construct(cookie_jar, initial_urls, man_file); auto content_filters_watcher = TRY(Core::FileWatcher::create()); content_filters_watcher->on_change = [&](Core::FileWatcherEvent const&) {