summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsuzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-26 00:56:43 +0000
committersuzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-26 00:56:43 +0000
commit96d56c6e87c9639b94cf4241e40bf3b22d386eab (patch)
tree660cfdec6354472f774b79c79d64667142da9cb2
parente26f136fdddef35d0928f675dc700d1cb8b7da2e (diff)
downloadchromium_src-96d56c6e87c9639b94cf4241e40bf3b22d386eab.zip
chromium_src-96d56c6e87c9639b94cf4241e40bf3b22d386eab.tar.gz
chromium_src-96d56c6e87c9639b94cf4241e40bf3b22d386eab.tar.bz2
Fix regression issue 20066.
This CL fixes issue 20066, a regression issue caused by a change in CL 172041. BUG=20066: Regression: search keywords search with default search engine only. TEST=Assuming 'y' is associated to a search engine, type "y abc" in omnibox and press enter shall search abc with the search engine associated to 'y'. Review URL: http://codereview.chromium.org/173332 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24388 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index da50dea..0477e04 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -596,13 +596,15 @@ gboolean AutocompleteEditViewGtk::HandleKeyPress(GtkWidget* widget,
event->keyval == GDK_ISO_Enter ||
event->keyval == GDK_KP_Enter);
- std::wstring original_text;
+ gchar* original_text = NULL;
// Enter key will have special behavior if it's not handled by IME.
// We need save the original content of |text_buffer_| and restore it when
// necessary, because GtkTextView might alter the content.
if (enter_pressed) {
- original_text = GetText();
+ GtkTextIter start, end;
+ gtk_text_buffer_get_bounds(text_buffer_, &start, &end);
+ original_text = gtk_text_buffer_get_text(text_buffer_, &start, &end, FALSE);
// Reset |char_inserted_|, which may be set in the "insert-text" signal
// handler, so that we'll know if an Enter key event was handled by IME.
char_inserted_ = 0;
@@ -628,7 +630,13 @@ gboolean AutocompleteEditViewGtk::HandleKeyPress(GtkWidget* widget,
if (enter_pressed && (char_inserted_ == '\n' || char_inserted_ == '\r')) {
bool alt_held = (event->state & GDK_MOD1_MASK);
// Revert the original text in case the text has been changed.
- SetUserText(original_text);
+ // Call gtk_text_buffer_{begin|end}_user_action() to make sure |model_| will
+ // be updated correctly.
+ // Note: SetUserText() does not work here, it'll reset the keyword state.
+ DCHECK(original_text);
+ gtk_text_buffer_begin_user_action(text_buffer_);
+ gtk_text_buffer_set_text(text_buffer_, original_text, -1);
+ gtk_text_buffer_end_user_action(text_buffer_);
model_->AcceptInput(alt_held ? NEW_FOREGROUND_TAB : CURRENT_TAB, false);
result = TRUE;
} else if (!result && event->keyval == GDK_Escape &&
@@ -644,6 +652,9 @@ gboolean AutocompleteEditViewGtk::HandleKeyPress(GtkWidget* widget,
model_->OnControlKeyChanged(true);
}
+ if (original_text)
+ g_free(original_text);
+
// If the key event is not handled by |text_view_| or us, then we need to
// propagate the key event up to parent widgets by returning FALSE.
// In this case we need to stop the signal emission explicitly to prevent the