Chromium Code Reviews| Index: ui/base/clipboard/clipboard_gtk.cc |
| diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc |
| index 83f232cc72f74e4fc0f618d3f8b5fedcb09ce6a5..9b5e18cab65afe079395d9e19b67d6c57fcb6683 100644 |
| --- a/ui/base/clipboard/clipboard_gtk.cc |
| +++ b/ui/base/clipboard/clipboard_gtk.cc |
| @@ -17,6 +17,7 @@ |
| #include "base/memory/singleton.h" |
| #include "base/utf_string_conversions.h" |
| #include "third_party/skia/include/core/SkBitmap.h" |
| +#include "ui/base/clipboard/custom_data_helper.h" |
| #include "ui/base/gtk/gtk_signal.h" |
| #include "ui/base/x/x11_util.h" |
| #include "ui/gfx/canvas_skia.h" |
| @@ -106,6 +107,7 @@ GdkFilterReturn SelectionChangeObserver::OnXEvent(GdkXEvent* xevent, |
| const char kMimeTypeBitmap[] = "image/bmp"; |
| const char kMimeTypeMozillaURL[] = "text/x-moz-url"; |
| const char kMimeTypeWebkitSmartPaste[] = "chromium/x-webkit-paste"; |
| +const char kMimeTypeWebCustomData[] = "chromium/x-web-custom-data"; |
|
tony
2011/12/05 18:40:39
We want this data to be interoperable with other b
|
| std::string GdkAtomToString(const GdkAtom& atom) { |
| gchar* name = gdk_atom_name(atom); |
| @@ -390,6 +392,15 @@ void Clipboard::ReadAvailableTypes(Clipboard::Buffer buffer, |
| if (IsFormatAvailable(GetBitmapFormatType(), buffer)) |
| types->push_back(UTF8ToUTF16(kMimeTypePNG)); |
| *contains_filenames = false; |
| + |
| + GtkClipboard* clipboard = LookupBackingClipboard(buffer); |
| + DCHECK(clipboard); |
| + GtkSelectionData* data = gtk_clipboard_wait_for_contents( |
| + clipboard, StringToGdkAtom(GetWebCustomDataFormatType())); |
| + if (!data) |
| + return; |
| + ReadCustomDataTypes(data->data, data->length, types); |
| + gtk_selection_data_free(data); |
| } |
| @@ -491,8 +502,16 @@ SkBitmap Clipboard::ReadImage(Buffer buffer) const { |
| void Clipboard::ReadCustomData(Buffer buffer, |
| const string16& type, |
| string16* result) const { |
| - // TODO(dcheng): Implement this. |
| - NOTIMPLEMENTED(); |
| + GtkClipboard* clipboard = LookupBackingClipboard(buffer); |
| + if (!clipboard) |
| + return; |
| + |
| + GtkSelectionData* data = gtk_clipboard_wait_for_contents( |
| + clipboard, StringToGdkAtom(GetWebCustomDataFormatType())); |
| + if (!data) |
| + return; |
| + ReadCustomDataForType(data->data, data->length, type, result); |
| + gtk_selection_data_free(data); |
| } |
| void Clipboard::ReadBookmark(string16* title, std::string* url) const { |
| @@ -541,6 +560,11 @@ Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() { |
| return std::string(kMimeTypeWebkitSmartPaste); |
| } |
| +// static |
| +Clipboard::FormatType Clipboard::GetWebCustomDataFormatType() { |
| + return std::string(kMimeTypeWebCustomData); |
| +} |
| + |
| void Clipboard::InsertMapping(const char* key, |
| char* data, |
| size_t data_len) { |