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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 std::vector<base::string16>* types, | 304 std::vector<base::string16>* types, |
305 bool* contains_filenames) const { | 305 bool* contains_filenames) const { |
306 DCHECK(CalledOnValidThread()); | 306 DCHECK(CalledOnValidThread()); |
307 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 307 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
308 | 308 |
309 if (!types || !contains_filenames) { | 309 if (!types || !contains_filenames) { |
310 NOTREACHED(); | 310 NOTREACHED(); |
311 return; | 311 return; |
312 } | 312 } |
313 | 313 |
314 NOTIMPLEMENTED(); | 314 types->clear(); |
315 | 315 |
316 types->clear(); | 316 // would be nice to ask the ClipboardMap to enumerate the types it supports, |
| 317 // rather than hardcode the list here. |
| 318 if (IsFormatAvailable(Clipboard::GetPlainTextFormatType(), type)) |
| 319 types->push_back(base::UTF8ToUTF16(kMimeTypeText)); |
| 320 if (IsFormatAvailable(Clipboard::GetHtmlFormatType(), type)) |
| 321 types->push_back(base::UTF8ToUTF16(kMimeTypeHTML)); |
| 322 |
| 323 // these formats aren't supported by the ClipboardMap currently, but might |
| 324 // be one day? |
| 325 if (IsFormatAvailable(Clipboard::GetRtfFormatType(), type)) |
| 326 types->push_back(base::UTF8ToUTF16(kMimeTypeRTF)); |
| 327 if (IsFormatAvailable(Clipboard::GetBitmapFormatType(), type)) |
| 328 types->push_back(base::UTF8ToUTF16(kMimeTypePNG)); |
317 *contains_filenames = false; | 329 *contains_filenames = false; |
318 } | 330 } |
319 | 331 |
320 void ClipboardAndroid::ReadText(ClipboardType type, | 332 void ClipboardAndroid::ReadText(ClipboardType type, |
321 base::string16* result) const { | 333 base::string16* result) const { |
322 DCHECK(CalledOnValidThread()); | 334 DCHECK(CalledOnValidThread()); |
323 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 335 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
324 std::string utf8; | 336 std::string utf8; |
325 ReadAsciiText(type, &utf8); | 337 ReadAsciiText(type, &utf8); |
326 *result = base::UTF8ToUTF16(utf8); | 338 *result = base::UTF8ToUTF16(utf8); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 const char* data_data, | 466 const char* data_data, |
455 size_t data_len) { | 467 size_t data_len) { |
456 g_map.Get().Set(format.ToString(), std::string(data_data, data_len)); | 468 g_map.Get().Set(format.ToString(), std::string(data_data, data_len)); |
457 } | 469 } |
458 | 470 |
459 bool RegisterClipboardAndroid(JNIEnv* env) { | 471 bool RegisterClipboardAndroid(JNIEnv* env) { |
460 return RegisterNativesImpl(env); | 472 return RegisterNativesImpl(env); |
461 } | 473 } |
462 | 474 |
463 } // namespace ui | 475 } // namespace ui |
OLD | NEW |