blob: 2d42f277c19cc3d91afe537f38ae2952e1b23e2c [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is autogenerated by
// base/android/jni_generator/jni_generator.py
// For
// org/chromium/TestJni
#ifndef org_chromium_TestJni_JNI
#define org_chromium_TestJni_JNI
#include <jni.h>
#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
#include "base/basictypes.h"
#include "base/logging.h"
using base::android::ScopedJavaLocalRef;
// Step 1: forward declarations.
namespace {
const char kTestJniClassPath[] = "org/chromium/TestJni";
// Leaking this jclass as we cannot use LazyInstance from some threads.
jclass g_TestJni_clazz = NULL;
} // namespace
static jint Init(JNIEnv* env, jobject obj);
static jstring GetDomainAndRegistry(JNIEnv* env, jclass clazz,
jstring url);
static void CreateHistoricalTabFromState(JNIEnv* env, jclass clazz,
jbyteArray state,
jint tab_index);
static jbyteArray GetStateAsByteArray(JNIEnv* env, jobject obj,
jobject view);
static jobjectArray GetAutofillProfileGUIDs(JNIEnv* env, jclass clazz);
static void SetRecognitionResults(JNIEnv* env, jobject obj,
jint sessionId,
jobjectArray results);
static jint FindAll(JNIEnv* env, jobject obj,
jstring find);
static jobject GetInnerClass(JNIEnv* env, jclass clazz);
// Step 2: method stubs.
static void Destroy(JNIEnv* env, jobject obj,
jint nativeChromeBrowserProvider) {
DCHECK(nativeChromeBrowserProvider) << "Destroy";
ChromeBrowserProvider* native =
reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider);
return native->Destroy(env, obj);
}
static jlong AddBookmark(JNIEnv* env, jobject obj,
jint nativeChromeBrowserProvider,
jstring url,
jstring title,
jboolean isFolder,
jlong parentId) {
DCHECK(nativeChromeBrowserProvider) << "AddBookmark";
ChromeBrowserProvider* native =
reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider);
return native->AddBookmark(env, obj, url, title, isFolder, parentId);
}
static jlong AddBookmarkFromAPI(JNIEnv* env, jobject obj,
jint nativeChromeBrowserProvider,
jstring url,
jobject created,
jobject isBookmark,
jobject date,
jbyteArray favicon,
jstring title,
jobject visits) {
DCHECK(nativeChromeBrowserProvider) << "AddBookmarkFromAPI";
ChromeBrowserProvider* native =
reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider);
return native->AddBookmarkFromAPI(env, obj, url, created, isBookmark, date,
favicon, title, visits);
}
static jobject QueryBitmap(JNIEnv* env, jobject obj,
jint nativeChromeBrowserProvider,
jobjectArray projection,
jstring selection,
jobjectArray selectionArgs,
jstring sortOrder) {
DCHECK(nativeChromeBrowserProvider) << "QueryBitmap";
ChromeBrowserProvider* native =
reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider);
return native->QueryBitmap(env, obj, projection, selection, selectionArgs,
sortOrder).Release();
}
static void GotOrientation(JNIEnv* env, jobject obj,
jint nativeDataFetcherImplAndroid,
jdouble alpha,
jdouble beta,
jdouble gamma) {
DCHECK(nativeDataFetcherImplAndroid) << "GotOrientation";
DataFetcherImplAndroid* native =
reinterpret_cast<DataFetcherImplAndroid*>(nativeDataFetcherImplAndroid);
return native->GotOrientation(env, obj, alpha, beta, gamma);
}
// Step 3: RegisterNatives.
static bool RegisterNativesImpl(JNIEnv* env) {
g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
base::android::GetClass(env, kTestJniClassPath).obj()));
static const JNINativeMethod kMethodsTestJni[] = {
{ "nativeInit",
"("
")"
"I", reinterpret_cast<void*>(Init) },
{ "nativeDestroy",
"("
"I"
")"
"V", reinterpret_cast<void*>(Destroy) },
{ "nativeAddBookmark",
"("
"I"
"Ljava/lang/String;"
"Ljava/lang/String;"
"Z"
"J"
")"
"J", reinterpret_cast<void*>(AddBookmark) },
{ "nativeGetDomainAndRegistry",
"("
"Ljava/lang/String;"
")"
"Ljava/lang/String;", reinterpret_cast<void*>(GetDomainAndRegistry) },
{ "nativeCreateHistoricalTabFromState",
"("
"[B"
"I"
")"
"V", reinterpret_cast<void*>(CreateHistoricalTabFromState) },
{ "nativeGetStateAsByteArray",
"("
"Landroid/view/View;"
")"
"[B", reinterpret_cast<void*>(GetStateAsByteArray) },
{ "nativeGetAutofillProfileGUIDs",
"("
")"
"[Ljava/lang/String;", reinterpret_cast<void*>(GetAutofillProfileGUIDs) },
{ "nativeSetRecognitionResults",
"("
"I"
"[Ljava/lang/String;"
")"
"V", reinterpret_cast<void*>(SetRecognitionResults) },
{ "nativeAddBookmarkFromAPI",
"("
"I"
"Ljava/lang/String;"
"Ljava/lang/Long;"
"Ljava/lang/Boolean;"
"Ljava/lang/Long;"
"[B"
"Ljava/lang/String;"
"Ljava/lang/Integer;"
")"
"J", reinterpret_cast<void*>(AddBookmarkFromAPI) },
{ "nativeFindAll",
"("
"Ljava/lang/String;"
")"
"I", reinterpret_cast<void*>(FindAll) },
{ "nativeGetInnerClass",
"("
")"
"Lorg/chromium/example/jni_generator/SampleForTests$OnFrameAvailableListener;",
reinterpret_cast<void*>(GetInnerClass) },
{ "nativeQueryBitmap",
"("
"I"
"[Ljava/lang/String;"
"Ljava/lang/String;"
"[Ljava/lang/String;"
"Ljava/lang/String;"
")"
"Landroid/graphics/Bitmap;", reinterpret_cast<void*>(QueryBitmap) },
{ "nativeGotOrientation",
"("
"I"
"D"
"D"
"D"
")"
"V", reinterpret_cast<void*>(GotOrientation) },
};
const int kMethodsTestJniSize = arraysize(kMethodsTestJni);
if (env->RegisterNatives(g_TestJni_clazz,
kMethodsTestJni,
kMethodsTestJniSize) < 0) {
LOG(ERROR) << "RegisterNatives failed in " << __FILE__;
return false;
}
return true;
}
#endif // org_chromium_TestJni_JNI