2023-08-20 20:14:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2023-10-13 15:04:07 +00:00
|
|
|
#include <BrowserSettings/Defaults.h>
|
2023-08-20 20:14:31 +00:00
|
|
|
#include <Ladybird/Utilities.h>
|
|
|
|
#include <LibCore/ArgsParser.h>
|
|
|
|
#include <LibCore/EventLoop.h>
|
|
|
|
#include <LibGfx/Font/FontDatabase.h>
|
|
|
|
#include <LibMain/Main.h>
|
2023-08-31 11:07:07 +00:00
|
|
|
#include <LibWebView/CookieJar.h>
|
|
|
|
#include <LibWebView/Database.h>
|
2023-10-13 15:04:07 +00:00
|
|
|
#include <LibWebView/URL.h>
|
2023-08-20 20:14:31 +00:00
|
|
|
|
|
|
|
#import <Application/Application.h>
|
|
|
|
#import <Application/ApplicationDelegate.h>
|
|
|
|
#import <Application/EventLoopImplementation.h>
|
|
|
|
#import <UI/Tab.h>
|
|
|
|
#import <UI/TabController.h>
|
|
|
|
|
|
|
|
#if !__has_feature(objc_arc)
|
|
|
|
# error "This project requires ARC"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
|
|
{
|
|
|
|
[Application sharedApplication];
|
|
|
|
|
|
|
|
Core::EventLoopManager::install(*new Ladybird::CFEventLoopManager);
|
|
|
|
Core::EventLoop event_loop;
|
|
|
|
|
|
|
|
platform_init();
|
|
|
|
|
|
|
|
// NOTE: We only instantiate this to ensure that Gfx::FontDatabase has its default queries initialized.
|
|
|
|
Gfx::FontDatabase::set_default_font_query("Katica 10 400 0");
|
|
|
|
Gfx::FontDatabase::set_fixed_width_font_query("Csilla 10 400 0");
|
|
|
|
|
2023-10-13 15:04:07 +00:00
|
|
|
Vector<StringView> raw_urls;
|
2023-08-20 20:14:31 +00:00
|
|
|
StringView webdriver_content_ipc_path;
|
|
|
|
|
|
|
|
Core::ArgsParser args_parser;
|
|
|
|
args_parser.set_general_help("The Ladybird web browser");
|
2023-10-13 15:04:07 +00:00
|
|
|
args_parser.add_positional_argument(raw_urls, "URLs to open", "url", Core::ArgsParser::Required::No);
|
2023-09-03 13:14:56 +00:00
|
|
|
args_parser.add_option(webdriver_content_ipc_path, "Path to WebDriver IPC for WebContent", "webdriver-content-path", 0, "path", Core::ArgsParser::OptionHideMode::CommandLineAndMarkdown);
|
2023-08-20 20:14:31 +00:00
|
|
|
args_parser.parse(arguments);
|
|
|
|
|
|
|
|
auto sql_server_paths = TRY(get_paths_for_helper_process("SQLServer"sv));
|
2023-08-31 11:21:54 +00:00
|
|
|
auto database = TRY(WebView::Database::create(move(sql_server_paths)));
|
2023-08-31 11:07:07 +00:00
|
|
|
auto cookie_jar = TRY(WebView::CookieJar::create(*database));
|
2023-08-20 20:14:31 +00:00
|
|
|
|
2023-11-05 14:35:20 +00:00
|
|
|
URL new_tab_page_url = Browser::default_new_tab_url();
|
2023-10-13 15:04:07 +00:00
|
|
|
Vector<URL> initial_urls;
|
|
|
|
|
|
|
|
for (auto const& raw_url : raw_urls) {
|
|
|
|
if (auto url = WebView::sanitize_url(raw_url); url.has_value())
|
|
|
|
initial_urls.append(url.release_value());
|
2023-08-20 20:14:31 +00:00
|
|
|
}
|
|
|
|
|
2023-10-13 15:04:07 +00:00
|
|
|
if (initial_urls.is_empty())
|
|
|
|
initial_urls.append(new_tab_page_url);
|
|
|
|
|
|
|
|
auto* delegate = [[ApplicationDelegate alloc] init:move(initial_urls)
|
|
|
|
newTabPageURL:move(new_tab_page_url)
|
2023-08-20 20:14:31 +00:00
|
|
|
withCookieJar:move(cookie_jar)
|
|
|
|
webdriverContentIPCPath:webdriver_content_ipc_path];
|
|
|
|
|
|
|
|
[NSApp setDelegate:delegate];
|
|
|
|
|
|
|
|
return event_loop.exec();
|
|
|
|
}
|