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
3 // found in the LICENSE file.
5 #include "android_webview/lib/main/webview_jni_onload.h"
7 #include "android_webview/lib/main/aw_main_delegate.h"
8 #include "android_webview/native/android_webview_jni_registrar.h"
9 #include "base/android/jni_android.h"
10 #include "base/android/jni_registrar.h"
11 #include "base/bind.h"
12 #include "components/external_video_surface/component_jni_registrar.h"
13 #include "components/navigation_interception/component_jni_registrar.h"
14 #include "components/web_contents_delegate_android/component_jni_registrar.h"
15 #include "content/public/app/content_jni_onload.h"
16 #include "content/public/app/content_main.h"
17 #include "url/url_util.h"
19 namespace android_webview
{
23 static base::android::RegistrationMethod
24 kWebViewDependencyRegisteredMethods
[] = {
25 #if defined(VIDEO_HOLE)
26 { "ExternalVideoSurfaceContainer",
27 external_video_surface::RegisterExternalVideoSurfaceJni
},
29 { "NavigationInterception",
30 navigation_interception::RegisterNavigationInterceptionJni
},
31 { "WebContentsDelegateAndroid",
32 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni
},
35 bool RegisterJNI(JNIEnv
* env
) {
36 // Register JNI for components we depend on.
37 if (!RegisterNativeMethods(
39 kWebViewDependencyRegisteredMethods
,
40 arraysize(kWebViewDependencyRegisteredMethods
)) ||
41 !android_webview::RegisterJni(env
)) {
48 content::SetContentMainDelegate(new android_webview::AwMainDelegate());
50 // Initialize url lib here while we are still single-threaded, in case we use
51 // CookieManager before initializing Chromium (which would normally have done
52 // this). It's safe to call this multiple times.
59 bool OnJNIOnLoadRegisterJNI(JavaVM
* vm
) {
60 std::vector
<base::android::RegisterCallback
> register_callbacks
;
61 register_callbacks
.push_back(base::Bind(&RegisterJNI
));
62 return content::android::OnJNIOnLoadRegisterJNI(vm
, register_callbacks
);
65 bool OnJNIOnLoadInit() {
66 std::vector
<base::android::InitCallback
> init_callbacks
;
67 init_callbacks
.push_back(base::Bind(&Init
));
68 return content::android::OnJNIOnLoadInit(init_callbacks
);