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 "base/android/library_loader/library_loader_hooks.h" |
9 #include "components/navigation_interception/component_jni_registrar.h" | 10 #include "components/navigation_interception/component_jni_registrar.h" |
10 #include "components/web_contents_delegate_android/component_jni_registrar.h" | 11 #include "components/web_contents_delegate_android/component_jni_registrar.h" |
11 #include "content/public/app/android_library_loader_hooks.h" | 12 #include "content/public/app/android_library_loader_hooks.h" |
12 #include "content/public/app/content_main.h" | 13 #include "content/public/app/content_main.h" |
13 #include "url/url_util.h" | 14 #include "url/url_util.h" |
14 | 15 |
15 static base::android::RegistrationMethod | 16 static base::android::RegistrationMethod |
16 kWebViewDependencyRegisteredMethods[] = { | 17 kWebViewDependencyRegisteredMethods[] = { |
17 { "NavigationInterception", | 18 { "NavigationInterception", |
18 navigation_interception::RegisterNavigationInterceptionJni }, | 19 navigation_interception::RegisterNavigationInterceptionJni }, |
19 { "WebContentsDelegateAndroid", | 20 { "WebContentsDelegateAndroid", |
20 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni }, | 21 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni }, |
21 }; | 22 }; |
22 | 23 |
23 // This is called by the VM when the shared library is first loaded. | 24 // This is called by the VM when the shared library is first loaded. |
24 // Most of the initialization is done in LibraryLoadedOnMainThread(), not here. | 25 // Most of the initialization is done in LibraryLoadedOnMainThread(), not here. |
25 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { | 26 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
| 27 |
| 28 base::android::SetLibraryLoadedHook(&content::LibraryLoaded); |
| 29 |
26 base::android::InitVM(vm); | 30 base::android::InitVM(vm); |
27 JNIEnv* env = base::android::AttachCurrentThread(); | 31 JNIEnv* env = base::android::AttachCurrentThread(); |
28 if (!content::RegisterLibraryLoaderEntryHook(env)) | 32 if (!base::android::RegisterLibraryLoaderEntryHook(env)) |
29 return -1; | 33 return -1; |
30 | 34 |
31 // Register content JNI functions now, rather than waiting until | 35 // Register content JNI functions now, rather than waiting until |
32 // LibraryLoadedOnMainThread, so that we can call into native code early. | 36 // LibraryLoadedOnMainThread, so that we can call into native code early. |
33 if (!content::EnsureJniRegistered(env)) | 37 if (!content::EnsureJniRegistered(env)) |
34 return -1; | 38 return -1; |
35 | 39 |
36 // Register JNI for components we depend on. | 40 // Register JNI for components we depend on. |
37 if (!RegisterNativeMethods( | 41 if (!RegisterNativeMethods( |
38 env, | 42 env, |
39 kWebViewDependencyRegisteredMethods, | 43 kWebViewDependencyRegisteredMethods, |
40 arraysize(kWebViewDependencyRegisteredMethods))) | 44 arraysize(kWebViewDependencyRegisteredMethods))) |
41 return -1; | 45 return -1; |
42 | 46 |
43 if (!android_webview::RegisterJni(env)) | 47 if (!android_webview::RegisterJni(env)) |
44 return -1; | 48 return -1; |
45 | 49 |
46 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); | 50 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); |
47 | 51 |
48 // Initialize url_util here while we are still single-threaded, in case we use | 52 // Initialize url_util here while we are still single-threaded, in case we use |
49 // CookieManager before initializing Chromium (which would normally have done | 53 // CookieManager before initializing Chromium (which would normally have done |
50 // this). It's safe to call this multiple times. | 54 // this). It's safe to call this multiple times. |
51 url_util::Initialize(); | 55 url_util::Initialize(); |
52 | 56 |
53 return JNI_VERSION_1_4; | 57 return JNI_VERSION_1_4; |
54 } | 58 } |
OLD | NEW |