Commit 7f58a960 authored by Yipeng Wang's avatar Yipeng Wang Committed by Commit Bot

Move VR registrations to chrome_jni_onload.cc

The new JNI registration scheme automatically registers most native side
functions. However, some VR functions still require manual registrations.

This CL moves these VR function registrations to chrome_jni_onload.cc
since we plan to delete chrome_jni_registrar.cc afterwards. Also, it
deletes some VR registrations which are already handled by the new scheme.

Bug: 683256
Change-Id: Ifd60ddb0925e96f2eaf2b3c187824f49c33eda4b
Reviewed-on: https://chromium-review.googlesource.com/568584Reviewed-by: default avatarBiao She <bshe@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Yipeng Wang <yipengw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486061}
parent 64ca0b56
......@@ -3,4 +3,8 @@ specific_include_rules = {
"chrome_main_delegate_android.cc": [
"+content/browser/media/android/browser_media_player_manager.h",
],
"chrome_jni_onload.cc": [
"+device/vr/features/features.h",
"+third_party/gvr-android-sdk"
],
}
\ No newline at end of file
......@@ -5,20 +5,38 @@
#include "chrome/app/android/chrome_jni_onload.h"
#include "base/android/jni_android.h"
#include "base/android/library_loader/library_loader_hooks.h"
#include "base/android/jni_registrar.h"
#include "base/android/jni_utils.h"
#include "chrome/app/android/chrome_android_initializer.h"
#include "chrome/browser/android/chrome_jni_registrar.h"
#include "content/public/app/content_jni_onload.h"
#include "device/vr/features/features.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.
static base::android::RegistrationMethod kChromeRegisteredMethods[] = {
#if BUILDFLAG(ENABLE_VR)
{"DisplaySynchronizer",
DisplaySynchronizer::RegisterDisplaySynchronizerNatives},
{"GvrApi", GvrApi::RegisterGvrApiNatives},
{"NativeCallbacks", NativeCallbacks::RegisterNativeCallbacksNatives},
#endif
};
bool OnJNIOnLoadRegisterJNI(JNIEnv* env) {
if (!content::android::OnJNIOnLoadRegisterJNI(env))
return false;
if (base::android::GetLibraryProcessType(env) ==
base::android::PROCESS_BROWSER) {
return RegisterBrowserJNI(env);
// Register manually when on the browser process.
if (!base::android::IsSelectiveJniRegistrationEnabled(env)) {
return RegisterNativeMethods(env, kChromeRegisteredMethods,
arraysize(kChromeRegisteredMethods));
}
return true;
}
......
......@@ -182,22 +182,12 @@
#include "components/spellcheck/spellcheck_build_features.h"
#include "components/sync/android/sync_jni_registrar.h"
#include "components/variations/android/component_jni_registrar.h"
#include "device/vr/features/features.h"
#include "printing/features/features.h"
#if BUILDFLAG(ENABLE_PRINTING) && !BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "printing/printing_context_android.h"
#endif
#if BUILDFLAG(ENABLE_VR)
#include "chrome/browser/android/vr_shell/vr_core_info.h"
#include "chrome/browser/android/vr_shell/vr_shell.h"
#include "chrome/browser/android/vr_shell/vr_shell_delegate.h"
#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
#if BUILDFLAG(ENABLE_OFFLINE_PAGES_HARNESS)
#include "chrome/browser/android/offline_pages/evaluation/offline_page_evaluation_bridge.h"
#endif
......@@ -413,15 +403,6 @@ static base::android::RegistrationMethod kChromeRegisteredMethods[] = {
{"UsbChooserDialogAndroid", UsbChooserDialogAndroid::Register},
{"Variations", variations::android::RegisterVariations},
{"VariationsSession", chrome::android::RegisterVariationsSession},
#if BUILDFLAG(ENABLE_VR)
{"VrCoreInfo", vr_shell::RegisterVrCoreInfo},
{"VrShell", vr_shell::RegisterVrShell},
{"VrShellDelegate", vr_shell::RegisterVrShellDelegate},
{"DisplaySynchronizer",
DisplaySynchronizer::RegisterDisplaySynchronizerNatives},
{"GvrApi", GvrApi::RegisterGvrApiNatives},
{"NativeCallbacks", NativeCallbacks::RegisterNativeCallbacksNatives},
#endif
{"WarmupManager", RegisterWarmupManager},
{"WebApkInstaller", WebApkInstaller::Register},
{"WebApkUpdateManager", WebApkUpdateManager::Register},
......
......@@ -22,10 +22,6 @@ VrCoreInfo::VrCoreInfo(int32_t major_version,
// Native JNI methods
// ----------------------------------------------------------------------------
bool RegisterVrCoreInfo(JNIEnv* env) {
return RegisterNativesImpl(env);
}
jlong Init(JNIEnv* env,
const JavaParamRef<jobject>& obj,
jint major_version,
......
......@@ -31,8 +31,6 @@ struct VrCoreInfo {
VrCoreCompatibility compatibility);
};
bool RegisterVrCoreInfo(JNIEnv* env);
} // namespace vr_shell
#endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CORE_INFO_H_
......@@ -188,10 +188,6 @@ void VrShell::SetUiState() {
}
}
bool RegisterVrShell(JNIEnv* env) {
return RegisterNativesImpl(env);
}
VrShell::~VrShell() {
DVLOG(1) << __FUNCTION__ << "=" << this;
poll_capturing_media_task_.Cancel();
......
......@@ -259,8 +259,6 @@ class VrShell : public device::GvrDelegate,
DISALLOW_COPY_AND_ASSIGN(VrShell);
};
bool RegisterVrShell(JNIEnv* env);
} // namespace vr_shell
#endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
......@@ -245,10 +245,6 @@ void VrShellDelegate::CreateVRDisplayInfo(
// Native JNI methods
// ----------------------------------------------------------------------------
bool RegisterVrShellDelegate(JNIEnv* env) {
return RegisterNativesImpl(env);
}
jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj));
}
......
......@@ -96,8 +96,6 @@ class VrShellDelegate : public device::GvrDelegateProvider {
DISALLOW_COPY_AND_ASSIGN(VrShellDelegate);
};
bool RegisterVrShellDelegate(JNIEnv* env);
} // namespace vr_shell
#endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is autogenerated by
// This file is of the same format as file that generated by
// base/android/jni_generator/jni_generator.py
// For
// com/google/vr/internal/controller/NativeCallbacks
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment