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.h" | 5 #include "ui/base/clipboard/clipboard.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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 return g_map.Get().HasFormat(format.data()); | 236 return g_map.Get().HasFormat(format.data()); |
237 } | 237 } |
238 | 238 |
239 void Clipboard::Clear(ClipboardType type) { | 239 void Clipboard::Clear(ClipboardType type) { |
240 DCHECK(CalledOnValidThread()); | 240 DCHECK(CalledOnValidThread()); |
241 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 241 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
242 g_map.Get().Clear(); | 242 g_map.Get().Clear(); |
243 } | 243 } |
244 | 244 |
245 void Clipboard::ReadAvailableTypes(ClipboardType type, | 245 void Clipboard::ReadAvailableTypes(ClipboardType type, |
246 std::vector<string16>* types, | 246 std::vector<base::string16>* types, |
247 bool* contains_filenames) const { | 247 bool* contains_filenames) const { |
248 DCHECK(CalledOnValidThread()); | 248 DCHECK(CalledOnValidThread()); |
249 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 249 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
250 | 250 |
251 if (!types || !contains_filenames) { | 251 if (!types || !contains_filenames) { |
252 NOTREACHED(); | 252 NOTREACHED(); |
253 return; | 253 return; |
254 } | 254 } |
255 | 255 |
256 NOTIMPLEMENTED(); | 256 NOTIMPLEMENTED(); |
257 | 257 |
258 types->clear(); | 258 types->clear(); |
259 *contains_filenames = false; | 259 *contains_filenames = false; |
260 } | 260 } |
261 | 261 |
262 void Clipboard::ReadText(ClipboardType type, string16* result) const { | 262 void Clipboard::ReadText(ClipboardType type, base::string16* result) const { |
263 DCHECK(CalledOnValidThread()); | 263 DCHECK(CalledOnValidThread()); |
264 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 264 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
265 std::string utf8; | 265 std::string utf8; |
266 ReadAsciiText(type, &utf8); | 266 ReadAsciiText(type, &utf8); |
267 *result = UTF8ToUTF16(utf8); | 267 *result = UTF8ToUTF16(utf8); |
268 } | 268 } |
269 | 269 |
270 void Clipboard::ReadAsciiText(ClipboardType type, std::string* result) const { | 270 void Clipboard::ReadAsciiText(ClipboardType type, std::string* result) const { |
271 DCHECK(CalledOnValidThread()); | 271 DCHECK(CalledOnValidThread()); |
272 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 272 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
273 *result = g_map.Get().Get(kPlainTextFormat); | 273 *result = g_map.Get().Get(kPlainTextFormat); |
274 } | 274 } |
275 | 275 |
276 // Note: |src_url| isn't really used. It is only implemented in Windows | 276 // Note: |src_url| isn't really used. It is only implemented in Windows |
277 void Clipboard::ReadHTML(ClipboardType type, | 277 void Clipboard::ReadHTML(ClipboardType type, |
278 string16* markup, | 278 base::string16* markup, |
279 std::string* src_url, | 279 std::string* src_url, |
280 uint32* fragment_start, | 280 uint32* fragment_start, |
281 uint32* fragment_end) const { | 281 uint32* fragment_end) const { |
282 DCHECK(CalledOnValidThread()); | 282 DCHECK(CalledOnValidThread()); |
283 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 283 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
284 if (src_url) | 284 if (src_url) |
285 src_url->clear(); | 285 src_url->clear(); |
286 | 286 |
287 std::string input = g_map.Get().Get(kHTMLFormat); | 287 std::string input = g_map.Get().Get(kHTMLFormat); |
288 *markup = UTF8ToUTF16(input); | 288 *markup = UTF8ToUTF16(input); |
(...skipping 21 matching lines...) Expand all Loading... |
310 bmp.allocPixels(); | 310 bmp.allocPixels(); |
311 | 311 |
312 DCHECK_EQ(sizeof(gfx::Size) + bmp.getSize(), input.size()); | 312 DCHECK_EQ(sizeof(gfx::Size) + bmp.getSize(), input.size()); |
313 | 313 |
314 memcpy(bmp.getPixels(), input.data() + sizeof(gfx::Size), bmp.getSize()); | 314 memcpy(bmp.getPixels(), input.data() + sizeof(gfx::Size), bmp.getSize()); |
315 } | 315 } |
316 return bmp; | 316 return bmp; |
317 } | 317 } |
318 | 318 |
319 void Clipboard::ReadCustomData(ClipboardType clipboard_type, | 319 void Clipboard::ReadCustomData(ClipboardType clipboard_type, |
320 const string16& type, | 320 const base::string16& type, |
321 string16* result) const { | 321 base::string16* result) const { |
322 DCHECK(CalledOnValidThread()); | 322 DCHECK(CalledOnValidThread()); |
323 NOTIMPLEMENTED(); | 323 NOTIMPLEMENTED(); |
324 } | 324 } |
325 | 325 |
326 void Clipboard::ReadBookmark(string16* title, std::string* url) const { | 326 void Clipboard::ReadBookmark(base::string16* title, std::string* url) const { |
327 DCHECK(CalledOnValidThread()); | 327 DCHECK(CalledOnValidThread()); |
328 NOTIMPLEMENTED(); | 328 NOTIMPLEMENTED(); |
329 } | 329 } |
330 | 330 |
331 void Clipboard::ReadData(const Clipboard::FormatType& format, | 331 void Clipboard::ReadData(const Clipboard::FormatType& format, |
332 std::string* result) const { | 332 std::string* result) const { |
333 DCHECK(CalledOnValidThread()); | 333 DCHECK(CalledOnValidThread()); |
334 *result = g_map.Get().Get(format.data()); | 334 *result = g_map.Get().Get(format.data()); |
335 } | 335 } |
336 | 336 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 const char* data_data, size_t data_len) { | 434 const char* data_data, size_t data_len) { |
435 g_map.Get().Set(format.data(), std::string(data_data, data_len)); | 435 g_map.Get().Set(format.data(), std::string(data_data, data_len)); |
436 } | 436 } |
437 | 437 |
438 // See clipboard_android_initialization.h for more information. | 438 // See clipboard_android_initialization.h for more information. |
439 bool RegisterClipboardAndroid(JNIEnv* env) { | 439 bool RegisterClipboardAndroid(JNIEnv* env) { |
440 return RegisterNativesImpl(env); | 440 return RegisterNativesImpl(env); |
441 } | 441 } |
442 | 442 |
443 } // namespace ui | 443 } // namespace ui |
OLD | NEW |