| 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" | |
| 11 #include "base/android/library_loader/library_loader_hooks.h" | 10 #include "base/android/library_loader/library_loader_hooks.h" |
| 11 #include "base/bind.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 bool RegisterJNI(JNIEnv* env) { |
| 21 : public base::android::JNIOnLoadDelegate { | |
| 22 public: | |
| 23 bool RegisterJNI(JNIEnv* env) override; | |
| 24 bool Init() override; | |
| 25 }; | |
| 26 | |
| 27 bool ContentJNIOnLoadDelegate::RegisterJNI(JNIEnv* env) { | |
| 28 return content::EnsureJniRegistered(env); | 21 return content::EnsureJniRegistered(env); |
| 29 } | 22 } |
| 30 | 23 |
| 31 bool ContentJNIOnLoadDelegate::Init() { | 24 bool Init() { |
| 32 base::android::SetLibraryLoadedHook(&content::LibraryLoaded); | 25 base::android::SetLibraryLoadedHook(&content::LibraryLoaded); |
| 33 return true; | 26 return true; |
| 34 } | 27 } |
| 35 | 28 |
| 36 } // namespace | 29 } // namespace |
| 37 | 30 |
| 38 | 31 |
| 39 bool OnJNIOnLoad(JavaVM* vm, | 32 bool OnJNIOnLoadRegisterJNI( |
| 40 base::android::JNIOnLoadDelegate* delegate) { | 33 JavaVM* vm, |
| 41 std::vector<base::android::JNIOnLoadDelegate*> delegates; | 34 base::android::RegisterCallback callback) { |
| 42 ContentJNIOnLoadDelegate content_delegate; | 35 std::vector<base::android::RegisterCallback> callbacks; |
| 43 delegates.push_back(delegate); | 36 callbacks.push_back(callback); |
| 44 delegates.push_back(&content_delegate); | 37 callbacks.push_back(base::Bind(&RegisterJNI)); |
| 45 return base::android::OnJNIOnLoad(vm, &delegates); | 38 return base::android::OnJNIOnLoadRegisterJNI(vm, callbacks); |
| 39 } |
| 40 |
| 41 bool OnJNIOnLoadInit(base::android::InitCallback callback) { |
| 42 std::vector<base::android::InitCallback> callbacks; |
| 43 callbacks.push_back(callback); |
| 44 callbacks.push_back(base::Bind(&Init)); |
| 45 return base::android::OnJNIOnLoadInit(callbacks); |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace android | 48 } // namespace android |
| 49 } // namespace content | 49 } // namespace content |
| OLD | NEW |