Chromium Code Reviews| Index: ui/android/event_forwarder.cc |
| diff --git a/ui/android/event_forwarder.cc b/ui/android/event_forwarder.cc |
| index 911fa406931ffbfe9e7528202a2a03584125c80c..f7a5f0a0a079333ed24f9bd835ea0d17cefbf55b 100644 |
| --- a/ui/android/event_forwarder.cc |
| +++ b/ui/android/event_forwarder.cc |
| @@ -4,17 +4,23 @@ |
| #include "ui/android/event_forwarder.h" |
| +#include "base/android/jni_array.h" |
| +#include "base/android/jni_string.h" |
| #include "base/metrics/histogram_macros.h" |
| #include "jni/EventForwarder_jni.h" |
| #include "ui/android/view_android.h" |
| #include "ui/android/view_client.h" |
| +#include "ui/base/ui_base_switches_util.h" |
| +#include "ui/events/android/drag_event_android.h" |
| #include "ui/events/android/motion_event_android.h" |
| #include "ui/events/base_event_utils.h" |
| namespace ui { |
| +using base::android::AppendJavaStringArrayToStringVector; |
| using base::android::JavaParamRef; |
| using base::android::ScopedJavaLocalRef; |
| +using base::android::ConvertJavaStringToUTF16; |
| EventForwarder::EventForwarder(ViewAndroid* view) : view_(view) {} |
| @@ -28,9 +34,10 @@ EventForwarder::~EventForwarder() { |
| ScopedJavaLocalRef<jobject> EventForwarder::GetJavaObject() { |
| if (java_obj_.is_null()) { |
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| java_obj_.Reset( |
| - Java_EventForwarder_create(base::android::AttachCurrentThread(), |
| - reinterpret_cast<intptr_t>(this))); |
| + Java_EventForwarder_create(env, reinterpret_cast<intptr_t>(this), |
| + switches::IsTouchDragDropEnabled())); |
| } |
| return ScopedJavaLocalRef<jobject>(java_obj_); |
| } |
| @@ -137,6 +144,27 @@ void EventForwarder::OnMouseWheelEvent(JNIEnv* env, |
| view_->OnMouseWheelEvent(event); |
| } |
| +void EventForwarder::OnDragEvent(JNIEnv* env, |
| + const JavaParamRef<jobject>& jobj, |
| + jint action, |
| + jint x, |
| + jint y, |
| + jint screen_x, |
| + jint screen_y, |
| + const JavaParamRef<jobjectArray>& j_mimeTypes, |
| + const JavaParamRef<jstring>& j_content) { |
| + base::string16 drop_content = ConvertJavaStringToUTF16(env, j_content); |
|
boliu
2017/05/24 22:54:02
depending on how big the payload is, that's potent
Jinsuk Kim
2017/05/25 03:18:18
Done.
|
| + float dip_scale = view_->GetDipScale(); |
| + gfx::PointF location(x / dip_scale, y / dip_scale); |
| + gfx::PointF root_location(screen_x / dip_scale, screen_y / dip_scale); |
| + std::vector<base::string16> mime_types; |
| + AppendJavaStringArrayToStringVector(env, j_mimeTypes, &mime_types); |
| + |
| + DragEventAndroid event(action, location, root_location, mime_types, |
| + drop_content); |
| + view_->OnDragEvent(event); |
| +} |
| + |
| bool RegisterEventForwarder(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |