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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 2135493002: Support dragging texts out of webview/Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Support dragging texts out of webview/Chrome. 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/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 52504aa283d14a75704e5c9c9d2069176c81f6b1..5310a0ba553517ee3fe164b3435e9166c27c0b96 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -47,6 +47,7 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
+import android.widget.ImageView;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.CommandLine;
@@ -115,6 +116,9 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
// produce little visible difference.
private static final float ZOOM_CONTROLS_EPSILON = 0.007f;
+ // TODO(hush): use View#DRAG_FLAG_GLOBAL when Chromium starts to build with API 24.
+ private static final int DRAG_FLAG_GLOBAL = 1 << 8;
+
private static final ZoomControlsDelegate NO_OP_ZOOM_CONTROLS_DELEGATE =
new ZoomControlsDelegate() {
@Override
@@ -3330,6 +3334,20 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
return true;
}
+ @CalledByNative
+ private void startDragging(String draggedText, Bitmap dragShadowImage) {
+ ClipData data = ClipData.newPlainText(null, draggedText);
+
+ ImageView imageView = new ImageView(mContext);
+ imageView.setImageBitmap(dragShadowImage);
+ imageView.layout(0, 0, dragShadowImage.getWidth(), dragShadowImage.getHeight());
+
+ // TODO(hush): use View#startDragAndDrop when Chromium starts to build with API 24.
+ mContainerView.startDrag(
+ data, new View.DragShadowBuilder(imageView), null, DRAG_FLAG_GLOBAL);
+ hidePopupsAndPreserveSelection();
+ }
+
/**
* Offer a long press gesture to the embedding View, primarily for WebView compatibility.
*

Powered by Google App Engine
This is Rietveld 408576698