| Index: content/browser/android/content_view_core_impl.cc
|
| diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
|
| index 7d636b6f9cd372551f017f41d54572848b612c65..561c2fb041108fd4081f836525303c6e9c18be86 100644
|
| --- a/content/browser/android/content_view_core_impl.cc
|
| +++ b/content/browser/android/content_view_core_impl.cc
|
| @@ -14,6 +14,7 @@
|
| #include "base/logging.h"
|
| #include "base/macros.h"
|
| #include "base/metrics/histogram.h"
|
| +#include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/values.h"
|
| #include "cc/layers/layer.h"
|
| @@ -52,9 +53,11 @@
|
| #include "content/public/common/menu_item.h"
|
| #include "content/public/common/user_agent.h"
|
| #include "jni/ContentViewCore_jni.h"
|
| +#include "jni/DragEvent_jni.h"
|
| #include "third_party/WebKit/public/web/WebInputEvent.h"
|
| #include "ui/android/view_android.h"
|
| #include "ui/android/window_android.h"
|
| +#include "ui/base/clipboard/clipboard.h"
|
| #include "ui/events/android/motion_event_android.h"
|
| #include "ui/events/blink/blink_event_util.h"
|
| #include "ui/events/event_utils.h"
|
| @@ -1473,6 +1476,64 @@ void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env,
|
| }
|
| }
|
|
|
| +void ContentViewCoreImpl::OnDragEvent(
|
| + JNIEnv* env,
|
| + const base::android::JavaParamRef<jobject>& jobj,
|
| + jint action,
|
| + jint x,
|
| + jint y,
|
| + jint screen_x,
|
| + jint screen_y,
|
| + const base::android::JavaParamRef<jobjectArray>& j_mimeTypes,
|
| + const base::android::JavaParamRef<jstring>& j_content) {
|
| + WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>(
|
| + static_cast<WebContentsImpl*>(web_contents())->GetView());
|
| +
|
| + const gfx::Point location(x, y);
|
| + const gfx::Point screen_location(screen_x, screen_y);
|
| +
|
| + std::vector<base::string16> mime_types;
|
| + base::android::AppendJavaStringArrayToStringVector(env, j_mimeTypes,
|
| + &mime_types);
|
| + switch (action) {
|
| + case JNI_DragEvent::ACTION_DRAG_ENTERED: {
|
| + std::vector<DropData::Metadata> metadata;
|
| + for (const base::string16& mime_type : mime_types) {
|
| + metadata.push_back(DropData::Metadata::CreateForMimeType(
|
| + DropData::Kind::STRING, mime_type));
|
| + }
|
| + wcva->OnDragEntered(metadata, location, screen_location);
|
| + break;
|
| + }
|
| + case JNI_DragEvent::ACTION_DRAG_LOCATION: {
|
| + wcva->OnDragUpdated(location, screen_location);
|
| + break;
|
| + }
|
| + case JNI_DragEvent::ACTION_DROP: {
|
| + base::string16 text_to_drop = ConvertJavaStringToUTF16(env, j_content);
|
| + DropData drop_data;
|
| + drop_data.did_originate_from_renderer = false;
|
| + for (const base::string16& mime_type : mime_types) {
|
| + if (base::EqualsASCII(mime_type, ui::Clipboard::kMimeTypeURIList)) {
|
| + drop_data.url = GURL(text_to_drop);
|
| + } else if (base::EqualsASCII(mime_type, ui::Clipboard::kMimeTypeText)) {
|
| + drop_data.text = base::NullableString16(text_to_drop, false);
|
| + } else {
|
| + drop_data.html = base::NullableString16(text_to_drop, false);
|
| + }
|
| + }
|
| +
|
| + wcva->OnPerformDrop(&drop_data, location, screen_location);
|
| + break;
|
| + }
|
| + case JNI_DragEvent::ACTION_DRAG_EXITED:
|
| + wcva->OnDragExited();
|
| + break;
|
| + default: // STARTED and ENDED. Nothing meaningful to do.
|
| + break;
|
| + }
|
| +}
|
| +
|
| void ContentViewCoreImpl::RequestTextSurroundingSelection(
|
| int max_length,
|
| const base::Callback<
|
| @@ -1584,7 +1645,7 @@ static ScopedJavaLocalRef<jobject> FromWebContentsAndroid(
|
| }
|
|
|
| bool RegisterContentViewCore(JNIEnv* env) {
|
| - return RegisterNativesImpl(env);
|
| + return RegisterNativesImpl(env) && JNI_DragEvent::RegisterNativesImpl(env);
|
| }
|
|
|
| } // namespace content
|
|
|