[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / android_webview / lib / main / webview_entry_point.cc
blob1aa1d27b385fecfe07930bd22548c05b362acac2
1 // Copyright (c) 2012 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/aw_main_delegate.h"
6 #include "android_webview/native/android_webview_jni_registrar.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_registrar.h"
9 #include "base/android/library_loader/library_loader_hooks.h"
10 #include "components/navigation_interception/component_jni_registrar.h"
11 #include "components/web_contents_delegate_android/component_jni_registrar.h"
12 #include "content/public/app/android_library_loader_hooks.h"
13 #include "content/public/app/content_main.h"
14 #include "url/url_util.h"
16 static base::android::RegistrationMethod
17 kWebViewDependencyRegisteredMethods[] = {
18 { "NavigationInterception",
19 navigation_interception::RegisterNavigationInterceptionJni },
20 { "WebContentsDelegateAndroid",
21 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni },
24 // This is called by the VM when the shared library is first loaded.
25 // Most of the initialization is done in LibraryLoadedOnMainThread(), not here.
26 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
28 base::android::SetLibraryLoadedHook(&content::LibraryLoaded);
30 base::android::InitVM(vm);
31 JNIEnv* env = base::android::AttachCurrentThread();
32 if (!base::android::RegisterLibraryLoaderEntryHook(env))
33 return -1;
35 // Register content JNI functions now, rather than waiting until
36 // LibraryLoadedOnMainThread, so that we can call into native code early.
37 if (!content::EnsureJniRegistered(env))
38 return -1;
40 // Register JNI for components we depend on.
41 if (!RegisterNativeMethods(
42 env,
43 kWebViewDependencyRegisteredMethods,
44 arraysize(kWebViewDependencyRegisteredMethods)))
45 return -1;
47 if (!android_webview::RegisterJni(env))
48 return -1;
50 content::SetContentMainDelegate(new android_webview::AwMainDelegate());
52 // Initialize url lib here while we are still single-threaded, in case we use
53 // CookieManager before initializing Chromium (which would normally have done
54 // this). It's safe to call this multiple times.
55 url::Initialize();
57 return JNI_VERSION_1_4;