summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-22 19:47:14 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-22 19:47:14 +0100
commit05e45bfdc5515ee84e9876cbf05909a9e0322115 (patch)
tree812528ac82a8bcafb2ec9b33fb7ca43c4dd5acda
parentf5927f167b4f90694432d0623974bd1ff1099b49 (diff)
downloadserenity-05e45bfdc5515ee84e9876cbf05909a9e0322115.zip
Browser: Port to LibMain :^)
-rw-r--r--Userland/Applications/Browser/CMakeLists.txt2
-rw-r--r--Userland/Applications/Browser/main.cpp51
2 files changed, 14 insertions, 39 deletions
diff --git a/Userland/Applications/Browser/CMakeLists.txt b/Userland/Applications/Browser/CMakeLists.txt
index f9d01126db..542af7d4a8 100644
--- a/Userland/Applications/Browser/CMakeLists.txt
+++ b/Userland/Applications/Browser/CMakeLists.txt
@@ -26,4 +26,4 @@ set(SOURCES
)
serenity_app(Browser ICON app-browser)
-target_link_libraries(Browser LibWeb LibProtocol LibGUI LibDesktop LibConfig)
+target_link_libraries(Browser LibWeb LibProtocol LibGUI LibDesktop LibConfig LibMain)
diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp
index fe3ba22e72..82c8d4ab0d 100644
--- a/Userland/Applications/Browser/main.cpp
+++ b/Userland/Applications/Browser/main.cpp
@@ -19,6 +19,8 @@
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Icon.h>
#include <LibGUI/TabWidget.h>
+#include <LibMain/Main.h>
+#include <LibSystem/Wrappers.h>
#include <stdio.h>
#include <unistd.h>
@@ -30,25 +32,22 @@ Vector<String> g_content_filters;
}
-int main(int argc, char** argv)
+ErrorOr<int> serenity_main(Main::Arguments arguments)
{
if (getuid() == 0) {
warnln("Refusing to run as root");
return 1;
}
- if (pledge("stdio recvfd sendfd unix cpath rpath wpath", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(System::pledge("stdio recvfd sendfd unix cpath rpath wpath", nullptr));
const char* specified_url = nullptr;
Core::ArgsParser args_parser;
args_parser.add_positional_argument(specified_url, "URL to open", "url", Core::ArgsParser::Required::No);
- args_parser.parse(argc, argv);
+ args_parser.parse(arguments.argc, arguments.argv);
- auto app = GUI::Application::construct(argc, argv);
+ auto app = GUI::Application::construct(arguments.argc, arguments.argv);
Config::pledge_domains("Browser");
@@ -61,37 +60,13 @@ int main(int argc, char** argv)
return 1;
}
- if (unveil("/home", "rwc") < 0) {
- perror("unveil");
- return 1;
- }
-
- if (unveil("/res", "r") < 0) {
- perror("unveil");
- return 1;
- }
-
- if (unveil("/etc/passwd", "r") < 0) {
- perror("unveil");
- return 1;
- }
-
- if (unveil("/tmp/portal/image", "rw") < 0) {
- perror("unveil");
- return 1;
- }
-
- if (unveil("/tmp/portal/webcontent", "rw") < 0) {
- perror("unveil");
- return 1;
- }
-
- if (unveil("/tmp/portal/request", "rw") < 0) {
- perror("unveil");
- return 1;
- }
-
- unveil(nullptr, nullptr);
+ TRY(System::unveil("/home", "rwc"));
+ TRY(System::unveil("/res", "r"));
+ TRY(System::unveil("/etc/passwd", "r"));
+ TRY(System::unveil("/tmp/portal/image", "rw"));
+ TRY(System::unveil("/tmp/portal/webcontent", "rw"));
+ TRY(System::unveil("/tmp/portal/request", "rw"));
+ TRY(System::unveil(nullptr, nullptr));
auto app_icon = GUI::Icon::default_icon("app-browser");