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