Index: ui/base/clipboard/clipboard_gtk.cc |
diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc |
index cb61441570909fc4513e77c819d044f38597aaba..857445df83a645542cc0aef0805d2797409be905 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 20:24:50
Please file a bug that this name is temporary and
dcheng
2011/12/05 20:51:04
Done.
|
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); |
tony
2011/12/05 20:24:50
Nit: Should we handle a NULL clipboard case in rel
dcheng
2011/12/05 20:51:04
Done.
|
+ 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) { |