Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1639)

Side by Side Diff: ui/base/clipboard/clipboard_aurax11.cc

Issue 117983002: Prefix string16 with base:: in ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/clipboard/clipboard_aura.cc ('k') | ui/base/clipboard/clipboard_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <X11/extensions/Xfixes.h> 7 #include <X11/extensions/Xfixes.h>
8 #include <X11/Xatom.h> 8 #include <X11/Xatom.h>
9 #include <list> 9 #include <list>
10 #include <set> 10 #include <set>
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 return target_list.ContainsFormat(format); 561 return target_list.ContainsFormat(format);
562 } 562 }
563 563
564 void Clipboard::Clear(ClipboardType type) { 564 void Clipboard::Clear(ClipboardType type) {
565 DCHECK(CalledOnValidThread()); 565 DCHECK(CalledOnValidThread());
566 DCHECK(IsSupportedClipboardType(type)); 566 DCHECK(IsSupportedClipboardType(type));
567 aurax11_details_->Clear(type); 567 aurax11_details_->Clear(type);
568 } 568 }
569 569
570 void Clipboard::ReadAvailableTypes(ClipboardType type, 570 void Clipboard::ReadAvailableTypes(ClipboardType type,
571 std::vector<string16>* types, 571 std::vector<base::string16>* types,
572 bool* contains_filenames) const { 572 bool* contains_filenames) const {
573 DCHECK(CalledOnValidThread()); 573 DCHECK(CalledOnValidThread());
574 if (!types || !contains_filenames) { 574 if (!types || !contains_filenames) {
575 NOTREACHED(); 575 NOTREACHED();
576 return; 576 return;
577 } 577 }
578 578
579 TargetList target_list = aurax11_details_->WaitAndGetTargetsList(type); 579 TargetList target_list = aurax11_details_->WaitAndGetTargetsList(type);
580 580
581 types->clear(); 581 types->clear();
582 582
583 if (target_list.ContainsText()) 583 if (target_list.ContainsText())
584 types->push_back(UTF8ToUTF16(kMimeTypeText)); 584 types->push_back(UTF8ToUTF16(kMimeTypeText));
585 if (target_list.ContainsFormat(GetHtmlFormatType())) 585 if (target_list.ContainsFormat(GetHtmlFormatType()))
586 types->push_back(UTF8ToUTF16(kMimeTypeHTML)); 586 types->push_back(UTF8ToUTF16(kMimeTypeHTML));
587 if (target_list.ContainsFormat(GetRtfFormatType())) 587 if (target_list.ContainsFormat(GetRtfFormatType()))
588 types->push_back(UTF8ToUTF16(kMimeTypeRTF)); 588 types->push_back(UTF8ToUTF16(kMimeTypeRTF));
589 if (target_list.ContainsFormat(GetBitmapFormatType())) 589 if (target_list.ContainsFormat(GetBitmapFormatType()))
590 types->push_back(UTF8ToUTF16(kMimeTypePNG)); 590 types->push_back(UTF8ToUTF16(kMimeTypePNG));
591 *contains_filenames = false; 591 *contains_filenames = false;
592 592
593 SelectionData data(aurax11_details_->RequestAndWaitForTypes( 593 SelectionData data(aurax11_details_->RequestAndWaitForTypes(
594 type, aurax11_details_->GetAtomsForFormat(GetWebCustomDataFormatType()))); 594 type, aurax11_details_->GetAtomsForFormat(GetWebCustomDataFormatType())));
595 if (data.IsValid()) 595 if (data.IsValid())
596 ReadCustomDataTypes(data.GetData(), data.GetSize(), types); 596 ReadCustomDataTypes(data.GetData(), data.GetSize(), types);
597 } 597 }
598 598
599 void Clipboard::ReadText(ClipboardType type, string16* result) const { 599 void Clipboard::ReadText(ClipboardType type, base::string16* result) const {
600 DCHECK(CalledOnValidThread()); 600 DCHECK(CalledOnValidThread());
601 601
602 SelectionData data(aurax11_details_->RequestAndWaitForTypes( 602 SelectionData data(aurax11_details_->RequestAndWaitForTypes(
603 type, aurax11_details_->GetTextAtoms())); 603 type, aurax11_details_->GetTextAtoms()));
604 if (data.IsValid()) { 604 if (data.IsValid()) {
605 std::string text = data.GetText(); 605 std::string text = data.GetText();
606 *result = UTF8ToUTF16(text); 606 *result = UTF8ToUTF16(text);
607 } 607 }
608 } 608 }
609 609
610 void Clipboard::ReadAsciiText(ClipboardType type, std::string* result) const { 610 void Clipboard::ReadAsciiText(ClipboardType type, std::string* result) const {
611 DCHECK(CalledOnValidThread()); 611 DCHECK(CalledOnValidThread());
612 612
613 SelectionData data(aurax11_details_->RequestAndWaitForTypes( 613 SelectionData data(aurax11_details_->RequestAndWaitForTypes(
614 type, aurax11_details_->GetTextAtoms())); 614 type, aurax11_details_->GetTextAtoms()));
615 if (data.IsValid()) 615 if (data.IsValid())
616 result->assign(data.GetText()); 616 result->assign(data.GetText());
617 } 617 }
618 618
619 // TODO(estade): handle different charsets. 619 // TODO(estade): handle different charsets.
620 // TODO(port): set *src_url. 620 // TODO(port): set *src_url.
621 void Clipboard::ReadHTML(ClipboardType type, 621 void Clipboard::ReadHTML(ClipboardType type,
622 string16* markup, 622 base::string16* markup,
623 std::string* src_url, 623 std::string* src_url,
624 uint32* fragment_start, 624 uint32* fragment_start,
625 uint32* fragment_end) const { 625 uint32* fragment_end) const {
626 DCHECK(CalledOnValidThread()); 626 DCHECK(CalledOnValidThread());
627 markup->clear(); 627 markup->clear();
628 if (src_url) 628 if (src_url)
629 src_url->clear(); 629 src_url->clear();
630 *fragment_start = 0; 630 *fragment_start = 0;
631 *fragment_end = 0; 631 *fragment_end = 0;
632 632
(...skipping 25 matching lines...) Expand all
658 if (data.IsValid()) { 658 if (data.IsValid()) {
659 SkBitmap bitmap; 659 SkBitmap bitmap;
660 if (gfx::PNGCodec::Decode(data.GetData(), data.GetSize(), &bitmap)) 660 if (gfx::PNGCodec::Decode(data.GetData(), data.GetSize(), &bitmap))
661 return SkBitmap(bitmap); 661 return SkBitmap(bitmap);
662 } 662 }
663 663
664 return SkBitmap(); 664 return SkBitmap();
665 } 665 }
666 666
667 void Clipboard::ReadCustomData(ClipboardType clipboard_type, 667 void Clipboard::ReadCustomData(ClipboardType clipboard_type,
668 const string16& type, 668 const base::string16& type,
669 string16* result) const { 669 base::string16* result) const {
670 DCHECK(CalledOnValidThread()); 670 DCHECK(CalledOnValidThread());
671 671
672 SelectionData data(aurax11_details_->RequestAndWaitForTypes( 672 SelectionData data(aurax11_details_->RequestAndWaitForTypes(
673 clipboard_type, 673 clipboard_type,
674 aurax11_details_->GetAtomsForFormat(GetWebCustomDataFormatType()))); 674 aurax11_details_->GetAtomsForFormat(GetWebCustomDataFormatType())));
675 if (data.IsValid()) 675 if (data.IsValid())
676 ReadCustomDataForType(data.GetData(), data.GetSize(), type, result); 676 ReadCustomDataForType(data.GetData(), data.GetSize(), type, result);
677 } 677 }
678 678
679 void Clipboard::ReadBookmark(string16* title, std::string* url) const { 679 void Clipboard::ReadBookmark(base::string16* title, std::string* url) const {
680 DCHECK(CalledOnValidThread()); 680 DCHECK(CalledOnValidThread());
681 // TODO(erg): This was left NOTIMPLEMENTED() in the gtk port too. 681 // TODO(erg): This was left NOTIMPLEMENTED() in the gtk port too.
682 NOTIMPLEMENTED(); 682 NOTIMPLEMENTED();
683 } 683 }
684 684
685 void Clipboard::ReadData(const FormatType& format, std::string* result) const { 685 void Clipboard::ReadData(const FormatType& format, std::string* result) const {
686 DCHECK(CalledOnValidThread()); 686 DCHECK(CalledOnValidThread());
687 687
688 SelectionData data(aurax11_details_->RequestAndWaitForTypes( 688 SelectionData data(aurax11_details_->RequestAndWaitForTypes(
689 CLIPBOARD_TYPE_COPY_PASTE, aurax11_details_->GetAtomsForFormat(format))); 689 CLIPBOARD_TYPE_COPY_PASTE, aurax11_details_->GetAtomsForFormat(format)));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 729
730 void Clipboard::WriteRTF(const char* rtf_data, size_t data_len) { 730 void Clipboard::WriteRTF(const char* rtf_data, size_t data_len) {
731 WriteData(GetRtfFormatType(), rtf_data, data_len); 731 WriteData(GetRtfFormatType(), rtf_data, data_len);
732 } 732 }
733 733
734 void Clipboard::WriteBookmark(const char* title_data, 734 void Clipboard::WriteBookmark(const char* title_data,
735 size_t title_len, 735 size_t title_len,
736 const char* url_data, 736 const char* url_data,
737 size_t url_len) { 737 size_t url_len) {
738 // Write as a mozilla url (UTF16: URL, newline, title). 738 // Write as a mozilla url (UTF16: URL, newline, title).
739 string16 url = UTF8ToUTF16(std::string(url_data, url_len) + "\n"); 739 base::string16 url = UTF8ToUTF16(std::string(url_data, url_len) + "\n");
740 string16 title = UTF8ToUTF16(std::string(title_data, title_len)); 740 base::string16 title = UTF8ToUTF16(std::string(title_data, title_len));
741 741
742 std::vector<unsigned char> data; 742 std::vector<unsigned char> data;
743 ui::AddString16ToVector(url, &data); 743 ui::AddString16ToVector(url, &data);
744 ui::AddString16ToVector(title, &data); 744 ui::AddString16ToVector(title, &data);
745 scoped_refptr<base::RefCountedMemory> mem( 745 scoped_refptr<base::RefCountedMemory> mem(
746 base::RefCountedBytes::TakeVector(&data)); 746 base::RefCountedBytes::TakeVector(&data));
747 747
748 aurax11_details_->InsertMapping(kMimeTypeMozillaURL, mem); 748 aurax11_details_->InsertMapping(kMimeTypeMozillaURL, mem);
749 } 749 }
750 750
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 return type; 848 return type;
849 } 849 }
850 850
851 // static 851 // static
852 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { 852 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
853 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData)); 853 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData));
854 return type; 854 return type;
855 } 855 }
856 856
857 } // namespace ui 857 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_aura.cc ('k') | ui/base/clipboard/clipboard_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698