| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 | |
| 5 // This file is autogenerated by | |
| 6 // base/android/jni_generator/jni_generator.py | |
| 7 // For | |
| 8 // org/chromium/TestJni | |
| 9 | |
| 10 #ifndef org_chromium_TestJni_JNI | |
| 11 #define org_chromium_TestJni_JNI | |
| 12 | |
| 13 #include <jni.h> | |
| 14 | |
| 15 #include "base/android/jni_generator/jni_generator_helper.h" | |
| 16 | |
| 17 #include "base/android/jni_int_wrapper.h" | |
| 18 | |
| 19 // Step 1: forward declarations. | |
| 20 namespace { | |
| 21 const char kTestJniClassPath[] = "org/chromium/TestJni"; | |
| 22 // Leaking this jclass as we cannot use LazyInstance from some threads. | |
| 23 jclass g_TestJni_clazz = NULL; | |
| 24 #define TestJni_clazz(env) g_TestJni_clazz | |
| 25 | |
| 26 } // namespace | |
| 27 | |
| 28 static jint Init(JNIEnv* env, jobject jcaller); | |
| 29 | |
| 30 static jstring GetDomainAndRegistry(JNIEnv* env, jclass jcaller, | |
| 31 jstring url); | |
| 32 | |
| 33 static void CreateHistoricalTabFromState(JNIEnv* env, jclass jcaller, | |
| 34 jbyteArray state, | |
| 35 jint tab_index); | |
| 36 | |
| 37 static jbyteArray GetStateAsByteArray(JNIEnv* env, jobject jcaller, | |
| 38 jobject view); | |
| 39 | |
| 40 static jobjectArray GetAutofillProfileGUIDs(JNIEnv* env, jclass jcaller); | |
| 41 | |
| 42 static void SetRecognitionResults(JNIEnv* env, jobject jcaller, | |
| 43 jint sessionId, | |
| 44 jobjectArray results); | |
| 45 | |
| 46 static jint FindAll(JNIEnv* env, jobject jcaller, | |
| 47 jstring find); | |
| 48 | |
| 49 static jobject GetInnerClass(JNIEnv* env, jclass jcaller); | |
| 50 | |
| 51 // Step 2: method stubs. | |
| 52 static void Destroy(JNIEnv* env, jobject jcaller, | |
| 53 jint nativeChromeBrowserProvider) { | |
| 54 ChromeBrowserProvider* native = | |
| 55 reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider); | |
| 56 CHECK_NATIVE_PTR(env, jcaller, native, "Destroy"); | |
| 57 return native->Destroy(env, jcaller); | |
| 58 } | |
| 59 | |
| 60 static jlong AddBookmark(JNIEnv* env, jobject jcaller, | |
| 61 jint nativeChromeBrowserProvider, | |
| 62 jstring url, | |
| 63 jstring title, | |
| 64 jboolean isFolder, | |
| 65 jlong parentId) { | |
| 66 ChromeBrowserProvider* native = | |
| 67 reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider); | |
| 68 CHECK_NATIVE_PTR(env, jcaller, native, "AddBookmark", 0); | |
| 69 return native->AddBookmark(env, jcaller, url, title, isFolder, parentId); | |
| 70 } | |
| 71 | |
| 72 static jlong AddBookmarkFromAPI(JNIEnv* env, jobject jcaller, | |
| 73 jint nativeChromeBrowserProvider, | |
| 74 jstring url, | |
| 75 jobject created, | |
| 76 jobject isBookmark, | |
| 77 jobject date, | |
| 78 jbyteArray favicon, | |
| 79 jstring title, | |
| 80 jobject visits) { | |
| 81 ChromeBrowserProvider* native = | |
| 82 reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider); | |
| 83 CHECK_NATIVE_PTR(env, jcaller, native, "AddBookmarkFromAPI", 0); | |
| 84 return native->AddBookmarkFromAPI(env, jcaller, url, created, isBookmark, | |
| 85 date, favicon, title, visits); | |
| 86 } | |
| 87 | |
| 88 static jobject QueryBitmap(JNIEnv* env, jobject jcaller, | |
| 89 jint nativeChromeBrowserProvider, | |
| 90 jobjectArray projection, | |
| 91 jstring selection, | |
| 92 jobjectArray selectionArgs, | |
| 93 jstring sortOrder) { | |
| 94 ChromeBrowserProvider* native = | |
| 95 reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider); | |
| 96 CHECK_NATIVE_PTR(env, jcaller, native, "QueryBitmap", NULL); | |
| 97 return native->QueryBitmap(env, jcaller, projection, selection, selectionArgs, | |
| 98 sortOrder).Release(); | |
| 99 } | |
| 100 | |
| 101 static void GotOrientation(JNIEnv* env, jobject jcaller, | |
| 102 jint nativeDataFetcherImplAndroid, | |
| 103 jdouble alpha, | |
| 104 jdouble beta, | |
| 105 jdouble gamma) { | |
| 106 DataFetcherImplAndroid* native = | |
| 107 reinterpret_cast<DataFetcherImplAndroid*>(nativeDataFetcherImplAndroid); | |
| 108 CHECK_NATIVE_PTR(env, jcaller, native, "GotOrientation"); | |
| 109 return native->GotOrientation(env, jcaller, alpha, beta, gamma); | |
| 110 } | |
| 111 | |
| 112 // Step 3: RegisterNatives. | |
| 113 | |
| 114 static const JNINativeMethod kMethodsTestJni[] = { | |
| 115 { "nativeInit", | |
| 116 "(" | |
| 117 ")" | |
| 118 "I", reinterpret_cast<void*>(Init) }, | |
| 119 { "nativeDestroy", | |
| 120 "(" | |
| 121 "I" | |
| 122 ")" | |
| 123 "V", reinterpret_cast<void*>(Destroy) }, | |
| 124 { "nativeAddBookmark", | |
| 125 "(" | |
| 126 "I" | |
| 127 "Ljava/lang/String;" | |
| 128 "Ljava/lang/String;" | |
| 129 "Z" | |
| 130 "J" | |
| 131 ")" | |
| 132 "J", reinterpret_cast<void*>(AddBookmark) }, | |
| 133 { "nativeGetDomainAndRegistry", | |
| 134 "(" | |
| 135 "Ljava/lang/String;" | |
| 136 ")" | |
| 137 "Ljava/lang/String;", reinterpret_cast<void*>(GetDomainAndRegistry) }, | |
| 138 { "nativeCreateHistoricalTabFromState", | |
| 139 "(" | |
| 140 "[B" | |
| 141 "I" | |
| 142 ")" | |
| 143 "V", reinterpret_cast<void*>(CreateHistoricalTabFromState) }, | |
| 144 { "nativeGetStateAsByteArray", | |
| 145 "(" | |
| 146 "Landroid/view/View;" | |
| 147 ")" | |
| 148 "[B", reinterpret_cast<void*>(GetStateAsByteArray) }, | |
| 149 { "nativeGetAutofillProfileGUIDs", | |
| 150 "(" | |
| 151 ")" | |
| 152 "[Ljava/lang/String;", reinterpret_cast<void*>(GetAutofillProfileGUIDs) }, | |
| 153 { "nativeSetRecognitionResults", | |
| 154 "(" | |
| 155 "I" | |
| 156 "[Ljava/lang/String;" | |
| 157 ")" | |
| 158 "V", reinterpret_cast<void*>(SetRecognitionResults) }, | |
| 159 { "nativeAddBookmarkFromAPI", | |
| 160 "(" | |
| 161 "I" | |
| 162 "Ljava/lang/String;" | |
| 163 "Ljava/lang/Long;" | |
| 164 "Ljava/lang/Boolean;" | |
| 165 "Ljava/lang/Long;" | |
| 166 "[B" | |
| 167 "Ljava/lang/String;" | |
| 168 "Ljava/lang/Integer;" | |
| 169 ")" | |
| 170 "J", reinterpret_cast<void*>(AddBookmarkFromAPI) }, | |
| 171 { "nativeFindAll", | |
| 172 "(" | |
| 173 "Ljava/lang/String;" | |
| 174 ")" | |
| 175 "I", reinterpret_cast<void*>(FindAll) }, | |
| 176 { "nativeGetInnerClass", | |
| 177 "(" | |
| 178 ")" | |
| 179 "Lorg/chromium/example/jni_generator/SampleForTests$OnFrameAvailableListener;", | |
| 180 reinterpret_cast<void*>(GetInnerClass) }, | |
| 181 { "nativeQueryBitmap", | |
| 182 "(" | |
| 183 "I" | |
| 184 "[Ljava/lang/String;" | |
| 185 "Ljava/lang/String;" | |
| 186 "[Ljava/lang/String;" | |
| 187 "Ljava/lang/String;" | |
| 188 ")" | |
| 189 "Landroid/graphics/Bitmap;", reinterpret_cast<void*>(QueryBitmap) }, | |
| 190 { "nativeGotOrientation", | |
| 191 "(" | |
| 192 "I" | |
| 193 "D" | |
| 194 "D" | |
| 195 "D" | |
| 196 ")" | |
| 197 "V", reinterpret_cast<void*>(GotOrientation) }, | |
| 198 }; | |
| 199 | |
| 200 static bool RegisterNativesImpl(JNIEnv* env) { | |
| 201 | |
| 202 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
| 203 base::android::GetClass(env, kTestJniClassPath).obj())); | |
| 204 | |
| 205 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); | |
| 206 | |
| 207 if (env->RegisterNatives(TestJni_clazz(env), | |
| 208 kMethodsTestJni, | |
| 209 kMethodsTestJniSize) < 0) { | |
| 210 jni_generator::HandleRegistrationError( | |
| 211 env, TestJni_clazz(env), __FILE__); | |
| 212 return false; | |
| 213 } | |
| 214 | |
| 215 return true; | |
| 216 } | |
| 217 | |
| 218 #endif // org_chromium_TestJni_JNI | |
| OLD | NEW |