summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustav Sennton <gsennton@google.com>2017-06-20 17:13:46 +0100
committerGustav Sennton <gsennton@google.com>2017-06-20 17:27:13 +0100
commit296e4676e6286ba1f2296f6e778f78e8b4d27bea (patch)
treec9d5a9ea9197925af98fe2cafd3b13c0228dc366
parent8d3658cd163b52950175c12ee6ec2f4afaede70f (diff)
downloadwebview-296e4676e6286ba1f2296f6e778f78e8b4d27bea.tar.gz
Move native methods from WebViewFactory to WebViewLibraryLoader.
To clean up WebViewFactory we are moving some of its functionality into a new class, WebViewLibraryLoader. Some of this functionality is native, and thus we need to update JNI registration code. Bug: 28736099 Test: start WebView-using app, ensure libwebviewchromium64.relro is loaded into the app process. Change-Id: I0dbf5d15fe33e75605e100850d06f48cb49b949c
-rw-r--r--chromium/loader/loader.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/chromium/loader/loader.cpp b/chromium/loader/loader.cpp
index 91c0a21..565c6b0 100644
--- a/chromium/loader/loader.cpp
+++ b/chromium/loader/loader.cpp
@@ -191,7 +191,9 @@ jint LoadWithRelroFile(JNIEnv* env, jclass, jstring lib32, jstring lib64,
return ret;
}
-const char kClassName[] = "android/webkit/WebViewFactory";
+const char kWebViewFactoryClassName[] = "android/webkit/WebViewFactory";
+const char kWebViewLibraryLoaderClassName[] =
+ "android/webkit/WebViewLibraryLoader";
const JNINativeMethod kJniMethods[] = {
{ "nativeReserveAddressSpace", "(J)Z",
reinterpret_cast<void*>(ReserveAddressSpace) },
@@ -208,10 +210,8 @@ const JNINativeMethod kJniMethods[] = {
void RegisterWebViewFactory(JNIEnv* env) {
// If either of these fail, it will set an exception that will be thrown on
// return, so no need to handle errors here.
- jclass clazz = env->FindClass(kClassName);
+ jclass clazz = env->FindClass(kWebViewFactoryClassName);
if (clazz) {
- env->RegisterNatives(clazz, kJniMethods, NELEM(kJniMethods));
-
LIBLOAD_SUCCESS = env->GetStaticIntField(
clazz,
env->GetStaticFieldID(clazz, "LIBLOAD_SUCCESS", "I"));
@@ -234,6 +234,15 @@ void RegisterWebViewFactory(JNIEnv* env) {
}
}
+void RegisterWebViewLibraryLoader(JNIEnv* env) {
+ // If either of these fail, it will set an exception that will be thrown on
+ // return, so no need to handle errors here.
+ jclass clazz = env->FindClass(kWebViewLibraryLoaderClassName);
+ if (clazz) {
+ env->RegisterNatives(clazz, kJniMethods, NELEM(kJniMethods));
+ }
+}
+
} // namespace android
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
@@ -243,5 +252,10 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
return JNI_ERR;
}
android::RegisterWebViewFactory(env);
+ // Ensure there isn't a pending Java exception before registering methods from
+ // WebViewLibraryLoader
+ if (!env->ExceptionCheck()) {
+ android::RegisterWebViewLibraryLoader(env);
+ }
return JNI_VERSION_1_6;
}