| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/clipboard/clipboard_android.h" | 5 #include "ui/base/clipboard/clipboard_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void ClipboardMap::CommitToAndroidClipboard() { | 88 void ClipboardMap::CommitToAndroidClipboard() { |
| 89 JNIEnv* env = AttachCurrentThread(); | 89 JNIEnv* env = AttachCurrentThread(); |
| 90 base::AutoLock lock(lock_); | 90 base::AutoLock lock(lock_); |
| 91 if (base::ContainsKey(map_, kHTMLFormat)) { | 91 if (base::ContainsKey(map_, kHTMLFormat)) { |
| 92 // Android's API for storing HTML content on the clipboard requires a plain- | 92 // Android's API for storing HTML content on the clipboard requires a plain- |
| 93 // text representation to be available as well. | 93 // text representation to be available as well. |
| 94 if (!base::ContainsKey(map_, kPlainTextFormat)) | 94 if (!base::ContainsKey(map_, kPlainTextFormat)) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 ScopedJavaLocalRef<jstring> html = | 97 ScopedJavaLocalRef<jstring> html = |
| 98 ConvertUTF8ToJavaString(env, map_[kHTMLFormat].c_str()); | 98 ConvertUTF8ToJavaString(env, map_[kHTMLFormat]); |
| 99 ScopedJavaLocalRef<jstring> text = | 99 ScopedJavaLocalRef<jstring> text = |
| 100 ConvertUTF8ToJavaString(env, map_[kPlainTextFormat].c_str()); | 100 ConvertUTF8ToJavaString(env, map_[kPlainTextFormat]); |
| 101 | 101 |
| 102 DCHECK(html.obj() && text.obj()); | 102 DCHECK(html.obj() && text.obj()); |
| 103 Java_Clipboard_setHTMLText(env, clipboard_manager_, html, text); | 103 Java_Clipboard_setHTMLText(env, clipboard_manager_, html, text); |
| 104 } else if (base::ContainsKey(map_, kPlainTextFormat)) { | 104 } else if (base::ContainsKey(map_, kPlainTextFormat)) { |
| 105 ScopedJavaLocalRef<jstring> str = | 105 ScopedJavaLocalRef<jstring> str = |
| 106 ConvertUTF8ToJavaString(env, map_[kPlainTextFormat].c_str()); | 106 ConvertUTF8ToJavaString(env, map_[kPlainTextFormat]); |
| 107 DCHECK(str.obj()); | 107 DCHECK(str.obj()); |
| 108 Java_Clipboard_setText(env, clipboard_manager_, str); | 108 Java_Clipboard_setText(env, clipboard_manager_, str); |
| 109 } else { | 109 } else { |
| 110 Java_Clipboard_clear(env, clipboard_manager_); | 110 Java_Clipboard_clear(env, clipboard_manager_); |
| 111 NOTIMPLEMENTED(); | 111 NOTIMPLEMENTED(); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 void ClipboardMap::Clear() { | 115 void ClipboardMap::Clear() { |
| 116 JNIEnv* env = AttachCurrentThread(); | 116 JNIEnv* env = AttachCurrentThread(); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 g_map.Get().Set(kBitmapFormat, packed); | 458 g_map.Get().Set(kBitmapFormat, packed); |
| 459 } | 459 } |
| 460 | 460 |
| 461 void ClipboardAndroid::WriteData(const Clipboard::FormatType& format, | 461 void ClipboardAndroid::WriteData(const Clipboard::FormatType& format, |
| 462 const char* data_data, | 462 const char* data_data, |
| 463 size_t data_len) { | 463 size_t data_len) { |
| 464 g_map.Get().Set(format.ToString(), std::string(data_data, data_len)); | 464 g_map.Get().Set(format.ToString(), std::string(data_data, data_len)); |
| 465 } | 465 } |
| 466 | 466 |
| 467 } // namespace ui | 467 } // namespace ui |
| OLD | NEW |