| 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(JavaVM* vm) { |
| 32 if (!content::android::OnJNIOnLoadRegisterJNI(vm)) |
| 33 return false; |
| 34 |
| 30 // Register JNI for components we depend on. | 35 // Register JNI for components we depend on. |
| 36 JNIEnv* env = base::android::AttachCurrentThread(); |
| 31 if (!RegisterNativeMethods( | 37 if (!RegisterNativeMethods( |
| 32 env, | 38 env, |
| 33 kWebViewDependencyRegisteredMethods, | 39 kWebViewDependencyRegisteredMethods, |
| 34 arraysize(kWebViewDependencyRegisteredMethods)) || | 40 arraysize(kWebViewDependencyRegisteredMethods)) || |
| 35 !android_webview::RegisterJni(env)) { | 41 !android_webview::RegisterJni(env)) { |
| 36 return false; | 42 return false; |
| 37 } | 43 } |
| 38 return true; | 44 return true; |
| 39 } | 45 } |
| 40 | 46 |
| 41 bool Init() { | 47 bool OnJNIOnLoadInit() { |
| 48 if (!content::android::OnJNIOnLoadInit()) |
| 49 return false; |
| 50 |
| 42 base::android::SetVersionNumber(PRODUCT_VERSION); | 51 base::android::SetVersionNumber(PRODUCT_VERSION); |
| 43 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); | 52 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); |
| 44 | 53 |
| 45 // Initialize url lib here while we are still single-threaded, in case we use | 54 // Initialize url lib here while we are still single-threaded, in case we use |
| 46 // CookieManager before initializing Chromium (which would normally have done | 55 // CookieManager before initializing Chromium (which would normally have done |
| 47 // this). It's safe to call this multiple times. | 56 // this). It's safe to call this multiple times. |
| 48 url::Initialize(); | 57 url::Initialize(); |
| 49 return true; | 58 return true; |
| 50 } | 59 } |
| 51 | 60 |
| 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 | 61 } // android_webview |
| OLD | NEW |