| Index: chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
|
| diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
|
| index 0938d83ca739897e1dce075c1417e3bda10ee220..d41d373078c751feedefec3e8bf4f0b49bb8caf1 100644
|
| --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
|
| +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
|
| @@ -210,6 +210,8 @@ void AutocompleteEditViewGtk::Init() {
|
| G_CALLBACK(&HandleDragDataReceivedThunk), this);
|
| g_signal_connect(text_view_, "backspace",
|
| G_CALLBACK(&HandleBackSpaceThunk), this);
|
| + g_signal_connect(text_view_, "copy-clipboard",
|
| + G_CALLBACK(&HandleCopyClipboardThunk), this);
|
|
|
| #if !defined(TOOLKIT_VIEWS)
|
| registrar_.Add(this,
|
| @@ -921,6 +923,31 @@ void AutocompleteEditViewGtk::HandleBackSpace() {
|
| g_signal_stop_emission(text_view_, signal_id, 0);
|
| }
|
|
|
| +void AutocompleteEditViewGtk::HandleCopyClipboard() {
|
| + // On copy, we manually update the PRIMARY selection to contain the
|
| + // highlighted text. This matches Firefox -- we highlight the URL but don't
|
| + // update PRIMARY on Ctrl-L, so Ctrl-L, Ctrl-C and then middle-click is a
|
| + // convenient way to paste the current URL somewhere.
|
| + if (!gtk_text_buffer_get_has_selection(text_buffer_))
|
| + return;
|
| +
|
| + GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
|
| + DCHECK(clipboard);
|
| + if (!clipboard)
|
| + return;
|
| +
|
| + // Passing gtk_text_buffer_copy_clipboard() a text buffer that already owns
|
| + // the clipboard that's being updated clears the highlighted text, which we
|
| + // don't want to do (and it also appears to at least sometimes trigger a
|
| + // failed G_IS_OBJECT() assertion).
|
| + if (gtk_clipboard_get_owner(clipboard) == G_OBJECT(text_buffer_))
|
| + return;
|
| +
|
| + // We can't just call SavePrimarySelection(); that makes the text view lose
|
| + // the selection and unhighlight its text.
|
| + gtk_text_buffer_copy_clipboard(text_buffer_, clipboard);
|
| +}
|
| +
|
| void AutocompleteEditViewGtk::SelectAllInternal(bool reversed,
|
| bool update_primary_selection) {
|
| GtkTextIter start, end;
|
|
|