This source file includes following definitions.
- Register
- Vibrate
- CancelVibration
- CreateProvider
#include "content/browser/vibration/vibration_provider_android.h"
#include <algorithm>
#include "content/browser/vibration/vibration_message_filter.h"
#include "content/common/view_messages.h"
#include "jni/VibrationProvider_jni.h"
#include "third_party/WebKit/public/platform/WebVibration.h"
using base::android::AttachCurrentThread;
namespace content {
VibrationProviderAndroid::VibrationProviderAndroid() {
}
VibrationProviderAndroid::~VibrationProviderAndroid() {
}
bool VibrationProviderAndroid::Register(JNIEnv* env) {
return RegisterNativesImpl(env);
}
void VibrationProviderAndroid::Vibrate(int64 milliseconds) {
if (j_vibration_provider_.is_null()) {
j_vibration_provider_.Reset(
Java_VibrationProvider_create(
AttachCurrentThread(),
base::android::GetApplicationContext()));
}
Java_VibrationProvider_vibrate(AttachCurrentThread(),
j_vibration_provider_.obj(),
milliseconds);
}
void VibrationProviderAndroid::CancelVibration() {
if (j_vibration_provider_.is_null())
return;
Java_VibrationProvider_cancelVibration(AttachCurrentThread(),
j_vibration_provider_.obj());
}
VibrationProvider* VibrationMessageFilter::CreateProvider() {
return new VibrationProviderAndroid();
}
}