OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "android_webview/lib/main/aw_main_delegate.h" | 5 #include "android_webview/lib/main/aw_main_delegate.h" |
6 #include "android_webview/native/android_webview_jni_registrar.h" | 6 #include "android_webview/native/android_webview_jni_registrar.h" |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_registrar.h" | 8 #include "base/android/jni_registrar.h" |
9 #include "components/navigation_interception/component_jni_registrar.h" | 9 #include "components/navigation_interception/component_jni_registrar.h" |
10 #include "components/web_contents_delegate_android/component_jni_registrar.h" | 10 #include "components/web_contents_delegate_android/component_jni_registrar.h" |
11 #include "content/public/app/android_library_loader_hooks.h" | 11 #include "content/public/app/android_library_loader_hooks.h" |
12 #include "content/public/app/content_main.h" | 12 #include "content/public/app/content_main.h" |
13 | 13 |
14 static base::android::RegistrationMethod | 14 static base::android::RegistrationMethod |
15 kWebViewDependencyRegisteredMethods[] = { | 15 kWebViewDependencyRegisteredMethods[] = { |
16 { "NavigationInterception", | 16 { "NavigationInterception", |
17 navigation_interception::RegisterNavigationInterceptionJni }, | 17 navigation_interception::RegisterNavigationInterceptionJni }, |
18 { "WebContentsDelegateAndroid", | 18 { "WebContentsDelegateAndroid", |
19 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni }, | 19 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni }, |
20 }; | 20 }; |
21 | 21 |
22 // This is called by the VM when the shared library is first loaded. | 22 // This is called by the VM when the shared library is first loaded. |
23 // Most of the initialization is done in LibraryLoadedOnMainThread(), not here. | 23 // Most of the initialization is done in LibraryLoadedOnMainThread(), not here. |
24 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { | 24 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
25 base::android::InitVM(vm); | 25 base::android::InitVM(vm); |
26 JNIEnv* env = base::android::AttachCurrentThread(); | 26 JNIEnv* env = base::android::AttachCurrentThread(); |
27 if (!content::RegisterLibraryLoaderEntryHook(env)) | 27 if (!content::RegisterLibraryLoaderEntryHook(env)) |
28 return -1; | 28 return -1; |
29 | 29 |
| 30 // Register content JNI functions now, rather than waiting until |
| 31 // LibraryLoadedOnMainThread, so that we can call into native code early. |
| 32 if (!content::EnsureJniRegistered(env)) |
| 33 return -1; |
| 34 |
30 // Register JNI for components we depend on. | 35 // Register JNI for components we depend on. |
31 if (!RegisterNativeMethods( | 36 if (!RegisterNativeMethods( |
32 env, | 37 env, |
33 kWebViewDependencyRegisteredMethods, | 38 kWebViewDependencyRegisteredMethods, |
34 arraysize(kWebViewDependencyRegisteredMethods))) | 39 arraysize(kWebViewDependencyRegisteredMethods))) |
35 return -1; | 40 return -1; |
36 | 41 |
37 if (!android_webview::RegisterJni(env)) | 42 if (!android_webview::RegisterJni(env)) |
38 return -1; | 43 return -1; |
39 | 44 |
40 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); | 45 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); |
41 | 46 |
42 return JNI_VERSION_1_4; | 47 return JNI_VERSION_1_4; |
43 } | 48 } |
OLD | NEW |