Chromium Code Reviews| 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); |
| } |
| /** |