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

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

Issue 12298037: Revert 183123 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1417/src/
Patch Set: Created 7 years, 10 months 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_android.cc ('k') | ui/base/clipboard/clipboard_chromeos.cc » ('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 21 matching lines...) Expand all
32 namespace { 32 namespace {
33 33
34 const char kChromeSelection[] = "CHROME_SELECTION"; 34 const char kChromeSelection[] = "CHROME_SELECTION";
35 const char kClipboard[] = "CLIPBOARD"; 35 const char kClipboard[] = "CLIPBOARD";
36 const char kMimeTypeBitmap[] = "image/bmp"; 36 const char kMimeTypeBitmap[] = "image/bmp";
37 const char kMimeTypeFilename[] = "chromium/filename"; 37 const char kMimeTypeFilename[] = "chromium/filename";
38 const char kMimeTypeMozillaURL[] = "text/x-moz-url"; 38 const char kMimeTypeMozillaURL[] = "text/x-moz-url";
39 const char kMimeTypePepperCustomData[] = "chromium/x-pepper-custom-data"; 39 const char kMimeTypePepperCustomData[] = "chromium/x-pepper-custom-data";
40 const char kMimeTypeWebkitSmartPaste[] = "chromium/x-webkit-paste"; 40 const char kMimeTypeWebkitSmartPaste[] = "chromium/x-webkit-paste";
41 const char kMultiple[] = "MULTIPLE"; 41 const char kMultiple[] = "MULTIPLE";
42 const char kSourceTagType[] = "org.chromium.source-tag";
43 const char kString[] = "STRING"; 42 const char kString[] = "STRING";
44 const char kTargets[] = "TARGETS"; 43 const char kTargets[] = "TARGETS";
45 const char kText[] = "TEXT"; 44 const char kText[] = "TEXT";
46 const char kUtf8String[] = "UTF8_STRING"; 45 const char kUtf8String[] = "UTF8_STRING";
47 46
48 const char* kAtomsToCache[] = { 47 const char* kAtomsToCache[] = {
49 kChromeSelection, 48 kChromeSelection,
50 kClipboard, 49 kClipboard,
51 kMimeTypeBitmap, 50 kMimeTypeBitmap,
52 kMimeTypeFilename, 51 kMimeTypeFilename,
53 kMimeTypeMozillaURL, 52 kMimeTypeMozillaURL,
54 kMimeTypeWebkitSmartPaste, 53 kMimeTypeWebkitSmartPaste,
55 kMultiple, 54 kMultiple,
56 kSourceTagType,
57 kString, 55 kString,
58 kTargets, 56 kTargets,
59 kText, 57 kText,
60 kUtf8String, 58 kUtf8String,
61 NULL 59 NULL
62 }; 60 };
63 61
64 /////////////////////////////////////////////////////////////////////////////// 62 ///////////////////////////////////////////////////////////////////////////////
65 63
66 // Returns a list of all text atoms that we handle. 64 // Returns a list of all text atoms that we handle.
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 } 878 }
881 879
882 Clipboard::~Clipboard() { 880 Clipboard::~Clipboard() {
883 DCHECK(CalledOnValidThread()); 881 DCHECK(CalledOnValidThread());
884 882
885 // TODO(erg): We need to do whatever the equivalent of 883 // TODO(erg): We need to do whatever the equivalent of
886 // gtk_clipboard_store(clipboard_) is here. When we shut down, we want the 884 // gtk_clipboard_store(clipboard_) is here. When we shut down, we want the
887 // current selection to live on. 885 // current selection to live on.
888 } 886 }
889 887
890 void Clipboard::WriteObjectsImpl(Buffer buffer, 888 void Clipboard::WriteObjects(Buffer buffer, const ObjectMap& objects) {
891 const ObjectMap& objects,
892 SourceTag tag) {
893 DCHECK(CalledOnValidThread()); 889 DCHECK(CalledOnValidThread());
894 DCHECK(IsValidBuffer(buffer)); 890 DCHECK(IsValidBuffer(buffer));
895 891
896 aurax11_details_->CreateNewClipboardData(); 892 aurax11_details_->CreateNewClipboardData();
897 for (ObjectMap::const_iterator iter = objects.begin(); 893 for (ObjectMap::const_iterator iter = objects.begin();
898 iter != objects.end(); ++iter) { 894 iter != objects.end(); ++iter) {
899 DispatchObject(static_cast<ObjectType>(iter->first), iter->second); 895 DispatchObject(static_cast<ObjectType>(iter->first), iter->second);
900 } 896 }
901 WriteSourceTag(tag);
902 aurax11_details_->TakeOwnershipOfSelection(buffer); 897 aurax11_details_->TakeOwnershipOfSelection(buffer);
903 898
904 if (buffer == BUFFER_STANDARD) { 899 if (buffer == BUFFER_STANDARD) {
905 ObjectMap::const_iterator text_iter = objects.find(CBF_TEXT); 900 ObjectMap::const_iterator text_iter = objects.find(CBF_TEXT);
906 if (text_iter != objects.end()) { 901 if (text_iter != objects.end()) {
907 aurax11_details_->CreateNewClipboardData(); 902 aurax11_details_->CreateNewClipboardData();
908 const ObjectMapParam& char_vector = text_iter->second[0]; 903 const ObjectMapParam& char_vector = text_iter->second[0];
909 WriteText(&char_vector.front(), char_vector.size()); 904 WriteText(&char_vector.front(), char_vector.size());
910 WriteSourceTag(tag);
911 aurax11_details_->TakeOwnershipOfSelection(BUFFER_SELECTION); 905 aurax11_details_->TakeOwnershipOfSelection(BUFFER_SELECTION);
912 } 906 }
913 } 907 }
914 } 908 }
915 909
916 bool Clipboard::IsFormatAvailable(const FormatType& format, 910 bool Clipboard::IsFormatAvailable(const FormatType& format,
917 Buffer buffer) const { 911 Buffer buffer) const {
918 DCHECK(CalledOnValidThread()); 912 DCHECK(CalledOnValidThread());
919 DCHECK(IsValidBuffer(buffer)); 913 DCHECK(IsValidBuffer(buffer));
920 914
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 ReadCustomDataForType(data->data(), data->size(), type, result); 1041 ReadCustomDataForType(data->data(), data->size(), type, result);
1048 } 1042 }
1049 1043
1050 void Clipboard::ReadBookmark(string16* title, std::string* url) const { 1044 void Clipboard::ReadBookmark(string16* title, std::string* url) const {
1051 DCHECK(CalledOnValidThread()); 1045 DCHECK(CalledOnValidThread());
1052 // TODO(erg): This was left NOTIMPLEMENTED() in the gtk port too. 1046 // TODO(erg): This was left NOTIMPLEMENTED() in the gtk port too.
1053 NOTIMPLEMENTED(); 1047 NOTIMPLEMENTED();
1054 } 1048 }
1055 1049
1056 void Clipboard::ReadData(const FormatType& format, std::string* result) const { 1050 void Clipboard::ReadData(const FormatType& format, std::string* result) const {
1057 ReadDataImpl(BUFFER_STANDARD, format, result);
1058 }
1059
1060 void Clipboard::ReadDataImpl(Buffer buffer,
1061 const FormatType& format,
1062 std::string* result) const {
1063 DCHECK(CalledOnValidThread()); 1051 DCHECK(CalledOnValidThread());
1064 1052
1065 scoped_ptr<SelectionData> data(aurax11_details_->RequestAndWaitForTypes( 1053 scoped_ptr<SelectionData> data(aurax11_details_->RequestAndWaitForTypes(
1066 buffer, aurax11_details_->GetAtomsForFormat(format))); 1054 BUFFER_STANDARD, aurax11_details_->GetAtomsForFormat(format)));
1067 if (data.get()) 1055 if (data.get())
1068 data->AssignTo(result); 1056 data->AssignTo(result);
1069 } 1057 }
1070 1058
1071 Clipboard::SourceTag Clipboard::ReadSourceTag(Buffer buffer) const {
1072 std::string result;
1073 ReadDataImpl(buffer, GetSourceTagFormatType(), &result);
1074 return Binary2SourceTag(result);
1075 }
1076
1077 uint64 Clipboard::GetSequenceNumber(Buffer buffer) { 1059 uint64 Clipboard::GetSequenceNumber(Buffer buffer) {
1078 DCHECK(CalledOnValidThread()); 1060 DCHECK(CalledOnValidThread());
1079 if (buffer == BUFFER_STANDARD) 1061 if (buffer == BUFFER_STANDARD)
1080 return SelectionChangeObserver::GetInstance()->clipboard_sequence_number(); 1062 return SelectionChangeObserver::GetInstance()->clipboard_sequence_number();
1081 else 1063 else
1082 return SelectionChangeObserver::GetInstance()->primary_sequence_number(); 1064 return SelectionChangeObserver::GetInstance()->primary_sequence_number();
1083 } 1065 }
1084 1066
1085 void Clipboard::WriteText(const char* text_data, size_t text_len) { 1067 void Clipboard::WriteText(const char* text_data, size_t text_len) {
1086 char* data = new char[text_len]; 1068 char* data = new char[text_len];
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 size_t data_len) { 1130 size_t data_len) {
1149 // We assume that certain mapping types are only written by trusted code. 1131 // We assume that certain mapping types are only written by trusted code.
1150 // Therefore we must upkeep their integrity. 1132 // Therefore we must upkeep their integrity.
1151 if (format.Equals(GetBitmapFormatType())) 1133 if (format.Equals(GetBitmapFormatType()))
1152 return; 1134 return;
1153 char* data = new char[data_len]; 1135 char* data = new char[data_len];
1154 memcpy(data, data_data, data_len); 1136 memcpy(data, data_data, data_len);
1155 aurax11_details_->InsertMapping(format.ToString(), data, data_len); 1137 aurax11_details_->InsertMapping(format.ToString(), data, data_len);
1156 } 1138 }
1157 1139
1158 void Clipboard::WriteSourceTag(SourceTag tag) {
1159 if (tag != SourceTag()) {
1160 ObjectMapParam binary = SourceTag2Binary(tag);
1161 WriteData(GetSourceTagFormatType(), &binary[0], binary.size());
1162 }
1163 }
1164
1165 // static 1140 // static
1166 Clipboard::FormatType Clipboard::GetFormatType( 1141 Clipboard::FormatType Clipboard::GetFormatType(
1167 const std::string& format_string) { 1142 const std::string& format_string) {
1168 return FormatType::Deserialize(format_string); 1143 return FormatType::Deserialize(format_string);
1169 } 1144 }
1170 1145
1171 // static 1146 // static
1172 const Clipboard::FormatType& Clipboard::GetUrlFormatType() { 1147 const Clipboard::FormatType& Clipboard::GetUrlFormatType() {
1173 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeURIList)); 1148 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeURIList));
1174 return type; 1149 return type;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData)); 1205 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData));
1231 return type; 1206 return type;
1232 } 1207 }
1233 1208
1234 // static 1209 // static
1235 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { 1210 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
1236 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData)); 1211 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData));
1237 return type; 1212 return type;
1238 } 1213 }
1239 1214
1240 // static
1241 const Clipboard::FormatType& Clipboard::GetSourceTagFormatType() {
1242 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kSourceTagType));
1243 return type;
1244 }
1245
1246 } // namespace ui 1215 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_android.cc ('k') | ui/base/clipboard/clipboard_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698