| 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..82d99b8e22764d407017abaaeac35e0b255f9ac7 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"
|
| @@ -88,6 +90,15 @@ enum PopupItemType {
|
| POPUP_ITEM_TYPE_ENABLED,
|
| };
|
|
|
| +enum DragEventActions {
|
| + ACTION_DRAG_STARTED = 1,
|
| + ACTION_DRAG_LOCATION,
|
| + ACTION_DROP,
|
| + ACTION_DRAG_ENDED,
|
| + ACTION_DRAG_ENTERED,
|
| + ACTION_DRAG_EXITED,
|
| +};
|
| +
|
| const void* const kContentViewUserDataKey = &kContentViewUserDataKey;
|
|
|
| int GetRenderProcessIdFromRenderViewHost(RenderViewHost* host) {
|
| @@ -1409,6 +1420,64 @@ void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env,
|
| }
|
| }
|
|
|
| +void ContentViewCoreImpl::OnDragEvent(
|
| + JNIEnv* env,
|
| + const base::android::JavaParamRef<jobject>& jobj,
|
| + int action,
|
| + const JavaParamRef<jintArray>& j_locations,
|
| + const base::android::JavaParamRef<jstring>& content) {
|
| + WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>(
|
| + static_cast<WebContentsImpl*>(web_contents())->GetView());
|
| +
|
| + std::vector<int> locations;
|
| + base::android::JavaIntArrayToIntVector(env, j_locations, &locations);
|
| + int x = locations[0];
|
| + int y = locations[1];
|
| + int screen_x = locations[2];
|
| + int screen_y = locations[3];
|
| +
|
| + switch (action) {
|
| + case ACTION_DRAG_ENTERED: {
|
| + ui::OSExchangeData data(new ui::OSExchangeDataProviderAndroid());
|
| + // Text being dragged is not available when drag enters. Use an empty
|
| + // string to declare that the DropData contains string. The DropData will
|
| + // be updated with real string being dragged during ACTION_DROP.
|
| + data.SetString(base::string16());
|
| + ui::DropTargetEvent event(data, gfx::Point(x, y),
|
| + gfx::Point(screen_x, screen_y),
|
| + ui::DragDropTypes::DRAG_COPY);
|
| +
|
| + wcva->OnDragEntered(event);
|
| + break;
|
| + }
|
| + case ACTION_DRAG_LOCATION: {
|
| + ui::OSExchangeData data(new ui::OSExchangeDataProviderAndroid());
|
| + ui::DropTargetEvent event(data, gfx::Point(x, y),
|
| + gfx::Point(screen_x, screen_y),
|
| + ui::DragDropTypes::DRAG_COPY);
|
| +
|
| + wcva->OnDragUpdated(event);
|
| + break;
|
| + }
|
| + case ACTION_DROP: {
|
| + base::string16 text_to_drop = ConvertJavaStringToUTF16(env, content);
|
| + 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);
|
| + break;
|
| + }
|
| + case ACTION_DRAG_EXITED:
|
| + wcva->OnDragExited();
|
| + break;
|
| + case ACTION_DRAG_ENDED:
|
| + break;
|
| + }
|
| +}
|
| +
|
| void ContentViewCoreImpl::RequestTextSurroundingSelection(
|
| int max_length,
|
| const base::Callback<
|
|
|