Android: Use LibWebView for command line flags

On Android there's really no real way to provide command line flags.
We are using a dummy Main::Argument that only contains "ladybird"
as a name of the program.
The strings of Main::Argument cannot be empty, otherwise the program
throws an error. However the argc and argv can be set to 0 and nullptr
This commit is contained in:
Olekoop 2024-08-07 20:59:46 +02:00 committed by Andrew Kaster
parent 7cee53fad6
commit bf84a681a5
Notes: github-actions[bot] 2024-09-03 06:19:09 +00:00

View file

@ -30,6 +30,13 @@ static OwnPtr<Core::EventLoop> s_main_event_loop;
static jobject s_java_instance;
static jmethodID s_schedule_event_loop_method;
struct Application : public WebView::Application {
WEB_VIEW_APPLICATION(Application);
};
Application::Application(Badge<WebView::Application>, Main::Arguments&)
{
}
extern "C" JNIEXPORT void JNICALL
Java_org_serenityos_ladybird_LadybirdActivity_initNativeCode(JNIEnv*, jobject, jstring, jstring, jobject);
@ -76,10 +83,17 @@ Java_org_serenityos_ladybird_LadybirdActivity_initNativeCode(JNIEnv* env, jobjec
Core::EventLoopManager::install(*event_loop_manager);
s_main_event_loop = make<Core::EventLoop>();
// The strings cannot be empty
Main::Arguments arguments = {
.argc = 0,
.argv = nullptr,
.strings = Span<StringView> { new StringView("ladybird"sv), 1 }
};
// FIXME: We are not making use of this Application object to track our processes.
// So, right now, the Application's ProcessManager is constantly empty.
// (However, LibWebView depends on an Application object existing, so we do have to actually create one.)
s_application = make<WebView::Application>(0, nullptr);
s_application = Application::create(arguments, "about:newtab"sv);
}
extern "C" JNIEXPORT void JNICALL