Ladybird/Android: Implement enough of WebContent to load local files

The local files can only be loaded by calling loadURL on the WebView,
but it's a start.
This commit is contained in:
Andrew Kaster 2023-09-13 23:22:44 -06:00 committed by Andrew Kaster
parent bd131c0bf8
commit a58ee0ecd2
Notes: sideshowbarker 2024-07-17 18:13:59 +09:00
8 changed files with 235 additions and 43 deletions

View file

@ -5,35 +5,34 @@
*/
#include "ALooperEventLoopImplementation.h"
#include <AK/Format.h>
#include <AK/OwnPtr.h>
#include <Ladybird/Utilities.h>
#include <LibCore/EventLoop.h>
#include <LibCore/Timer.h>
#include <android/log.h>
#include <jni.h>
OwnPtr<Core::EventLoop> s_main_event_loop;
RefPtr<Core::Timer> s_timer;
extern "C" JNIEXPORT void JNICALL
Java_org_serenityos_ladybird_LadybirdActivity_initNativeCode(JNIEnv* env, jobject /* thiz */, jstring resource_dir, jobject timer_service)
Java_org_serenityos_ladybird_LadybirdActivity_initNativeCode(JNIEnv* env, jobject /* thiz */, jstring resource_dir, jstring tag_name, jobject timer_service)
{
char const* raw_resource_dir = env->GetStringUTFChars(resource_dir, nullptr);
s_serenity_resource_root = raw_resource_dir;
__android_log_print(ANDROID_LOG_INFO, "Ladybird", "Serenity resource dir is %s", s_serenity_resource_root.characters());
env->ReleaseStringUTFChars(resource_dir, raw_resource_dir);
char const* raw_tag_name = env->GetStringUTFChars(tag_name, nullptr);
AK::set_log_tag_name(raw_tag_name);
env->ReleaseStringUTFChars(tag_name, raw_tag_name);
dbgln("Set resource dir to {}", s_serenity_resource_root);
jobject timer_service_ref = env->NewGlobalRef(timer_service);
JavaVM* vm = nullptr;
jint ret = env->GetJavaVM(&vm);
VERIFY(ret == 0);
Core::EventLoopManager::install(*new Ladybird::ALooperEventLoopManager(vm, timer_service_ref));
s_main_event_loop = make<Core::EventLoop>();
s_timer = MUST(Core::Timer::create_repeating(1000, [] {
__android_log_print(ANDROID_LOG_DEBUG, "Ladybird", "EventLoop is alive!");
}));
s_timer->start();
}
extern "C" JNIEXPORT void JNICALL