| 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_delegate.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/android/jni_utils.h" | 11 #include "base/android/jni_utils.h" |
| 12 #include "components/navigation_interception/component_jni_registrar.h" | 12 #include "components/navigation_interception/component_jni_registrar.h" |
| 13 #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" | |
| 15 #include "content/public/app/content_main.h" | 14 #include "content/public/app/content_main.h" |
| 16 #include "url/url_util.h" | 15 #include "url/url_util.h" |
| 17 | 16 |
| 18 namespace android_webview { | 17 namespace android_webview { |
| 19 | 18 |
| 20 namespace { | 19 namespace { |
| 21 | 20 |
| 22 static base::android::RegistrationMethod | 21 static base::android::RegistrationMethod |
| 23 kWebViewDependencyRegisteredMethods[] = { | 22 kWebViewDependencyRegisteredMethods[] = { |
| 24 { "NavigationInterception", | 23 { "NavigationInterception", |
| 25 navigation_interception::RegisterNavigationInterceptionJni }, | 24 navigation_interception::RegisterNavigationInterceptionJni }, |
| 26 { "WebContentsDelegateAndroid", | 25 { "WebContentsDelegateAndroid", |
| 27 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni }, | 26 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni }, |
| 28 }; | 27 }; |
| 29 | 28 |
| 30 } // namespace | 29 } // namespace |
| 31 | 30 |
| 32 bool WebViewJNIOnLoadDelegate::RegisterJNI(JNIEnv* env) { | 31 bool RegisterJNI(JNIEnv* env) { |
| 33 // Register JNI for components we depend on. | 32 // Register JNI for components we depend on. |
| 34 if (!RegisterNativeMethods( | 33 if (!RegisterNativeMethods( |
| 35 env, | 34 env, |
| 36 kWebViewDependencyRegisteredMethods, | 35 kWebViewDependencyRegisteredMethods, |
| 37 arraysize(kWebViewDependencyRegisteredMethods)) || | 36 arraysize(kWebViewDependencyRegisteredMethods)) || |
| 38 !android_webview::RegisterJni(env)) { | 37 !android_webview::RegisterJni(env)) { |
| 39 return false; | 38 return false; |
| 40 } | 39 } |
| 41 return true; | 40 return true; |
| 42 } | 41 } |
| 43 | 42 |
| 44 bool WebViewJNIOnLoadDelegate::Init() { | 43 bool Init() { |
| 45 JNIEnv* env = base::android::AttachCurrentThread(); | 44 JNIEnv* env = base::android::AttachCurrentThread(); |
| 46 base::android::InitReplacementClassLoader(env, | 45 base::android::InitReplacementClassLoader(env, |
| 47 base::android::GetClassLoader(env)); | 46 base::android::GetClassLoader(env)); |
| 48 | 47 |
| 49 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); | 48 content::SetContentMainDelegate(new android_webview::AwMainDelegate()); |
| 50 | 49 |
| 51 // Initialize url lib here while we are still single-threaded, in case we use | 50 // Initialize url lib here while we are still single-threaded, in case we use |
| 52 // CookieManager before initializing Chromium (which would normally have done | 51 // CookieManager before initializing Chromium (which would normally have done |
| 53 // this). It's safe to call this multiple times. | 52 // this). It's safe to call this multiple times. |
| 54 url::Initialize(); | 53 url::Initialize(); |
| 55 return true; | 54 return true; |
| 56 } | 55 } |
| 57 | 56 |
| 58 bool OnJNIOnLoad(JavaVM* vm) { | |
| 59 WebViewJNIOnLoadDelegate delegate; | |
| 60 return content::android::OnJNIOnLoad(vm, &delegate); | |
| 61 } | |
| 62 | |
| 63 } // android_webview | 57 } // android_webview |
| OLD | NEW |