OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/app/android/chrome_jni_onload.h" | 5 #include "chrome/app/android/chrome_jni_onload.h" |
6 | 6 |
| 7 #include "base/android/jni_android.h" |
7 #include "base/android/library_loader/library_loader_hooks.h" | 8 #include "base/android/library_loader/library_loader_hooks.h" |
8 #include "base/bind.h" | |
9 #include "chrome/app/android/chrome_android_initializer.h" | 9 #include "chrome/app/android/chrome_android_initializer.h" |
10 #include "chrome/browser/android/chrome_jni_registrar.h" | 10 #include "chrome/browser/android/chrome_jni_registrar.h" |
11 #include "content/public/app/content_jni_onload.h" | 11 #include "content/public/app/content_jni_onload.h" |
12 | 12 |
13 namespace android { | 13 namespace android { |
14 | 14 |
15 namespace { | 15 bool OnJNIOnLoadRegisterJNI(JavaVM* vm) { |
| 16 if (!content::android::OnJNIOnLoadRegisterJNI(vm)) |
| 17 return false; |
16 | 18 |
17 bool RegisterJNI(JNIEnv* env) { | 19 JNIEnv* env = base::android::AttachCurrentThread(); |
18 if (base::android::GetLibraryProcessType(env) == | 20 if (base::android::GetLibraryProcessType(env) == |
19 base::android::PROCESS_BROWSER) { | 21 base::android::PROCESS_BROWSER) { |
20 return RegisterBrowserJNI(env); | 22 return RegisterBrowserJNI(env); |
21 } | 23 } |
22 return true; | 24 return true; |
23 } | 25 } |
24 | 26 |
25 bool Init() { | 27 bool OnJNIOnLoadInit() { |
| 28 if (!content::android::OnJNIOnLoadInit()) |
| 29 return false; |
| 30 |
26 return RunChrome(); | 31 return RunChrome(); |
27 } | 32 } |
28 | 33 |
29 } // namespace | |
30 | |
31 bool OnJNIOnLoadRegisterJNI( | |
32 JavaVM* vm, | |
33 base::android::RegisterCallback callback) { | |
34 std::vector<base::android::RegisterCallback> register_callbacks; | |
35 register_callbacks.push_back(callback); | |
36 register_callbacks.push_back(base::Bind(&RegisterJNI)); | |
37 return content::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks); | |
38 } | |
39 | |
40 bool OnJNIOnLoadInit(base::android::InitCallback callback) { | |
41 std::vector<base::android::InitCallback> init_callbacks; | |
42 init_callbacks.push_back(callback); | |
43 init_callbacks.push_back(base::Bind(&Init)); | |
44 return content::android::OnJNIOnLoadInit(init_callbacks); | |
45 } | |
46 | |
47 } // namespace android | 34 } // namespace android |
OLD | NEW |