Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / android_webview / lib / main / webview_jni_onload.cc
blob6b7847fe1befb7351a55b18f9f23d1031c8fce5f
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/common/aw_version_info_values.h"
8 #include "android_webview/lib/main/aw_main_delegate.h"
9 #include "android_webview/native/android_webview_jni_registrar.h"
10 #include "base/android/jni_android.h"
11 #include "base/android/jni_registrar.h"
12 #include "base/android/library_loader/library_loader_hooks.h"
13 #include "base/bind.h"
14 #include "components/external_video_surface/component_jni_registrar.h"
15 #include "components/navigation_interception/component_jni_registrar.h"
16 #include "components/web_contents_delegate_android/component_jni_registrar.h"
17 #include "content/public/app/content_jni_onload.h"
18 #include "content/public/app/content_main.h"
19 #include "url/url_util.h"
21 namespace android_webview {
23 namespace {
25 static base::android::RegistrationMethod
26 kWebViewDependencyRegisteredMethods[] = {
27 #if defined(VIDEO_HOLE)
28 { "ExternalVideoSurfaceContainer",
29 external_video_surface::RegisterExternalVideoSurfaceJni },
30 #endif
31 { "NavigationInterception",
32 navigation_interception::RegisterNavigationInterceptionJni },
33 { "WebContentsDelegateAndroid",
34 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni },
37 bool RegisterJNI(JNIEnv* env) {
38 // Register JNI for components we depend on.
39 if (!RegisterNativeMethods(
40 env,
41 kWebViewDependencyRegisteredMethods,
42 arraysize(kWebViewDependencyRegisteredMethods)) ||
43 !android_webview::RegisterJni(env)) {
44 return false;
46 return true;
49 bool Init() {
50 base::android::SetVersionNumber(PRODUCT_VERSION);
51 content::SetContentMainDelegate(new android_webview::AwMainDelegate());
53 // Initialize url lib here while we are still single-threaded, in case we use
54 // CookieManager before initializing Chromium (which would normally have done
55 // this). It's safe to call this multiple times.
56 url::Initialize();
57 return true;
60 } // namespace
62 bool OnJNIOnLoadRegisterJNI(JavaVM* vm) {
63 std::vector<base::android::RegisterCallback> register_callbacks;
64 register_callbacks.push_back(base::Bind(&RegisterJNI));
65 return content::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks);
68 bool OnJNIOnLoadInit() {
69 std::vector<base::android::InitCallback> init_callbacks;
70 init_callbacks.push_back(base::Bind(&Init));
71 return content::android::OnJNIOnLoadInit(init_callbacks);
74 } // android_webview