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

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: 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/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 a1c24280c5b732b2a1b95590c535631f9fb6ad3a..a020be2d61a46fb6e6e8b64669c6f82139adc815 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;
@@ -155,6 +156,8 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
* that clients can safely hold to instances of this class.
*/
private static class ContentViewAndroidDelegate implements ViewAndroidDelegate {
+ // TODO(hush): use View#DRAG_FLAG_GLOBAL when Chromium starts to build with API 24.
+ private static final int DRAG_FLAG_GLOBAL = 1 << 8;
/**
* Represents the position of an anchor view.
*/
@@ -297,6 +300,21 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
}
}
}
+
+ public void startDragAndDrop(String text, Bitmap shadowImage) {
+ ClipData data = ClipData.newPlainText(null, text);
+
+ ViewGroup containerView = mCurrentContainerView.get();
+ if (containerView == null) return;
+
+ ImageView imageView = new ImageView(containerView.getContext());
+ imageView.setImageBitmap(shadowImage);
+ imageView.layout(0, 0, shadowImage.getWidth(), shadowImage.getHeight());
+
+ // TODO(hush): use View#startDragAndDrop when Chromium starts to build with API 24.
+ containerView.startDrag(
Theresa 2016/07/13 22:55:42 This method is deprecated in API 24, so there will
hush (inactive) 2016/07/14 18:42:09 Yes, done.
+ data, new View.DragShadowBuilder(imageView), null, DRAG_FLAG_GLOBAL);
+ }
}
/**
@@ -1466,6 +1484,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
hidePopups();
}
+ @CalledByNative
private void hidePopupsAndPreserveSelection() {
mUnselectAllOnActionModeDismiss = false;
hidePopups();

Powered by Google App Engine
This is Rietveld 408576698