Chromium Code Reviews| 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/lib/main/aw_main_delegate.h" | 7 #include "android_webview/lib/main/aw_main_delegate.h" |
| 8 #include "android_webview/native/android_webview_jni_registrar.h" | 8 #include "android_webview/native/android_webview_jni_registrar.h" |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_registrar.h" | 10 #include "base/android/jni_registrar.h" |
| 11 #include "base/bind.h" | |
| 11 #include "components/navigation_interception/component_jni_registrar.h" | 12 #include "components/navigation_interception/component_jni_registrar.h" |
| 12 #include "components/web_contents_delegate_android/component_jni_registrar.h" | 13 #include "components/web_contents_delegate_android/component_jni_registrar.h" |
| 14 #include "content/public/app/content_jni_onload.h" | |
| 13 #include "content/public/app/content_main.h" | 15 #include "content/public/app/content_main.h" |
| 14 #include "url/url_util.h" | 16 #include "url/url_util.h" |
| 15 | 17 |
| 16 namespace android_webview { | 18 namespace android_webview { |
| 17 | 19 |
| 18 namespace { | 20 namespace { |
| 19 | 21 |
| 20 static base::android::RegistrationMethod | 22 static base::android::RegistrationMethod |
| 21 kWebViewDependencyRegisteredMethods[] = { | 23 kWebViewDependencyRegisteredMethods[] = { |
| 22 { "NavigationInterception", | 24 { "NavigationInterception", |
| 23 navigation_interception::RegisterNavigationInterceptionJni }, | 25 navigation_interception::RegisterNavigationInterceptionJni }, |
| 24 { "WebContentsDelegateAndroid", | 26 { "WebContentsDelegateAndroid", |
| 25 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni }, | 27 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni }, |
| 26 }; | 28 }; |
| 27 | 29 |
| 28 } // namespace | |
| 29 | |
| 30 bool RegisterJNI(JNIEnv* env) { | 30 bool RegisterJNI(JNIEnv* env) { |
| 31 // Register JNI for components we depend on. | 31 // Register JNI for components we depend on. |
| 32 if (!RegisterNativeMethods( | 32 if (!RegisterNativeMethods( |
| 33 env, | 33 env, |
| 34 kWebViewDependencyRegisteredMethods, | 34 kWebViewDependencyRegisteredMethods, |
| 35 arraysize(kWebViewDependencyRegisteredMethods)) || | 35 arraysize(kWebViewDependencyRegisteredMethods)) || |
| 36 !android_webview::RegisterJni(env)) { | 36 !android_webview::RegisterJni(env)) { |
| 37 return false; | 37 return false; |
| 38 } | 38 } |
| 39 return true; | 39 return true; |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool Init() { | 42 bool Init() { |
| 43 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); | 43 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); |
| 44 | 44 |
| 45 // Initialize url lib here while we are still single-threaded, in case we use | 45 // Initialize url lib here while we are still single-threaded, in case we use |
| 46 // CookieManager before initializing Chromium (which would normally have done | 46 // CookieManager before initializing Chromium (which would normally have done |
| 47 // this). It's safe to call this multiple times. | 47 // this). It's safe to call this multiple times. |
| 48 url::Initialize(); | 48 url::Initialize(); |
| 49 return true; | 49 return true; |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace | |
| 53 | |
| 54 bool OnJNIOnLoadRegisterJNI(JavaVM* vm) { | |
| 55 // WebView uses native JNI exports; disable manual JNI registration to | |
| 56 // improve startup peformance. | |
| 57 base::android::DisableManualJniRegistration(); | |
|
Torne
2015/03/05 18:56:09
I think we should leave this in JNI_OnLoad, since
michaelbai
2015/03/05 19:28:53
Will WebView always disable JNI Registration no ma
| |
| 58 | |
| 59 std::vector<base::android::RegisterCallback> register_callbacks; | |
| 60 register_callbacks.push_back(base::Bind(&RegisterJNI)); | |
| 61 return content::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks); | |
| 62 } | |
| 63 | |
| 64 bool OnJNIOnLoadInit() { | |
| 65 std::vector<base::android::InitCallback> init_callbacks; | |
| 66 init_callbacks.push_back(base::Bind(&Init)); | |
| 67 return content::android::OnJNIOnLoadInit(init_callbacks); | |
| 68 } | |
| 69 | |
| 52 } // android_webview | 70 } // android_webview |
| OLD | NEW |