| 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 <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <X11/extensions/Xfixes.h> | 8 #include <X11/extensions/Xfixes.h> |
| 9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 360 |
| 361 bool retval = false; | 361 bool retval = false; |
| 362 GtkSelectionData* data = gtk_clipboard_wait_for_contents( | 362 GtkSelectionData* data = gtk_clipboard_wait_for_contents( |
| 363 clipboard, gdk_atom_intern_static_string("TARGETS")); | 363 clipboard, gdk_atom_intern_static_string("TARGETS")); |
| 364 | 364 |
| 365 bool format_is_plain_text = GetPlainTextFormatType().Equals(format); | 365 bool format_is_plain_text = GetPlainTextFormatType().Equals(format); |
| 366 if (format_is_plain_text) { | 366 if (format_is_plain_text) { |
| 367 // This tries a number of common text targets. | 367 // This tries a number of common text targets. |
| 368 if (data) { | 368 if (data) { |
| 369 retval = gtk_selection_data_targets_include_text(data); | 369 retval = gtk_selection_data_targets_include_text(data); |
| 370 } else { | 370 } |
| 371 // Some programs like Java decide to set an empty TARGETS list, so even if |
| 372 // data is not NULL, we still have to fall back. |
| 373 if (!retval) { |
| 371 // Some programs post data to the clipboard without any targets. If this | 374 // Some programs post data to the clipboard without any targets. If this |
| 372 // is the case we attempt to make sense of the contents as text. This is | 375 // is the case we attempt to make sense of the contents as text. This is |
| 373 // pretty unfortunate since it means we have to actually copy the data to | 376 // pretty unfortunate since it means we have to actually copy the data to |
| 374 // see if it is available, but at least this path shouldn't be hit for | 377 // see if it is available, but at least this path shouldn't be hit for |
| 375 // conforming programs. | 378 // conforming programs. |
| 376 gchar* text = gtk_clipboard_wait_for_text(clipboard); | 379 gchar* text = gtk_clipboard_wait_for_text(clipboard); |
| 377 if (text) { | 380 if (text) { |
| 378 g_free(text); | 381 g_free(text); |
| 379 retval = true; | 382 retval = true; |
| 380 } | 383 } |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 return clipboard_; | 632 return clipboard_; |
| 630 case BUFFER_SELECTION: | 633 case BUFFER_SELECTION: |
| 631 return primary_selection_; | 634 return primary_selection_; |
| 632 default: | 635 default: |
| 633 NOTREACHED(); | 636 NOTREACHED(); |
| 634 return NULL; | 637 return NULL; |
| 635 } | 638 } |
| 636 } | 639 } |
| 637 | 640 |
| 638 } // namespace ui | 641 } // namespace ui |
| OLD | NEW |