| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/public/app/content_jni_onload.h" | 5 #include "content/public/app/content_jni_onload.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/android/base_jni_onload.h" | 9 #include "base/android/base_jni_onload.h" |
| 10 #include "base/android/jni_onload_delegate.h" | 10 #include "base/android/jni_onload_delegate.h" |
| 11 #include "base/android/library_loader/library_loader_hooks.h" | 11 #include "base/android/library_loader/library_loader_hooks.h" |
| 12 #include "content/app/android/library_loader_hooks.h" | 12 #include "content/app/android/library_loader_hooks.h" |
| 13 #include "content/public/app/content_main.h" | 13 #include "content/public/app/content_main.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 namespace android { | 16 namespace android { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 class ContentJNIOnLoadDelegate | 20 class ContentJNIOnLoadDelegate |
| 21 : public base::android::JNIOnLoadDelegate { | 21 : public base::android::JNIOnLoadDelegate { |
| 22 public: | 22 public: |
| 23 bool RegisterJNI(JNIEnv* env) override; | 23 bool RegisterJNI(JNIEnv* env) override { |
| 24 bool Init() override; | 24 return content::EnsureJniRegistered(env); |
| 25 } |
| 26 bool Init() override { |
| 27 base::android::SetLibraryLoadedHook(&content::LibraryLoaded); |
| 28 return true; |
| 29 } |
| 25 }; | 30 }; |
| 26 | 31 |
| 27 bool ContentJNIOnLoadDelegate::RegisterJNI(JNIEnv* env) { | |
| 28 return content::EnsureJniRegistered(env); | |
| 29 } | |
| 30 | |
| 31 bool ContentJNIOnLoadDelegate::Init() { | |
| 32 base::android::SetLibraryLoadedHook(&content::LibraryLoaded); | |
| 33 return true; | |
| 34 } | |
| 35 | |
| 36 } // namespace | 32 } // namespace |
| 37 | 33 |
| 38 | 34 |
| 39 bool OnJNIOnLoad(JavaVM* vm, | 35 bool OnJNIOnLoadRegisterJNI( |
| 40 base::android::JNIOnLoadDelegate* delegate) { | 36 JavaVM* vm, |
| 37 base::android::JNIOnLoadDelegate* delegate) { |
| 41 std::vector<base::android::JNIOnLoadDelegate*> delegates; | 38 std::vector<base::android::JNIOnLoadDelegate*> delegates; |
| 42 ContentJNIOnLoadDelegate content_delegate; | 39 ContentJNIOnLoadDelegate content_delegate; |
| 43 delegates.push_back(delegate); | 40 delegates.push_back(delegate); |
| 44 delegates.push_back(&content_delegate); | 41 delegates.push_back(&content_delegate); |
| 45 return base::android::OnJNIOnLoad(vm, &delegates); | 42 return base::android::OnJNIOnLoadRegisterJNI(vm, &delegates); |
| 43 } |
| 44 |
| 45 bool OnJNIOnLoadInit(base::android::JNIOnLoadDelegate* delegate) { |
| 46 std::vector<base::android::JNIOnLoadDelegate*> delegates; |
| 47 ContentJNIOnLoadDelegate content_delegate; |
| 48 delegates.push_back(delegate); |
| 49 delegates.push_back(&content_delegate); |
| 50 return base::android::OnJNIOnLoadInit(&delegates); |
| 46 } | 51 } |
| 47 | 52 |
| 48 } // namespace android | 53 } // namespace android |
| 49 } // namespace content | 54 } // namespace content |
| OLD | NEW |