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