OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/webview_jni_onload.h" | 5 #include "android_webview/lib/main/webview_jni_onload.h" |
6 | 6 |
7 #include "android_webview/common/aw_version_info_values.h" | 7 #include "android_webview/common/aw_version_info_values.h" |
8 #include "android_webview/lib/main/aw_main_delegate.h" | 8 #include "android_webview/lib/main/aw_main_delegate.h" |
9 #include "android_webview/native/android_webview_jni_registrar.h" | 9 #include "android_webview/native/android_webview_jni_registrar.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
11 #include "base/android/jni_registrar.h" | 11 #include "base/android/jni_registrar.h" |
12 #include "base/android/library_loader/library_loader_hooks.h" | 12 #include "base/android/library_loader/library_loader_hooks.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "components/web_contents_delegate_android/component_jni_registrar.h" | 14 #include "components/web_contents_delegate_android/component_jni_registrar.h" |
15 #include "content/public/app/content_jni_onload.h" | 15 #include "content/public/app/content_jni_onload.h" |
16 #include "content/public/app/content_main.h" | 16 #include "content/public/app/content_main.h" |
17 #include "url/url_util.h" | 17 #include "url/url_util.h" |
18 | 18 |
19 namespace android_webview { | 19 namespace android_webview { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 static base::android::RegistrationMethod | 23 static base::android::RegistrationMethod |
24 kWebViewDependencyRegisteredMethods[] = { | 24 kWebViewDependencyRegisteredMethods[] = { |
25 { "WebContentsDelegateAndroid", | 25 { "WebContentsDelegateAndroid", |
26 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni }, | 26 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni }, |
27 }; | 27 }; |
28 | 28 |
29 bool RegisterJNI(JNIEnv* env) { | 29 } // namespace |
| 30 |
| 31 bool OnJNIOnLoadRegisterJNI(JNIEnv* env) { |
| 32 if (!content::android::OnJNIOnLoadRegisterJNI(env)) |
| 33 return false; |
| 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 !android_webview::RegisterJni(env)) { | 40 !android_webview::RegisterJni(env)) { |
36 return false; | 41 return false; |
37 } | 42 } |
38 return true; | 43 return true; |
39 } | 44 } |
40 | 45 |
41 bool Init() { | 46 bool OnJNIOnLoadInit() { |
| 47 if (!content::android::OnJNIOnLoadInit()) |
| 48 return false; |
| 49 |
42 base::android::SetVersionNumber(PRODUCT_VERSION); | 50 base::android::SetVersionNumber(PRODUCT_VERSION); |
43 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); | 51 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); |
44 | 52 |
45 // Initialize url lib here while we are still single-threaded, in case we use | 53 // Initialize url lib here while we are still single-threaded, in case we use |
46 // CookieManager before initializing Chromium (which would normally have done | 54 // CookieManager before initializing Chromium (which would normally have done |
47 // this). It's safe to call this multiple times. | 55 // this). It's safe to call this multiple times. |
48 url::Initialize(); | 56 url::Initialize(); |
49 return true; | 57 return true; |
50 } | 58 } |
51 | 59 |
52 } // namespace | |
53 | |
54 bool OnJNIOnLoadRegisterJNI(JavaVM* vm) { | |
55 std::vector<base::android::RegisterCallback> register_callbacks; | |
56 register_callbacks.push_back(base::Bind(&RegisterJNI)); | |
57 return content::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks); | |
58 } | |
59 | |
60 bool OnJNIOnLoadInit() { | |
61 std::vector<base::android::InitCallback> init_callbacks; | |
62 init_callbacks.push_back(base::Bind(&Init)); | |
63 return content::android::OnJNIOnLoadInit(init_callbacks); | |
64 } | |
65 | |
66 } // android_webview | 60 } // android_webview |
OLD | NEW |