blob: b85eaa5cf057d09b8fea94c3046d0da4b94a96ae [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/app/android/chrome_jni_onload.h"
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
#include "base/android/jni_utils.h"
#include "base/stl_util.h"
#include "chrome/app/android/chrome_android_initializer.h"
#include "content/public/app/content_jni_onload.h"
#include "device/vr/buildflags/buildflags.h"
#if BUILDFLAG(ENABLE_VR)
#include "third_party/gvr-android-sdk/display_synchronizer_jni.h"
#include "third_party/gvr-android-sdk/gvr_api_jni.h"
#include "third_party/gvr-android-sdk/native_callbacks_jni.h"
#endif
namespace android {
// These VR native functions are not handled by the automatic registration, so
// they are manually registered here.
#if BUILDFLAG(ENABLE_VR)
static const base::android::RegistrationMethod kChromeRegisteredMethods[] = {
{"DisplaySynchronizer",
DisplaySynchronizer::RegisterDisplaySynchronizerNatives},
{"GvrApi", GvrApi::RegisterGvrApiNatives},
{"NativeCallbacks", NativeCallbacks::RegisterNativeCallbacksNatives},
};
#endif
bool OnJNIOnLoadRegisterJNI(JNIEnv* env) {
#if BUILDFLAG(ENABLE_VR)
// Register manually when on the browser process.
if (!base::android::IsSelectiveJniRegistrationEnabled(env)) {
return RegisterNativeMethods(env, kChromeRegisteredMethods,
base::size(kChromeRegisteredMethods));
}
#endif
return true;
}
bool OnJNIOnLoadInit() {
if (!content::android::OnJNIOnLoadInit())
return false;
return RunChrome();
}
} // namespace android