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 <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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 | 887 |
888 void Clipboard::WriteObjects(Buffer buffer, const ObjectMap& objects) { | 888 void Clipboard::WriteObjects(Buffer buffer, const ObjectMap& objects) { |
889 DCHECK(CalledOnValidThread()); | 889 DCHECK(CalledOnValidThread()); |
890 DCHECK(IsValidBuffer(buffer)); | 890 DCHECK(IsValidBuffer(buffer)); |
891 | 891 |
892 aurax11_details_->CreateNewClipboardData(); | 892 aurax11_details_->CreateNewClipboardData(); |
893 for (ObjectMap::const_iterator iter = objects.begin(); | 893 for (ObjectMap::const_iterator iter = objects.begin(); |
894 iter != objects.end(); ++iter) { | 894 iter != objects.end(); ++iter) { |
895 DispatchObject(static_cast<ObjectType>(iter->first), iter->second); | 895 DispatchObject(static_cast<ObjectType>(iter->first), iter->second); |
896 } | 896 } |
| 897 aurax11_details_->TakeOwnershipOfSelection(buffer); |
897 | 898 |
898 aurax11_details_->TakeOwnershipOfSelection(buffer); | 899 if (buffer == BUFFER_STANDARD) { |
| 900 ObjectMap::const_iterator text_iter = objects.find(CBF_TEXT); |
| 901 if (text_iter != objects.end()) { |
| 902 aurax11_details_->CreateNewClipboardData(); |
| 903 const ObjectMapParam& char_vector = text_iter->second[0]; |
| 904 WriteText(&char_vector.front(), char_vector.size()); |
| 905 aurax11_details_->TakeOwnershipOfSelection(BUFFER_SELECTION); |
| 906 } |
| 907 } |
899 } | 908 } |
900 | 909 |
901 bool Clipboard::IsFormatAvailable(const FormatType& format, | 910 bool Clipboard::IsFormatAvailable(const FormatType& format, |
902 Buffer buffer) const { | 911 Buffer buffer) const { |
903 DCHECK(CalledOnValidThread()); | 912 DCHECK(CalledOnValidThread()); |
904 DCHECK(IsValidBuffer(buffer)); | 913 DCHECK(IsValidBuffer(buffer)); |
905 | 914 |
906 TargetList target_list = aurax11_details_->WaitAndGetTargetsList(buffer); | 915 TargetList target_list = aurax11_details_->WaitAndGetTargetsList(buffer); |
907 return target_list.ContainsFormat(format); | 916 return target_list.ContainsFormat(format); |
908 } | 917 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 | 1049 |
1041 void Clipboard::ReadData(const FormatType& format, std::string* result) const { | 1050 void Clipboard::ReadData(const FormatType& format, std::string* result) const { |
1042 DCHECK(CalledOnValidThread()); | 1051 DCHECK(CalledOnValidThread()); |
1043 | 1052 |
1044 scoped_ptr<SelectionData> data(aurax11_details_->RequestAndWaitForTypes( | 1053 scoped_ptr<SelectionData> data(aurax11_details_->RequestAndWaitForTypes( |
1045 BUFFER_STANDARD, aurax11_details_->GetAtomsForFormat(format))); | 1054 BUFFER_STANDARD, aurax11_details_->GetAtomsForFormat(format))); |
1046 if (data.get()) | 1055 if (data.get()) |
1047 data->AssignTo(result); | 1056 data->AssignTo(result); |
1048 } | 1057 } |
1049 | 1058 |
1050 // When a URL is copied from a render view context menu (via "copy link | |
1051 // location", for example), we additionally stick it in the X clipboard. This | |
1052 // matches other linux browsers. | |
1053 void Clipboard::DidWriteURL(const std::string& utf8_text) { | |
1054 DCHECK(CalledOnValidThread()); | |
1055 | |
1056 aurax11_details_->CreateNewClipboardData(); | |
1057 WriteText(utf8_text.c_str(), utf8_text.size()); | |
1058 aurax11_details_->TakeOwnershipOfSelection(BUFFER_SELECTION); | |
1059 } | |
1060 | |
1061 uint64 Clipboard::GetSequenceNumber(Buffer buffer) { | 1059 uint64 Clipboard::GetSequenceNumber(Buffer buffer) { |
1062 DCHECK(CalledOnValidThread()); | 1060 DCHECK(CalledOnValidThread()); |
1063 if (buffer == BUFFER_STANDARD) | 1061 if (buffer == BUFFER_STANDARD) |
1064 return SelectionChangeObserver::GetInstance()->clipboard_sequence_number(); | 1062 return SelectionChangeObserver::GetInstance()->clipboard_sequence_number(); |
1065 else | 1063 else |
1066 return SelectionChangeObserver::GetInstance()->primary_sequence_number(); | 1064 return SelectionChangeObserver::GetInstance()->primary_sequence_number(); |
1067 } | 1065 } |
1068 | 1066 |
1069 void Clipboard::WriteText(const char* text_data, size_t text_len) { | 1067 void Clipboard::WriteText(const char* text_data, size_t text_len) { |
1070 char* data = new char[text_len]; | 1068 char* data = new char[text_len]; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 return type; | 1206 return type; |
1209 } | 1207 } |
1210 | 1208 |
1211 // static | 1209 // static |
1212 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { | 1210 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { |
1213 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData)); | 1211 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData)); |
1214 return type; | 1212 return type; |
1215 } | 1213 } |
1216 | 1214 |
1217 } // namespace ui | 1215 } // namespace ui |
OLD | NEW |