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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 buffer, | 954 buffer, |
955 aurax11_details_->GetAtomsForFormat(GetWebCustomDataFormatType()))); | 955 aurax11_details_->GetAtomsForFormat(GetWebCustomDataFormatType()))); |
956 if (!data.get()) | 956 if (!data.get()) |
957 return; | 957 return; |
958 | 958 |
959 ReadCustomDataTypes(data->data(), data->size(), types); | 959 ReadCustomDataTypes(data->data(), data->size(), types); |
960 } | 960 } |
961 | 961 |
962 void Clipboard::ReadText(Buffer buffer, string16* result) const { | 962 void Clipboard::ReadText(Buffer buffer, string16* result) const { |
963 DCHECK(CalledOnValidThread()); | 963 DCHECK(CalledOnValidThread()); |
| 964 ReportAction(buffer, READ_TEXT); |
964 | 965 |
965 scoped_ptr<SelectionData> data(aurax11_details_->RequestAndWaitForTypes( | 966 scoped_ptr<SelectionData> data(aurax11_details_->RequestAndWaitForTypes( |
966 buffer, aurax11_details_->GetTextAtoms())); | 967 buffer, aurax11_details_->GetTextAtoms())); |
967 if (data.get()) { | 968 if (data.get()) { |
968 std::string text = data->GetText(); | 969 std::string text = data->GetText(); |
969 *result = UTF8ToUTF16(text); | 970 *result = UTF8ToUTF16(text); |
970 } | 971 } |
971 } | 972 } |
972 | 973 |
973 void Clipboard::ReadAsciiText(Buffer buffer, std::string* result) const { | 974 void Clipboard::ReadAsciiText(Buffer buffer, std::string* result) const { |
974 DCHECK(CalledOnValidThread()); | 975 DCHECK(CalledOnValidThread()); |
| 976 ReportAction(buffer, READ_TEXT); |
975 | 977 |
976 scoped_ptr<SelectionData> data(aurax11_details_->RequestAndWaitForTypes( | 978 scoped_ptr<SelectionData> data(aurax11_details_->RequestAndWaitForTypes( |
977 buffer, aurax11_details_->GetTextAtoms())); | 979 buffer, aurax11_details_->GetTextAtoms())); |
978 if (data.get()) | 980 if (data.get()) |
979 result->assign(data->GetText()); | 981 result->assign(data->GetText()); |
980 } | 982 } |
981 | 983 |
982 // TODO(estade): handle different charsets. | 984 // TODO(estade): handle different charsets. |
983 // TODO(port): set *src_url. | 985 // TODO(port): set *src_url. |
984 void Clipboard::ReadHTML(Buffer buffer, | 986 void Clipboard::ReadHTML(Buffer buffer, |
(...skipping 28 matching lines...) Expand all Loading... |
1013 if (!markup->empty() && markup->at(markup->length() - 1) == '\0') | 1015 if (!markup->empty() && markup->at(markup->length() - 1) == '\0') |
1014 markup->resize(markup->length() - 1); | 1016 markup->resize(markup->length() - 1); |
1015 | 1017 |
1016 *fragment_start = 0; | 1018 *fragment_start = 0; |
1017 DCHECK(markup->length() <= kuint32max); | 1019 DCHECK(markup->length() <= kuint32max); |
1018 *fragment_end = static_cast<uint32>(markup->length()); | 1020 *fragment_end = static_cast<uint32>(markup->length()); |
1019 } | 1021 } |
1020 | 1022 |
1021 void Clipboard::ReadRTF(Buffer buffer, std::string* result) const { | 1023 void Clipboard::ReadRTF(Buffer buffer, std::string* result) const { |
1022 DCHECK(CalledOnValidThread()); | 1024 DCHECK(CalledOnValidThread()); |
| 1025 ReportAction(buffer, READ_TEXT); |
1023 | 1026 |
1024 scoped_ptr<SelectionData> data(aurax11_details_->RequestAndWaitForTypes( | 1027 scoped_ptr<SelectionData> data(aurax11_details_->RequestAndWaitForTypes( |
1025 buffer, aurax11_details_->GetAtomsForFormat(GetRtfFormatType()))); | 1028 buffer, aurax11_details_->GetAtomsForFormat(GetRtfFormatType()))); |
1026 if (data.get()) | 1029 if (data.get()) |
1027 data->AssignTo(result); | 1030 data->AssignTo(result); |
1028 } | 1031 } |
1029 | 1032 |
1030 SkBitmap Clipboard::ReadImage(Buffer buffer) const { | 1033 SkBitmap Clipboard::ReadImage(Buffer buffer) const { |
1031 DCHECK(CalledOnValidThread()); | 1034 DCHECK(CalledOnValidThread()); |
1032 NOTIMPLEMENTED(); | 1035 NOTIMPLEMENTED(); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 return type; | 1240 return type; |
1238 } | 1241 } |
1239 | 1242 |
1240 // static | 1243 // static |
1241 const Clipboard::FormatType& Clipboard::GetSourceTagFormatType() { | 1244 const Clipboard::FormatType& Clipboard::GetSourceTagFormatType() { |
1242 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kSourceTagType)); | 1245 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kSourceTagType)); |
1243 return type; | 1246 return type; |
1244 } | 1247 } |
1245 | 1248 |
1246 } // namespace ui | 1249 } // namespace ui |
OLD | NEW |