Skip to content

Truly independent web browser

Hub+UI/Qt: Run the Hub in a process of its own on macOS

Andreas Kling0f09a1113a19
diff --git a/Documentation/ProcessArchitecture.md b/Documentation/ProcessArchitecture.md
index b44a669eb09..c19691d68a7 100644
--- a/Documentation/ProcessArchitecture.md
+++ b/Documentation/ProcessArchitecture.md
@@ -44,7 +44,7 @@ This is the application itself, and the only process that talks to the window sy
**UI** and **Hub** talk over the protocols in `Services/Hub/HubServer.ipc` and `Services/Hub/HubClient.ipc`. **UI** may wait for **Hub** to answer, but **Hub** never waits for **UI**, which is why they cannot deadlock. Neither outlives the other: **Hub** ends once the connection closes, and **UI** ends with it if **Hub** is gone.
-With `--headless`, **UI** has nothing to do, and **Hub** takes over its process. On macOS and Windows, **Hub** does not have a process of its own yet, and runs inside **UI** over the same protocols.
+With `--headless`, **UI** has nothing to do, and **Hub** takes over its process. On Windows, **Hub** does not have a process of its own yet, and runs inside **UI** over the same protocols.
### Process: Hub
diff --git a/Meta/CMake/ladybird_helper_processes.cmake b/Meta/CMake/ladybird_helper_processes.cmake
index 72cc8684da7..8e74cbf9f99 100644
--- a/Meta/CMake/ladybird_helper_processes.cmake
+++ b/Meta/CMake/ladybird_helper_processes.cmake
@@ -34,9 +34,9 @@ function(ladybird_sign_helper_process target)
if (NOT APPLE)
return()
endif()
- cmake_parse_arguments(PARSE_ARGV 1 ARG "ALLOW_JIT" "" "")
+ cmake_parse_arguments(PARSE_ARGV 1 ARG "ALLOW_JIT" "" "ENTITLEMENTS")
- set(entitlements com.apple.security.cs.disable-library-validation)
+ set(entitlements com.apple.security.cs.disable-library-validation ${ARG_ENTITLEMENTS})
if (ARG_ALLOW_JIT)
list(APPEND entitlements com.apple.security.cs.allow-jit)
endif()
@@ -47,7 +47,7 @@ function(ladybird_sign_helper_process target)
set(entitlements_file "${CMAKE_CURRENT_BINARY_DIR}/${target}.entitlements")
ladybird_write_entitlements("${entitlements_file}" ${entitlements})
- set(release_entitlements)
+ set(release_entitlements ${ARG_ENTITLEMENTS})
if (ARG_ALLOW_JIT)
list(APPEND release_entitlements com.apple.security.cs.allow-jit)
endif()
diff --git a/Services/Hub/Application.cpp b/Services/Hub/Application.cpp
index c7dac1981ed..f298235a93f 100644
--- a/Services/Hub/Application.cpp
+++ b/Services/Hub/Application.cpp
@@ -16,6 +16,10 @@
#include <LibIPC/Decoder.h>
#include <LibWebView/WebContentPage.h>
+#if defined(AK_OS_MACOS)
+# include <LibWebView/MicrophoneAuthorizerMacOS.h>
+#endif
+
namespace Hub {
Application::Application(ApplicationHost* host)
@@ -26,6 +30,7 @@ Application::Application(ApplicationHost* host)
void Application::create_platform_arguments(Core::ArgsParser& args_parser)
{
args_parser.add_option(m_encoded_ui_info, "What the UI tells the Hub to start with", "ui-info", 0, "hex");
+ args_parser.add_option(m_ui_mach_server_name, "Mach server to get the connection to the UI from", "ui-mach-server", 0, "name");
}
Hub::UIInfo const* Application::ui_info() const
@@ -326,10 +331,10 @@ Core::EventLoop& Application::create_platform_event_loop()
NonnullOwnPtr<WebView::MicrophoneAuthorizer> Application::create_microphone_authorizer()
{
- if (m_host) {
- if (auto authorizer = m_host->create_microphone_authorizer())
- return authorizer.release_nonnull();
- }
+#if defined(AK_OS_MACOS)
+ if (!browser_options().headless_mode.has_value())
+ return make<WebView::MicrophoneAuthorizerMacOS>();
+#endif
return WebView::Application::create_microphone_authorizer();
}
diff --git a/Services/Hub/Application.h b/Services/Hub/Application.h
index ee2c124937d..55a64b082dc 100644
--- a/Services/Hub/Application.h
+++ b/Services/Hub/Application.h
@@ -24,9 +24,6 @@ public:
virtual void will_create_event_loop(Main::Arguments&) = 0;
virtual void did_create_event_loop(Core::EventLoop&) = 0;
- // The platform's own, if it has one.
- virtual OwnPtr<WebView::MicrophoneAuthorizer> create_microphone_authorizer() = 0;
-
virtual void create_platform_actions() = 0;
virtual Optional<String> ui_font_family() const = 0;
virtual Web::CSS::PreferredColorScheme interface_color_scheme() const = 0;
@@ -63,6 +60,7 @@ public:
void ui_did_start();
virtual void notify_webdriver_window_created(String const& handle) override;
void set_ui_info(Hub::UIInfo);
+ StringView ui_mach_server_name() const { return m_ui_mach_server_name; }
void did_resolve_external_url_handler(u64 request_id, Optional<u64> handler_id, String application_name, bool is_ladybird);
void launch_external_url(u64 handler_id, URL::URL const&, Function<void(bool)>) const;
void did_launch_external_url(u64 request_id, bool launched);
@@ -140,6 +138,7 @@ private:
ApplicationHost* m_host { nullptr };
StringView m_encoded_ui_info;
+ StringView m_ui_mach_server_name;
mutable Optional<Hub::UIInfo> m_ui_info;
HashMap<u64, NonnullOwnPtr<View>> m_views;
Optional<u64> m_active_view_id;
diff --git a/Services/Hub/CMakeLists.txt b/Services/Hub/CMakeLists.txt
index 79128b54544..7d7b2e5fc59 100644
--- a/Services/Hub/CMakeLists.txt
+++ b/Services/Hub/CMakeLists.txt
@@ -28,6 +28,15 @@ target_include_directories(hubservice PRIVATE ${LADYBIRD_SOURCE_DIR}/Services/)
target_link_libraries(hubservice PRIVATE LibCore LibGfx LibHTTP LibIPC LibRequests LibURL LibWebView hubipc)
+if (APPLE)
+ target_sources(hubservice PRIVATE SpellCheckerMac.mm)
+ set_source_files_properties(SpellCheckerMac.mm PROPERTIES COMPILE_FLAGS "-fobjc-arc")
+ target_link_libraries(hubservice PRIVATE "-framework AppKit")
+endif()
+
add_executable(Hub main.cpp)
target_include_directories(Hub PRIVATE ${LADYBIRD_SOURCE_DIR}/Services/)
target_link_libraries(Hub PRIVATE hubservice hubipc LibCore LibHTTP LibIPC LibMain LibRequests LibURL LibWebView)
+
+# NB: The hardened runtime refuses a process that asks for the microphone unless it has this entitlement.
+ladybird_sign_helper_process(Hub ENTITLEMENTS com.apple.security.device.audio-input)
diff --git a/Services/Hub/ConnectionFromUI.cpp b/Services/Hub/ConnectionFromUI.cpp
index 7a5cf4e0af8..5a89804af6f 100644
--- a/Services/Hub/ConnectionFromUI.cpp
+++ b/Services/Hub/ConnectionFromUI.cpp
@@ -507,6 +507,10 @@ Messages::HubServer::InitializeResponse ConnectionFromUI::initialize()
state.crash_report_directory = WebView::CrashReportStore::the().directory();
state.devtools_port = options.devtools_port;
state.has_translator = application.translator() != nullptr;
+ auto const& profile = Application::profile();
+ state.profile_identifier = profile.identifier();
+ state.profile_identity = profile.paths().identity;
+ state.profile_is_temporary = profile.is_temporary();
return state;
}
diff --git a/Services/Hub/HubClient.ipc b/Services/Hub/HubClient.ipc
index 09e20a0d7a4..9862465602c 100644
--- a/Services/Hub/HubClient.ipc
+++ b/Services/Hub/HubClient.ipc
@@ -243,6 +243,9 @@ struct Hub::InitialState {
ByteString crash_report_directory;
Optional<u16> devtools_port;
bool has_translator;
+ ByteString profile_identifier;
+ ByteString profile_identity;
+ bool profile_is_temporary;
}
// What the UI needs to know about a view at any time, without having to ask.
diff --git a/UI/Qt/SpellCheckerMac.h b/Services/Hub/SpellCheckerMac.h
similarity index 92%
rename from UI/Qt/SpellCheckerMac.h
rename to Services/Hub/SpellCheckerMac.h
index 9942fc03688..7efee5cfcf8 100644
--- a/UI/Qt/SpellCheckerMac.h
+++ b/Services/Hub/SpellCheckerMac.h
@@ -9,7 +9,7 @@
#include <AK/NonnullOwnPtr.h>
#include <LibWebView/SpellChecker.h>
-namespace Ladybird {
+namespace Hub {
NonnullOwnPtr<WebView::SpellChecker> create_platform_spell_checker();
diff --git a/UI/Qt/SpellCheckerMac.mm b/Services/Hub/SpellCheckerMac.mm
similarity index 98%
rename from UI/Qt/SpellCheckerMac.mm
rename to Services/Hub/SpellCheckerMac.mm
index a8796a5c7c2..cbf773c3872 100644
--- a/UI/Qt/SpellCheckerMac.mm
+++ b/Services/Hub/SpellCheckerMac.mm
@@ -7,9 +7,9 @@
#include <AK/AtomicRefCounted.h>
#include <AK/HashMap.h>
#include <AK/RefPtr.h>
+#include <Hub/SpellCheckerMac.h>
#include <LibCore/EventLoop.h>
-#include <UI/Qt/Conversions.h>
-#include <UI/Qt/SpellCheckerMac.h>
+#include <LibWebView/StringConversionsMacOS.h>
#import <AppKit/AppKit.h>
@@ -20,7 +20,9 @@
- (NSTextCheckingResult*)completionCandidateFromCandidates:(NSArray<NSTextCheckingResult*>*)candidates;
@end
-namespace Ladybird {
+namespace Hub {
+
+using namespace WebView;
// The private text checking type that asks for a single completion of the word at the caret.
static constexpr NSTextCheckingTypes text_checking_type_single_completion = 1ULL << 29;
diff --git a/Services/Hub/main.cpp b/Services/Hub/main.cpp
index 9f44e739237..38744e75a09 100644
--- a/Services/Hub/main.cpp
+++ b/Services/Hub/main.cpp
@@ -9,6 +9,10 @@
#include <LibIPC/StartupTransport.h>
#include <LibMain/Main.h>
+#if defined(AK_OS_MACOS)
+# include <Hub/SpellCheckerMac.h>
+#endif
+
ErrorOr<int> ladybird_main(Main::Arguments arguments)
{
AK::set_rich_debug_enabled(true);
@@ -19,10 +23,14 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)
return 0;
}
+#if defined(AK_OS_MACOS)
+ application->set_spell_checker(Hub::create_platform_spell_checker());
+#endif
+
// Headless mode runs on its own, with no UI to serve.
RefPtr<Hub::ConnectionFromUI> connection;
if (!Hub::Application::browser_options().headless_mode.has_value()) {
- auto transport = TRY(IPC::take_over_startup_transport({}));
+ auto transport = TRY(IPC::take_over_startup_transport(application->ui_mach_server_name()));
connection = Hub::ConnectionFromUI::construct(move(transport));
}
diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt
index 2113c6e4158..f43d0cb6e4d 100644
--- a/UI/CMakeLists.txt
+++ b/UI/CMakeLists.txt
@@ -111,9 +111,9 @@ else()
set(LADYBIRD_TARGET ladybird PRIVATE)
endif()
-set(LADYBIRD_LIBS AK LibCore LibGfx LibIPC LibMain LibWebView LibURL LibWakeLock hubipc)
+set(LADYBIRD_LIBS AK LibCore LibGfx LibIPC LibMain LibThreading LibWebView LibURL LibWakeLock hubipc)
# NB: Where the Hub is a process of its own, the UI must not be able to reach into it.
-if (LINUX)
+if (LINUX OR APPLE)
target_compile_definitions(${LADYBIRD_TARGET} LADYBIRD_HUB_IN_OWN_PROCESS)
else()
list(APPEND LADYBIRD_LIBS hubservice)
diff --git a/UI/Qt/Application.cpp b/UI/Qt/Application.cpp
index b534a8fb4af..cb8456443c0 100644
--- a/UI/Qt/Application.cpp
+++ b/UI/Qt/Application.cpp
@@ -17,15 +17,21 @@
#include <LibWebCommon/WebView/Utilities.h>
#include <LibWebView/CanonicalTraversable.h>
#include <LibWebView/CrashReportStore.h>
-#include <LibWebView/MicrophoneAuthorizer.h>
#include <LibWebView/NotificationBackend.h>
#include <LibWebView/PageTranslation.h>
#include <LibWebView/PictureInPictureManager.h>
#include <LibWebView/ReportSubmission.h>
#include <UI/Qt/SystemAppearance.h>
#if defined(AK_OS_MACOS)
-# include <LibWebView/MicrophoneAuthorizerMacOS.h>
+# include <AK/AtomicRefCounted.h>
+# include <LibCore/MachPort.h>
+# include <LibIPC/MachBootstrapListener.h>
+# include <LibIPC/TransportBootstrapMach.h>
+# include <LibIPC/TransportMachPort.h>
+# include <LibThreading/Thread.h>
# include <LibWebView/NotificationBackendMacOS.h>
+# include <mach/mach.h>
+# include <sys/wait.h>
#elif defined(AK_OS_LINUX) || defined(AK_OS_FREEBSD)
# include <LibWebView/NotificationBackendFreedesktop.h>
#endif
@@ -53,6 +59,7 @@
#include <UI/Qt/WebContentView.h>
#if defined(AK_OS_MACOS)
+# include <UI/Qt/ApplicationIcon.h>
# include <UI/Qt/MacWindow.h>
# include <UI/Qt/ScrollbarPreferencesMac.h>
#endif
@@ -646,6 +653,13 @@ ErrorOr<NonnullOwnPtr<Application>> Application::create(Main::Arguments const& a
}
#ifdef LADYBIRD_HUB_IN_OWN_PROCESS
+# if defined(AK_OS_MACOS)
+// What the Hub gets its end of the connection from. The thread that watches for the Hub to end can outlive connecting.
+struct HubBootstrap : public AtomicRefCounted<HubBootstrap> {
+ IPC::TransportBootstrapMachServer server;
+};
+# endif
+
ErrorOr<ByteString> Application::hub_executable_path()
{
for (auto const& path : TRY(WebView::get_paths_for_helper_process("Hub"sv))) {
@@ -689,14 +703,58 @@ ErrorOr<void> Application::connect_to_hub(Main::Arguments const& arguments)
hub_arguments.append(argument);
hub_arguments.append(ByteString::formatted("--ui-info={}", encode_hex(ui_info_buffer.data().span())));
- int socket_fds[2] {};
- TRY(Core::System::socketpair(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0, socket_fds));
-
Core::ProcessSpawnOptions spawn_options {
.name = "Hub"sv,
.executable = hub_path,
.arguments = hub_arguments,
};
+
+# if defined(AK_OS_MACOS)
+ // NB: This must answer while the main thread waits for the Hub to initialize, so it answers on its own thread.
+ auto hub_bootstrap = adopt_ref(*new HubBootstrap);
+ IPC::MachBootstrapListener bootstrap_listener { WebView::mach_server_name_for_process("Ladybird-UI"sv, Core::System::getpid()) };
+ if (!bootstrap_listener.is_initialized())
+ return Error::from_string_literal("Unable to start the Mach server for the Hub");
+ bootstrap_listener.on_bootstrap_request = [hub_bootstrap](IPC::MachBootstrapListener::BootstrapRequest request) {
+ if (auto result = hub_bootstrap->server.handle_bootstrap_request(request.pid, move(request.reply_port)); result.is_error())
+ dbgln("Unable to bootstrap the Hub: {}", result.error());
+ };
+ hub_arguments.append(ByteString::formatted("--ui-mach-server={}", bootstrap_listener.server_port_name()));
+ spawn_options.arguments = hub_arguments;
+
+ auto port_a_recv = TRY(Core::MachPort::create_with_right(Core::MachPort::PortRight::Receive));
+ auto port_a_send = TRY(port_a_recv.insert_right(Core::MachPort::MessageRight::MakeSend));
+ auto port_b_recv = TRY(Core::MachPort::create_with_right(Core::MachPort::PortRight::Receive));
+ auto port_b_send = TRY(port_b_recv.insert_right(Core::MachPort::MessageRight::MakeSend));
+
+ // The Hub may receive startup messages before it has constructed its transport.
+ IPC::TransportMachPort::raise_receive_queue_limit(port_b_recv);
+
+ Optional<Core::Process> spawned_process;
+ {
+ MutexLocker child_registration_locker(hub_bootstrap->server.child_registration_lock());
+ spawned_process = TRY(Core::Process::spawn(spawn_options));
+ hub_bootstrap->server.register_child_transport(spawned_process->pid(), IPC::TransportBootstrapMachPorts { move(port_b_recv), move(port_a_send) });
+ }
+ auto process = spawned_process.release_value();
+
+ // NB: Until the Hub takes its ports, we hold them ourselves, so nothing would tell us of a Hub that ended before
+ // that. Letting go of them then closes the connection, as a socket does when its peer ends.
+ auto hub_exit_watcher = Threading::Thread::construct("HubExitWatcher"sv, [hub_bootstrap, pid = process.pid()]() -> intptr_t {
+ siginfo_t info {};
+ while (waitid(P_PID, pid, &info, WEXITED | WNOWAIT) < 0 && errno == EINTR)
+ ;
+ hub_bootstrap->server.unregister_child_transport(pid);
+ return 0;
+ });
+ hub_exit_watcher->start();
+ hub_exit_watcher->detach();
+
+ auto transport = make<IPC::Transport>(move(port_a_recv), move(port_b_send));
+# else
+ int socket_fds[2] {};
+ TRY(Core::System::socketpair(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0, socket_fds));
+
spawn_options.file_actions.append(Core::FileAction::DupFd { .write_fd = socket_fds[1], .fd = socket_fds[1] });
TRY(Core::Environment::set("SOCKET_TAKEOVER"sv, ByteString::formatted("ipc:{}", socket_fds[1]), Core::Environment::Overwrite::Yes));
auto process = TRY(Core::Process::spawn(spawn_options));
@@ -705,7 +763,9 @@ ErrorOr<void> Application::connect_to_hub(Main::Arguments const& arguments)
auto ipc_socket = TRY(Core::LocalSocket::adopt_fd(socket_fds[0]));
TRY(ipc_socket->set_blocking(true));
- m_hub_connection = adopt_ref(*new HubConnection(make<IPC::Transport>(move(ipc_socket))));
+ auto transport = make<IPC::Transport>(move(ipc_socket));
+# endif
+ m_hub_connection = adopt_ref(*new HubConnection(move(transport)));
// The Hub can find that there is nothing for us to do, as when another process has this profile and takes our URLs,
// or when asked for its usage. It ends right away then, and how it ended is how we end.
@@ -719,8 +779,8 @@ ErrorOr<void> Application::connect_to_hub(Main::Arguments const& arguments)
m_settings = make<WebView::Settings>(WebView::Settings::create_from_json(TRY(JsonValue::from_string(state.settings_json))));
m_bookmark_store = make<WebView::BookmarkStore>(WebView::BookmarkStore::create_from_json(TRY(JsonValue::from_string(state.bookmarks_json))));
- // NB: Reports stay in files, which both of us read. This process keeps its own for when it crashes, and the next launch
- // recovers that the same as one of the Hub's.
+ // NB: Reports stay in files, which both of us read. This process keeps its own for when it crashes, and the next
+ // launch recovers that the same as one of the Hub's.
auto& crash_report_store = WebView::CrashReportStore::the();
crash_report_store.set_directory(move(state.crash_report_directory));
if (auto result = crash_report_store.initialize_browser_crash_handler(); result.is_error())
@@ -730,6 +790,9 @@ ErrorOr<void> Application::connect_to_hub(Main::Arguments const& arguments)
m_browser_options.raw_urls = move(state.raw_urls);
m_browser_options.devtools_port = state.devtools_port;
m_has_translator = state.has_translator;
+# if defined(AK_OS_MACOS)
+ set_profile_application_icon(state.profile_identifier, state.profile_identity, state.profile_is_temporary);
+# endif
RemoteActions::the().set_application_actions(state.actions);
RemoteDownloads::the().set_downloads(state.downloads);
@@ -755,8 +818,15 @@ Vector<WebView::ProcessSnapshot> Application::process_snapshots()
auto snapshots = HubConnection::the().process_snapshots();
// NB: The Hub knows the processes that it launched. Only this one can always tell how it is doing itself.
- if (m_ui_process_statistics.processes.is_empty())
- m_ui_process_statistics.processes.append(make<Core::Platform::ProcessInfo>(Core::System::getpid()));
+ if (m_ui_process_statistics.processes.is_empty()) {
+ auto process_info = make<Core::Platform::ProcessInfo>(Core::System::getpid());
+# if defined(AK_OS_MACH)
+ mach_port_t task_name_port = MACH_PORT_NULL;
+ VERIFY(task_get_special_port(mach_task_self(), TASK_NAME_PORT, &task_name_port) == KERN_SUCCESS);
+ process_info->task_name_port = Core::MachPort::adopt_right(task_name_port, Core::MachPort::PortRight::Send);
+# endif
+ m_ui_process_statistics.processes.append(move(process_info));
+ }
if (auto result = Core::Platform::update_process_statistics(m_ui_process_statistics); result.is_error())
dbgln("Unable to update the UI's process statistics: {}", result.error());
@@ -930,21 +1000,13 @@ void Application::did_create_event_loop(Core::EventLoop& event_loop)
#endif
#if defined(AK_OS_MACOS)
Ladybird::on_scrollbar_track_press_behavior_change([] {
- hub().platform_scrollbar_track_press_behavior_changed();
+ if (auto* hub = HubConnection::the_if_connected())
+ hub->async_ui_info_changed(Application::the().current_ui_info());
});
#endif
static_cast<EventLoopImplementationQt&>(event_loop.impl()).set_main_loop();
}
-OwnPtr<WebView::MicrophoneAuthorizer> Application::create_microphone_authorizer()
-{
-#if defined(AK_OS_MACOS)
- return make<WebView::MicrophoneAuthorizerMacOS>();
-#else
- return {};
-#endif
-}
-
Optional<String> Application::ui_font_family() const
{
if (!m_application)
diff --git a/UI/Qt/Application.h b/UI/Qt/Application.h
index bdcad0b3afc..a4d73f31ae7 100644
--- a/UI/Qt/Application.h
+++ b/UI/Qt/Application.h
@@ -76,9 +76,6 @@ public:
Function<void(Vector<URL::URL> const&)> on_new_tab;
Function<void(Vector<URL::URL> const&)> on_new_window;
static WebView::Settings& settings() { return *s_the->m_settings; }
-#ifndef LADYBIRD_HUB_IN_OWN_PROCESS
- static WebView::Profile const& profile() { return WebView::Application::profile(); }
-#endif
static WebView::BookmarkStore& bookmark_store() { return *s_the->m_bookmark_store; }
virtual ~Application() override;
@@ -174,7 +171,6 @@ private:
virtual void will_create_event_loop(Main::Arguments&) override;
virtual void did_create_event_loop(Core::EventLoop&) override;
virtual void create_platform_actions() override;
- virtual OwnPtr<WebView::MicrophoneAuthorizer> create_microphone_authorizer() override;
virtual Optional<String> ui_font_family() const override;
virtual Web::CSS::PreferredColorScheme interface_color_scheme() const override;
diff --git a/UI/Qt/ApplicationIcon.h b/UI/Qt/ApplicationIcon.h
index 61dd81782d4..8ae599aa98f 100644
--- a/UI/Qt/ApplicationIcon.h
+++ b/UI/Qt/ApplicationIcon.h
@@ -6,14 +6,10 @@
#pragma once
-namespace WebView {
-
-class Profile;
-
-}
+#include <AK/Forward.h>
namespace Ladybird {
-void set_profile_application_icon(WebView::Profile const&);
+void set_profile_application_icon(StringView identifier, ByteString const& identity, bool is_temporary);
}
diff --git a/UI/Qt/ApplicationIcon.mm b/UI/Qt/ApplicationIcon.mm
index 74a6588cd57..f78878abd8c 100644
--- a/UI/Qt/ApplicationIcon.mm
+++ b/UI/Qt/ApplicationIcon.mm
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <LibWebView/Profile.h>
+#include <AK/ByteString.h>
+#include <AK/StringView.h>
#include <UI/Qt/BrandColors.h>
#import <Cocoa/Cocoa.h>
@@ -12,14 +13,14 @@
namespace Ladybird {
-void set_profile_application_icon(WebView::Profile const& profile)
+void set_profile_application_icon(StringView identifier, ByteString const& identity, bool is_temporary)
{
- if (profile.identifier() == "default"sv)
+ if (identifier == "default"sv)
return;
- auto label = profile.is_temporary()
+ auto label = is_temporary
? "tmp"sv
- : profile.identifier().substring_view(0, min(profile.identifier().length(), 3uz));
+ : identifier.substring_view(0, min(identifier.length(), 3uz));
auto* profile_label = [[[NSString alloc] initWithBytes:label.characters_without_null_termination()
length:label.length()
encoding:NSUTF8StringEncoding]
@@ -42,7 +43,7 @@ void set_profile_application_icon(WebView::Profile const& profile)
ns_color(BrandColors::SlateBlue900),
ns_color(BrandColors::Indigo60),
];
- auto* badge_color = badge_colors[profile.paths().identity.hash() % [badge_colors count]];
+ auto* badge_color = badge_colors[identity.hash() % [badge_colors count]];
auto icon_size = [application_icon size];
auto* profile_icon = [NSImage imageWithSize:icon_size
diff --git a/UI/Qt/CMakeLists.txt b/UI/Qt/CMakeLists.txt
index 825f0829b40..557933c328b 100644
--- a/UI/Qt/CMakeLists.txt
+++ b/UI/Qt/CMakeLists.txt
@@ -138,7 +138,6 @@ if (APPLE)
NativeTextEditingBindings.mm
Menu.mm
ScrollbarPreferencesMac.mm
- SpellCheckerMac.mm
SystemAppearanceMac.mm
TranslateIconMac.mm
WebContentViewAccessibility.mm
@@ -147,7 +146,6 @@ if (APPLE)
target_link_libraries(ladybird_impl PRIVATE Qt::GuiPrivate "-framework ApplicationServices" "-framework Cocoa" "-framework IOSurface" "-framework QuartzCore")
set_source_files_properties(
LadybirdAccessibilityElement.mm
- SpellCheckerMac.mm
TranslateIconMac.mm
TranslatorMac.mm
WebContentViewAccessibility.mm
diff --git a/UI/Qt/main.cpp b/UI/Qt/main.cpp
index cb1b174f7c3..d867aa4ae05 100644
--- a/UI/Qt/main.cpp
+++ b/UI/Qt/main.cpp
@@ -28,12 +28,7 @@
#if defined(AK_OS_MACOS)
# include <QColorSpace>
# include <QSurfaceFormat>
-# include <UI/Qt/ApplicationIcon.h>
# include <UI/Qt/MacWindow.h>
-# include <UI/Qt/SpellCheckerMac.h>
-#endif
-#if defined(LADYBIRD_HAS_TRANSLATOR)
-# include <UI/Qt/TranslatorMac.h>
#endif
ErrorOr<int> ladybird_main(Main::Arguments arguments)
@@ -71,17 +66,8 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)
return *exit_status;
Ladybird::ChromeStyle::install_application_style();
-#if defined(AK_OS_MACOS)
- Ladybird::Application::hub().set_spell_checker(Ladybird::create_platform_spell_checker());
-#endif
-#if defined(LADYBIRD_HAS_TRANSLATOR)
- Ladybird::Application::hub().set_translator(Ladybird::create_platform_translator());
-#endif
if (auto const& browser_options = Ladybird::Application::browser_options(); !browser_options.headless_mode.has_value()) {
-#if defined(AK_OS_MACOS)
- Ladybird::set_profile_application_icon(Ladybird::Application::profile());
-#endif
Ladybird::SystemAppearance::the().apply_interface_theme(Ladybird::Application::settings().appearance().interface_theme);
Ladybird::SystemAppearance::the().apply_color_theme(Ladybird::Application::settings().appearance().color_theme);