| Index: ui/base/clipboard/clipboard_gtk.cc
|
| ===================================================================
|
| --- ui/base/clipboard/clipboard_gtk.cc (revision 183210)
|
| +++ ui/base/clipboard/clipboard_gtk.cc (working copy)
|
| @@ -106,7 +106,6 @@
|
| return GDK_FILTER_CONTINUE;
|
| }
|
|
|
| -const char kSourceTagType[] = "org.chromium.source-tag";
|
| const char kMimeTypeBitmap[] = "image/bmp";
|
| const char kMimeTypeMozillaURL[] = "text/x-moz-url";
|
| const char kMimeTypePepperCustomData[] = "chromium/x-pepper-custom-data";
|
| @@ -153,7 +152,7 @@
|
| // GtkClipboardClearFunc callback.
|
| // We are guaranteed this will be called exactly once for each call to
|
| // gtk_clipboard_set_with_data.
|
| -void ClearData(GtkClipboard* /*clipboard*/,
|
| +void ClearData(GtkClipboard* clipboard,
|
| gpointer user_data) {
|
| Clipboard::TargetMap* map =
|
| reinterpret_cast<Clipboard::TargetMap*>(user_data);
|
| @@ -218,9 +217,7 @@
|
| gtk_clipboard_store(clipboard_);
|
| }
|
|
|
| -void Clipboard::WriteObjectsImpl(Buffer buffer,
|
| - const ObjectMap& objects,
|
| - SourceTag tag) {
|
| +void Clipboard::WriteObjects(Buffer buffer, const ObjectMap& objects) {
|
| DCHECK(CalledOnValidThread());
|
| clipboard_data_ = new TargetMap();
|
|
|
| @@ -228,24 +225,13 @@
|
| iter != objects.end(); ++iter) {
|
| DispatchObject(static_cast<ObjectType>(iter->first), iter->second);
|
| }
|
| - WriteSourceTag(tag);
|
| - SetGtkClipboard(buffer);
|
|
|
| - if (buffer == BUFFER_STANDARD) {
|
| - ObjectMap::const_iterator text_iter = objects.find(CBF_TEXT);
|
| - if (text_iter != objects.end()) {
|
| - // Copy text and SourceTag to the selection clipboard.
|
| - ObjectMap::const_iterator next_iter = text_iter;
|
| - WriteObjectsImpl(BUFFER_SELECTION,
|
| - ObjectMap(text_iter, ++next_iter),
|
| - tag);
|
| - }
|
| - }
|
| + SetGtkClipboard(buffer);
|
| }
|
|
|
| // Take ownership of the GTK clipboard and inform it of the targets we support.
|
| void Clipboard::SetGtkClipboard(Buffer buffer) {
|
| - scoped_array<GtkTargetEntry> targets(
|
| + scoped_ptr<GtkTargetEntry[]> targets(
|
| new GtkTargetEntry[clipboard_data_->size()]);
|
|
|
| int i = 0;
|
| @@ -267,6 +253,14 @@
|
| clipboard_data_->size());
|
| }
|
|
|
| + if (buffer == BUFFER_STANDARD) {
|
| + Clipboard::TargetMap::iterator text_iter = clipboard_data_->find("TEXT");
|
| + if (text_iter != clipboard_data_->end()) {
|
| + gtk_clipboard_set_text(primary_selection_, text_iter->second.first,
|
| + text_iter->second.second);
|
| + }
|
| + }
|
| +
|
| // clipboard_data_ now owned by the GtkClipboard.
|
| clipboard_data_ = NULL;
|
| }
|
| @@ -356,13 +350,6 @@
|
| InsertMapping(GdkAtomToString(format.ToGdkAtom()).c_str(), data, data_len);
|
| }
|
|
|
| -void Clipboard::WriteSourceTag(SourceTag tag) {
|
| - if (tag != SourceTag()) {
|
| - ObjectMapParam binary = SourceTag2Binary(tag);
|
| - WriteData(GetSourceTagFormatType(), &binary[0], binary.size());
|
| - }
|
| -}
|
| -
|
| // We do not use gtk_clipboard_wait_is_target_available because of
|
| // a bug with the gtk clipboard. It caches the available targets
|
| // and does not always refresh the cache when it is appropriate.
|
| @@ -589,17 +576,9 @@
|
| }
|
|
|
| void Clipboard::ReadData(const FormatType& format, std::string* result) const {
|
| - ReadDataImpl(BUFFER_STANDARD, format, result);
|
| -}
|
| -
|
| -void Clipboard::ReadDataImpl(Buffer buffer,
|
| - const FormatType& format,
|
| - std::string* result) const {
|
| DCHECK(CalledOnValidThread());
|
| - result->clear();
|
| - GtkClipboard* clipboard = LookupBackingClipboard(buffer);
|
| GtkSelectionData* data =
|
| - gtk_clipboard_wait_for_contents(clipboard, format.ToGdkAtom());
|
| + gtk_clipboard_wait_for_contents(clipboard_, format.ToGdkAtom());
|
| if (!data)
|
| return;
|
| result->assign(reinterpret_cast<const char*>(
|
| @@ -608,12 +587,6 @@
|
| gtk_selection_data_free(data);
|
| }
|
|
|
| -Clipboard::SourceTag Clipboard::ReadSourceTag(Buffer buffer) const {
|
| - std::string result;
|
| - ReadDataImpl(buffer, GetSourceTagFormatType(), &result);
|
| - return Binary2SourceTag(result);
|
| -}
|
| -
|
| uint64 Clipboard::GetSequenceNumber(Buffer buffer) {
|
| DCHECK(CalledOnValidThread());
|
| if (buffer == BUFFER_STANDARD)
|
| @@ -686,12 +659,6 @@
|
| return type;
|
| }
|
|
|
| -// static
|
| -const Clipboard::FormatType& Clipboard::GetSourceTagFormatType() {
|
| - CR_DEFINE_STATIC_LOCAL(FormatType, type, (kSourceTagType));
|
| - return type;
|
| -}
|
| -
|
| void Clipboard::InsertMapping(const char* key,
|
| char* data,
|
| size_t data_len) {
|
|
|