1 // Copyright 2017 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. 4 5 #include "base/android/jni_android.h" 6 #include "base/android/jni_generator/sample_jni_registration.h" 7 #include "base/android/jni_utils.h" 8 9 // This is called by the VM when the shared library is first loaded. JNI_OnLoad(JavaVM * vm,void * reserved)10JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { 11 // By default, all JNI methods are registered. However, since render processes 12 // don't need very much Java code, we enable selective JNI registration on the 13 // Java side and only register a subset of JNI methods. 14 base::android::InitVM(vm); 15 JNIEnv* env = base::android::AttachCurrentThread(); 16 17 if (!base::android::IsSelectiveJniRegistrationEnabled(env)) { 18 if (!RegisterNonMainDexNatives(env)) { 19 return -1; 20 } 21 } 22 23 if (!RegisterMainDexNatives(env)) { 24 return -1; 25 } 26 return JNI_VERSION_1_4; 27 } 28