| 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..9b6479118c4e59d4300e0aa6805d5e042cdbcfb7 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,8 @@ GdkFilterReturn SelectionChangeObserver::OnXEvent(GdkXEvent* xevent,
|
| const char kMimeTypeBitmap[] = "image/bmp";
|
| const char kMimeTypeMozillaURL[] = "text/x-moz-url";
|
| const char kMimeTypeWebkitSmartPaste[] = "chromium/x-webkit-paste";
|
| +// TODO(dcheng): This name is temporary. See crbug.com/106449
|
| +const char kMimeTypeWebCustomData[] = "chromium/x-web-custom-data";
|
|
|
| std::string GdkAtomToString(const GdkAtom& atom) {
|
| gchar* name = gdk_atom_name(atom);
|
| @@ -390,6 +393,17 @@ void Clipboard::ReadAvailableTypes(Clipboard::Buffer buffer,
|
| if (IsFormatAvailable(GetBitmapFormatType(), buffer))
|
| types->push_back(UTF8ToUTF16(kMimeTypePNG));
|
| *contains_filenames = false;
|
| +
|
| + GtkClipboard* clipboard = LookupBackingClipboard(buffer);
|
| + if (!clipboard)
|
| + return;
|
| +
|
| + 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 +505,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 +563,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) {
|
|
|