Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 1728193002: Support dragging texts into Android WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 d70219a71ef275a274ba0f2cb91ad79fe20f34a8..04c30ba44da0d8bdf24b4b3b567bc7e4c0be63cd 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -54,6 +54,8 @@
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/android/view_android.h"
#include "ui/android/window_android.h"
+#include "ui/base/dragdrop/drop_target_event.h"
+#include "ui/base/dragdrop/os_exchange_data_provider_android.h"
#include "ui/events/android/motion_event_android.h"
#include "ui/gfx/android/java_bitmap.h"
#include "ui/gfx/geometry/point_conversions.h"
@@ -1409,6 +1411,72 @@ void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env,
}
}
+void ContentViewCoreImpl::OnDragEntered(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jobj,
+ int x,
+ int y,
+ int screen_x,
+ int screen_y) {
+ WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>(
+ static_cast<WebContentsImpl*>(web_contents())->GetView());
+
+ ui::OSExchangeData data(new ui::OSExchangeDataProviderAndroid());
+ ui::DropTargetEvent event(
+ data, gfx::Point(x, y), gfx::Point(screen_x, screen_y),
+ ui::DragDropTypes::DRAG_COPY); // Android drag and drop does only copy.
+
+ wcva->OnDragEntered(event);
+}
+
+void ContentViewCoreImpl::OnDragUpdated(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jobj,
+ int x,
+ int y,
+ int screen_x,
+ int screen_y) {
+ WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>(
+ static_cast<WebContentsImpl*>(web_contents())->GetView());
+
+ ui::OSExchangeData data(new ui::OSExchangeDataProviderAndroid());
+ ui::DropTargetEvent event(
+ data, gfx::Point(x, y), gfx::Point(screen_x, screen_y),
+ ui::DragDropTypes::DRAG_COPY); // Android drag and drop does only copy.
+
+ wcva->OnDragUpdated(event);
+}
+
+void ContentViewCoreImpl::OnPerformDrop(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jobj,
+ int x,
+ int y,
+ int screen_x,
+ int screen_y,
+ const base::android::JavaParamRef<jstring>& content) {
+ base::string16 text_to_drop = ConvertJavaStringToUTF16(env, content);
+
+ WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>(
+ static_cast<WebContentsImpl*>(web_contents())->GetView());
+
+ ui::OSExchangeData data(new ui::OSExchangeDataProviderAndroid());
+ data.SetString(text_to_drop);
+ ui::DropTargetEvent event(data, gfx::Point(x, y),
+ gfx::Point(screen_x, screen_y),
+ ui::DragDropTypes::DRAG_COPY);
+
+ wcva->OnPerformDrop(event);
+}
+
+void ContentViewCoreImpl::OnDragExited(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jobj) {
+ WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>(
+ static_cast<WebContentsImpl*>(web_contents())->GetView());
+ wcva->OnDragExited();
+}
+
void ContentViewCoreImpl::RequestTextSurroundingSelection(
int max_length,
const base::Callback<

Powered by Google App Engine
This is Rietveld 408576698