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

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

Issue 59023007: Enable pasting HTML content from the Android clipboard (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't use coerceToHtmlText Created 7 years, 1 month 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
« no previous file with comments | « no previous file | ui/base/clipboard/clipboard_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b4e0c21c9a9c03c147e4525ee7ba3e36c33cabf9..a7a3381706ceb35ca368577a725598197660cc64 100644
--- a/ui/android/java/src/org/chromium/ui/Clipboard.java
+++ b/ui/android/java/src/org/chromium/ui/Clipboard.java
@@ -77,6 +77,23 @@ public class Clipboard {
}
/**
+ * Gets the HTML text of top item on the primary clip on the Android clipboard.
+ *
+ * @return a Java string with the html text if any, or null if there is no html
+ * text or no entries on the primary clip.
+ */
+ @CalledByNative
+ private String getHtmlText() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ final ClipData clip = mClipboardManager.getPrimaryClip();
+ if (clip != null && clip.getItemCount() > 0) {
+ return clip.getItemAt(0).getHtmlText();
joth 2013/11/13 23:11:15 want to comment that coerce would be better (as it
+ }
+ }
+ return null;
+ }
+
+ /**
* Emulates the behavior of the now-deprecated
* {@link android.text.ClipboardManager#setText(CharSequence)}, setting the
* clipboard's current primary clip to a plain-text clip that consists of
@@ -105,24 +122,4 @@ public class Clipboard {
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
- * non-empty text entry (without attempting coercion - URLs and intents
- * will cause this method to return false).
- *
- * @return as described above
- */
- @SuppressWarnings("javadoc")
- @CalledByNative
- private boolean hasPlainText() {
- final ClipData clip = mClipboardManager.getPrimaryClip();
- if (clip != null && clip.getItemCount() > 0) {
- final CharSequence text = clip.getItemAt(0).getText();
- return !TextUtils.isEmpty(text);
- }
- return false;
- }
}
« no previous file with comments | « no previous file | ui/base/clipboard/clipboard_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698