2020-06-17 17:31:42 +02:00
|
|
|
/*
|
2022-09-08 11:55:12 +02:00
|
|
|
* Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
|
2020-06-17 17:31:42 +02:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-17 17:31:42 +02:00
|
|
|
*/
|
|
|
|
|
|
2022-09-16 15:01:47 +02:00
|
|
|
#include "ImageCodecPluginSerenity.h"
|
2020-06-17 17:31:42 +02:00
|
|
|
#include <LibCore/EventLoop.h>
|
2022-12-07 21:34:00 +01:00
|
|
|
#include <LibCore/File.h>
|
2020-06-17 17:31:42 +02:00
|
|
|
#include <LibCore/LocalServer.h>
|
2022-11-08 10:03:07 -05:00
|
|
|
#include <LibCore/Stream.h>
|
2021-11-23 10:59:50 +01:00
|
|
|
#include <LibCore/System.h>
|
2021-12-06 18:11:05 +01:00
|
|
|
#include <LibIPC/SingleServer.h>
|
2021-11-23 10:31:08 +01:00
|
|
|
#include <LibMain/Main.h>
|
2022-04-30 12:06:30 +02:00
|
|
|
#include <LibWeb/Loader/ResourceLoader.h>
|
2022-09-07 20:30:31 +02:00
|
|
|
#include <LibWeb/Platform/EventLoopPlugin.h>
|
2022-09-21 19:33:57 +01:00
|
|
|
#include <LibWeb/Platform/EventLoopPluginSerenity.h>
|
|
|
|
|
#include <LibWeb/Platform/FontPluginSerenity.h>
|
2022-04-30 11:26:21 +02:00
|
|
|
#include <LibWeb/WebSockets/WebSocket.h>
|
2022-04-30 12:06:30 +02:00
|
|
|
#include <LibWebView/RequestServerAdapter.h>
|
2022-04-30 11:26:21 +02:00
|
|
|
#include <LibWebView/WebSocketClientAdapter.h>
|
2022-02-25 12:18:30 +02:00
|
|
|
#include <WebContent/ConnectionFromClient.h>
|
2020-06-17 17:31:42 +02:00
|
|
|
|
2021-11-23 10:31:08 +01:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments)
|
2020-06-17 17:31:42 +02:00
|
|
|
{
|
|
|
|
|
Core::EventLoop event_loop;
|
2022-10-03 09:32:18 -04:00
|
|
|
TRY(Core::System::pledge("stdio recvfd sendfd accept unix rpath"));
|
2022-11-08 10:03:07 -05:00
|
|
|
|
|
|
|
|
// This must be first; we can't check if /tmp/webdriver exists once we've unveiled other paths.
|
2022-12-07 21:34:00 +01:00
|
|
|
if (Core::File::exists("/tmp/webdriver"sv))
|
2022-11-08 10:03:07 -05:00
|
|
|
TRY(Core::System::unveil("/tmp/webdriver", "rw"));
|
|
|
|
|
|
2022-10-14 21:56:07 +03:00
|
|
|
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
|
2021-11-23 10:59:50 +01:00
|
|
|
TRY(Core::System::unveil("/res", "r"));
|
2022-01-20 12:27:56 -05:00
|
|
|
TRY(Core::System::unveil("/etc/timezone", "r"));
|
2022-12-04 13:55:22 +00:00
|
|
|
TRY(Core::System::unveil("/usr/lib", "r"));
|
2022-09-06 00:04:06 -06:00
|
|
|
TRY(Core::System::unveil("/tmp/session/%sid/portal/request", "rw"));
|
|
|
|
|
TRY(Core::System::unveil("/tmp/session/%sid/portal/image", "rw"));
|
|
|
|
|
TRY(Core::System::unveil("/tmp/session/%sid/portal/websocket", "rw"));
|
2021-11-23 10:59:50 +01:00
|
|
|
TRY(Core::System::unveil(nullptr, nullptr));
|
2020-06-17 17:31:42 +02:00
|
|
|
|
2022-09-21 19:33:57 +01:00
|
|
|
Web::Platform::EventLoopPlugin::install(*new Web::Platform::EventLoopPluginSerenity);
|
2022-09-16 15:01:47 +02:00
|
|
|
Web::Platform::ImageCodecPlugin::install(*new WebContent::ImageCodecPluginSerenity);
|
2022-09-21 19:33:57 +01:00
|
|
|
Web::Platform::FontPlugin::install(*new Web::Platform::FontPluginSerenity);
|
2022-09-07 20:30:31 +02:00
|
|
|
|
2022-04-30 11:26:21 +02:00
|
|
|
Web::WebSockets::WebSocketClientManager::initialize(TRY(WebView::WebSocketClientManagerAdapter::try_create()));
|
2022-04-30 12:06:30 +02:00
|
|
|
Web::ResourceLoader::initialize(TRY(WebView::RequestServerAdapter::try_create()));
|
2022-04-30 11:21:21 +02:00
|
|
|
|
2022-02-25 12:18:30 +02:00
|
|
|
auto client = TRY(IPC::take_over_accepted_client_from_system_server<WebContent::ConnectionFromClient>());
|
2020-06-17 17:31:42 +02:00
|
|
|
return event_loop.exec();
|
|
|
|
|
}
|