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/navigation_interception/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"
16 #include "url/url_util.h"
18 namespace android_webview
{
22 static base::android::RegistrationMethod
23 kWebViewDependencyRegisteredMethods
[] = {
24 { "NavigationInterception",
25 navigation_interception::RegisterNavigationInterceptionJni
},
26 { "WebContentsDelegateAndroid",
27 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni
},
30 bool RegisterJNI(JNIEnv
* env
) {
31 // Register JNI for components we depend on.
32 if (!RegisterNativeMethods(
34 kWebViewDependencyRegisteredMethods
,
35 arraysize(kWebViewDependencyRegisteredMethods
)) ||
36 !android_webview::RegisterJni(env
)) {
43 content::SetContentMainDelegate(new android_webview::AwMainDelegate());
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
47 // this). It's safe to call this multiple times.
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
);
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
);