| Index: ui/base/clipboard/clipboard_android.cc
|
| diff --git a/ui/base/clipboard/clipboard_android.cc b/ui/base/clipboard/clipboard_android.cc
|
| index 34d4a83bdaaaac38400bb66ec504c345c8669788..c309bc6d9cc1b1e0a528f18fa0d0ab5914eee458 100644
|
| --- a/ui/base/clipboard/clipboard_android.cc
|
| +++ b/ui/base/clipboard/clipboard_android.cc
|
| @@ -129,39 +129,37 @@ void ClipboardMap::Clear() {
|
|
|
| // If the internal map contains a plain-text entry and it does not match that
|
| // in the Android clipboard, clear the map and insert the Android text into it.
|
| +// If there is an HTML entry in the Android clipboard it gets inserted in the
|
| +// map.
|
| void ClipboardMap::SyncWithAndroidClipboard() {
|
| lock_.AssertAcquired();
|
| JNIEnv* env = AttachCurrentThread();
|
|
|
| + // Update the plain text clipboard entry
|
| std::map<std::string, std::string>::const_iterator it =
|
| map_.find(kPlainTextFormat);
|
| -
|
| - if (!Java_Clipboard_hasPlainText(env, clipboard_manager_.obj())) {
|
| - if (it != map_.end())
|
| - // We have plain text on this side, but Android doesn't. Nuke ours.
|
| - map_.clear();
|
| - return;
|
| - }
|
| -
|
| - ScopedJavaLocalRef<jstring> java_string =
|
| + ScopedJavaLocalRef<jstring> java_string_text =
|
| Java_Clipboard_getCoercedText(env, clipboard_manager_.obj());
|
| -
|
| - if (!java_string.obj()) {
|
| - // Tolerate a null value from the Java side, even though that should not
|
| - // happen since hasPlainText has already returned true.
|
| - // Should only happen if someone is using the clipboard on multiple
|
| - // threads and clears it out after hasPlainText but before we get here...
|
| - if (it != map_.end())
|
| + if (java_string_text.obj()) {
|
| + std::string android_string = ConvertJavaStringToUTF8(java_string_text);
|
| + if (it == map_.end() || it->second != android_string) {
|
| + // There is a different string in the Android clipboard than we have.
|
| + // Clear the map on our side.
|
| + map_.clear();
|
| + map_[kPlainTextFormat] = android_string;
|
| + }
|
| + } else {
|
| + if (it != map_.end()) {
|
| // We have plain text on this side, but Android doesn't. Nuke ours.
|
| map_.clear();
|
| - return;
|
| + }
|
| }
|
|
|
| - // If Android text differs from ours (or we have none), then copy Android's.
|
| - std::string android_string = ConvertJavaStringToUTF8(java_string);
|
| - if (it == map_.end() || it->second != android_string) {
|
| - map_.clear();
|
| - map_[kPlainTextFormat] = android_string;
|
| + // Update the html clipboard entry
|
| + ScopedJavaLocalRef<jstring> java_string_html =
|
| + Java_Clipboard_getHtmlText(env, clipboard_manager_.obj());
|
| + if (java_string_html.obj()) {
|
| + map_[kHTMLFormat] = ConvertJavaStringToUTF8(java_string_html);
|
| }
|
| }
|
|
|
|
|