OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/test/test_clipboard.h" | 5 #include "ui/base/test/test_clipboard.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... | |
35 return store.data.find(format) != store.data.end(); | 35 return store.data.find(format) != store.data.end(); |
36 } | 36 } |
37 | 37 |
38 void TestClipboard::Clear(ClipboardType type) { | 38 void TestClipboard::Clear(ClipboardType type) { |
39 GetStore(type).Clear(); | 39 GetStore(type).Clear(); |
40 } | 40 } |
41 | 41 |
42 void TestClipboard::ReadAvailableTypes(ClipboardType type, | 42 void TestClipboard::ReadAvailableTypes(ClipboardType type, |
43 std::vector<base::string16>* types, | 43 std::vector<base::string16>* types, |
44 bool* contains_filenames) const { | 44 bool* contains_filenames) const { |
45 if (!types || !contains_filenames) { | |
46 return; | |
dcheng
2015/07/15 01:04:46
Why add this check? Both |types| and |contains_fil
Tobias Sargeant
2015/07/15 14:04:00
It was a copy from (for example) clipboard_android
| |
47 } | |
48 | |
49 types->clear(); | |
50 | |
51 if (IsFormatAvailable(Clipboard::GetPlainTextFormatType(), type)) | |
52 types->push_back(base::UTF8ToUTF16(kMimeTypeText)); | |
53 if (IsFormatAvailable(Clipboard::GetHtmlFormatType(), type)) | |
54 types->push_back(base::UTF8ToUTF16(kMimeTypeHTML)); | |
55 | |
56 if (IsFormatAvailable(Clipboard::GetRtfFormatType(), type)) | |
57 types->push_back(base::UTF8ToUTF16(kMimeTypeRTF)); | |
58 if (IsFormatAvailable(Clipboard::GetBitmapFormatType(), type)) | |
59 types->push_back(base::UTF8ToUTF16(kMimeTypePNG)); | |
60 | |
45 *contains_filenames = false; | 61 *contains_filenames = false; |
46 } | 62 } |
47 | 63 |
48 void TestClipboard::ReadText(ClipboardType type, base::string16* result) const { | 64 void TestClipboard::ReadText(ClipboardType type, base::string16* result) const { |
49 std::string result8; | 65 std::string result8; |
50 ReadAsciiText(type, &result8); | 66 ReadAsciiText(type, &result8); |
51 *result = base::UTF8ToUTF16(result8); | 67 *result = base::UTF8ToUTF16(result8); |
52 } | 68 } |
53 | 69 |
54 void TestClipboard::ReadAsciiText(ClipboardType type, | 70 void TestClipboard::ReadAsciiText(ClipboardType type, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 | 211 |
196 const TestClipboard::DataStore& TestClipboard::GetDefaultStore() const { | 212 const TestClipboard::DataStore& TestClipboard::GetDefaultStore() const { |
197 return GetStore(default_store_type_); | 213 return GetStore(default_store_type_); |
198 } | 214 } |
199 | 215 |
200 TestClipboard::DataStore& TestClipboard::GetDefaultStore() { | 216 TestClipboard::DataStore& TestClipboard::GetDefaultStore() { |
201 return GetStore(default_store_type_); | 217 return GetStore(default_store_type_); |
202 } | 218 } |
203 | 219 |
204 } // namespace ui | 220 } // namespace ui |
OLD | NEW |