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

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

Issue 73173002: Add ContextMenu support upstream for Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix bug in clipboard 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
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..058053375b2588eaca568f9df850c7993b483e18 100644
--- a/ui/android/java/src/org/chromium/ui/Clipboard.java
+++ b/ui/android/java/src/org/chromium/ui/Clipboard.java
@@ -30,7 +30,7 @@ public class Clipboard {
*
* @param context for accessing the clipboard
*/
- private Clipboard(final Context context) {
+ public Clipboard(final Context context) {
mContext = context;
mClipboardManager = (ClipboardManager)
context.getSystemService(Context.CLIPBOARD_SERVICE);
@@ -82,12 +82,41 @@ public class Clipboard {
* clipboard's current primary clip to a plain-text clip that consists of
* the specified string.
*
+ * @param label will become the label of the clipboard's primary clip
+ * @param text will become the content of the clipboard's primary clip
+ */
+ public void setText(final String label, final String text) {
+ mClipboardManager.setPrimaryClip(ClipData.newPlainText(label, text));
Ted C 2013/11/19 02:44:03 For all these setPrimaryClip calls, it's probably
David Trainor- moved to gerrit 2013/11/25 19:42:50 Done.
+ }
+
+ /**
+ * 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
+ * the specified string.
+ *
* @param text will become the content of the clipboard's primary clip
*/
@SuppressWarnings("javadoc")
@CalledByNative
private void setText(final String text) {
- mClipboardManager.setPrimaryClip(ClipData.newPlainText(null, text));
+ setText(null, text);
+ }
+
+ /**
+ * 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 label The Plain-text label for the HTML content.
+ * @param text Plain-text representation of the HTML content.
+ */
+ public void setHTMLText(final String html, final String label, final String text) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ mClipboardManager.setPrimaryClip(
+ ClipData.newHtmlText(label, text, html));
+ }
}
/**
@@ -100,10 +129,7 @@ public class Clipboard {
*/
@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));
- }
+ setHTMLText(html, null, text);
}
/**
« chrome/browser/ui/android/context_menu_helper.cc ('K') | « chrome/chrome_browser_ui.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698