web_view_compatibility_helper_impl.cc 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2020 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. #if defined(WEBLAYER_MANUAL_JNI_REGISTRATION)
  5. #include "base/android/library_loader/library_loader_hooks.h" // nogncheck
  6. #include "weblayer/browser/java/jni/WebViewCompatibilityHelperImpl_jni.h" // nogncheck
  7. #include "weblayer/browser/java/weblayer_jni_registration.h" // nogncheck
  8. #endif
  9. namespace weblayer {
  10. namespace {
  11. #if defined(WEBLAYER_MANUAL_JNI_REGISTRATION)
  12. void RegisterNonMainDexNativesHook() {
  13. RegisterNonMainDexNatives(base::android::AttachCurrentThread());
  14. }
  15. #endif
  16. } // namespace
  17. bool MaybeRegisterNatives() {
  18. #if defined(WEBLAYER_MANUAL_JNI_REGISTRATION)
  19. JNIEnv* env = base::android::AttachCurrentThread();
  20. if (Java_WebViewCompatibilityHelperImpl_requiresManualJniRegistration(env)) {
  21. if (!RegisterMainDexNatives(env))
  22. return false;
  23. base::android::SetNonMainDexJniRegistrationHook(
  24. RegisterNonMainDexNativesHook);
  25. }
  26. #endif
  27. return true;
  28. }
  29. } // namespace weblayer