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

Unified Diff: ui/android/java/src/org/chromium/ui/Clipboard.java

Issue 25668005: Android should be able to copy HTML snippets to the system clipboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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: ui/android/java/src/org/chromium/ui/Clipboard.java
diff --git a/ui/android/java/src/org/chromium/ui/Clipboard.java b/ui/android/java/src/org/chromium/ui/Clipboard.java
index a66fa3d91ddb12ae869325c0b40dda829abafce8..b4e0c21c9a9c03c147e4525ee7ba3e36c33cabf9 100644
--- a/ui/android/java/src/org/chromium/ui/Clipboard.java
+++ b/ui/android/java/src/org/chromium/ui/Clipboard.java
@@ -10,6 +10,7 @@ import org.chromium.base.JNINamespace;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
+import android.os.Build;
import android.text.TextUtils;
/**
@@ -90,6 +91,22 @@ public class Clipboard {
}
/**
+ * Writes HTML to the clipboard, together with a plain-text representation
+ * of that very data. This API is only available in Android JellyBean+ and
+ * will be a no-operation in older versions.
+ *
+ * @param html The HTML content to be pasted to the clipboard.
+ * @param text Plain-text representation of the HTML content.
+ */
+ @CalledByNative
+ private void setHTMLText(final String html, final String text) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ mClipboardManager.setPrimaryClip(
+ ClipData.newHtmlText(null, text, html));
+ }
+ }
+
+ /**
* Approximates the behavior of the now-deprecated
* {@link android.text.ClipboardManager#hasText()}, returning true if and
* only if the clipboard has a primary clip and that clip contains a plain

Powered by Google App Engine
This is Rietveld 408576698