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

Unified Diff: content/browser/web_contents/web_contents_view_android.cc

Issue 2135493002: Support dragging texts out of webview/Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile Created 4 years, 5 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/web_contents/web_contents_view_android.cc
diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc
index f0220cfcd41221a341fd966d2f607bfbbf0a43fe..36ce67bbc77de8acaaf77fe3d59c84b13b20f2e7 100644
--- a/content/browser/web_contents/web_contents_view_android.cc
+++ b/content/browser/web_contents/web_contents_view_android.cc
@@ -4,6 +4,8 @@
#include "content/browser/web_contents/web_contents_view_android.h"
+#include "base/android/jni_android.h"
+#include "base/android/jni_string.h"
#include "base/logging.h"
#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/frame_host/interstitial_page_impl.h"
@@ -14,6 +16,13 @@
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/drop_data.h"
+#include "ui/gfx/android/java_bitmap.h"
+#include "ui/gfx/image/image_skia.h"
+
+using base::android::AttachCurrentThread;
+using base::android::ConvertUTF16ToJavaString;
+using base::android::JavaRef;
+using base::android::ScopedJavaLocalRef;
namespace content {
@@ -199,7 +208,22 @@ void WebContentsViewAndroid::StartDragging(
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const DragEventSourceInfo& event_info) {
- NOTIMPLEMENTED();
+ if (drop_data.text.is_null())
+ return;
+
+ gfx::NativeView native_view = GetNativeView();
+ if (!native_view)
+ return;
+
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jstring> jtext =
+ ConvertUTF16ToJavaString(env, drop_data.text.string());
+
+ native_view->StartDragAndDrop(jtext,
sgurun-gerrit only 2016/07/14 18:13:35 it is better to convert the java type in location
hush (inactive) 2016/07/14 18:37:07 because window_android is in ui and cannot depend
sgurun-gerrit only 2016/07/14 18:43:04 ok in this case, I am fine. Daniel: By convertin
no sievers 2016/07/14 20:31:13 I think we'll probably want to eventually just add
+ gfx::ConvertToJavaBitmap(image.bitmap()));
+
+ if (content_view_core_)
+ content_view_core_->HidePopupsAndPreserveSelection();
}
void WebContentsViewAndroid::UpdateDragCursor(blink::WebDragOperation op) {
@@ -210,14 +234,20 @@ void WebContentsViewAndroid::OnDragEntered(
const std::vector<DropData::Metadata>& metadata,
const gfx::Point& location,
const gfx::Point& screen_location) {
+ blink::WebDragOperationsMask allowed_ops =
+ static_cast<blink::WebDragOperationsMask>(blink::WebDragOperationCopy |
+ blink::WebDragOperationMove);
web_contents_->GetRenderViewHost()->DragTargetDragEnterWithMetaData(
- metadata, location, screen_location, blink::WebDragOperationCopy, 0);
+ metadata, location, screen_location, allowed_ops, 0);
}
void WebContentsViewAndroid::OnDragUpdated(const gfx::Point& location,
const gfx::Point& screen_location) {
+ blink::WebDragOperationsMask allowed_ops =
+ static_cast<blink::WebDragOperationsMask>(blink::WebDragOperationCopy |
+ blink::WebDragOperationMove);
web_contents_->GetRenderViewHost()->DragTargetDragOver(
- location, screen_location, blink::WebDragOperationCopy, 0);
+ location, screen_location, allowed_ops, 0);
}
void WebContentsViewAndroid::OnDragExited() {
@@ -232,6 +262,10 @@ void WebContentsViewAndroid::OnPerformDrop(DropData* drop_data,
screen_location, 0);
}
+void WebContentsViewAndroid::OnDragEnded() {
+ web_contents_->GetRenderViewHost()->DragSourceSystemDragEnded();
+}
+
void WebContentsViewAndroid::GotFocus() {
// This is only used in the views FocusManager stuff but it bleeds through
// all subclasses. http://crbug.com/21875

Powered by Google App Engine
This is Rietveld 408576698