summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
diff options
context:
space:
mode:
authorsuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-20 21:18:07 +0000
committersuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-20 21:18:07 +0000
commit96ed237d4c3d8cd9d1a16851b7094b476c6c95e9 (patch)
tree7a5b42328cbd7e1dd3ac986363fa99191ba9b89d /chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
parente9f575064ea212023b82ec27e36905a066cfc76d (diff)
downloadchromium_src-96ed237d4c3d8cd9d1a16851b7094b476c6c95e9.zip
chromium_src-96ed237d4c3d8cd9d1a16851b7094b476c6c95e9.tar.gz
chromium_src-96ed237d4c3d8cd9d1a16851b7094b476c6c95e9.tar.bz2
Accept keyword by pressing space.
This CL disables implicit keyword accepting completely. The user can only accept a keyword by pressing Tab or space explicitly while the keyword hint UI is visible. BUG=60972 TEST=interactive_ui_tests --gtest_filter=AutocompleteEditViewTest.AcceptKeywordBySpace Review URL: http://codereview.chromium.org/6252003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72003 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc32
1 files changed, 13 insertions, 19 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index baebcef..f957137 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -184,7 +184,6 @@ AutocompleteEditViewGtk::AutocompleteEditViewGtk(
tab_was_pressed_(false),
paste_clipboard_requested_(false),
enter_was_inserted_(false),
- enable_tab_to_search_(true),
selection_suggested_(false),
delete_was_pressed_(false),
delete_at_end_pressed_(false),
@@ -650,13 +649,10 @@ void AutocompleteEditViewGtk::OnRevertTemporaryText() {
}
void AutocompleteEditViewGtk::OnBeforePossibleChange() {
- // If this change is caused by a paste clipboard action and all text is
- // selected, then call model_->on_paste_replacing_all() to prevent inline
- // autocomplete.
+ // Record this paste, so we can do different behavior.
if (paste_clipboard_requested_) {
paste_clipboard_requested_ = false;
- if (IsSelectAll())
- model_->on_paste_replacing_all();
+ model_->on_paste();
}
// This method will be called in HandleKeyPress() method just before
@@ -696,8 +692,11 @@ bool AutocompleteEditViewGtk::OnAfterPossibleChange() {
CharRange new_sel = GetSelection();
int length = GetTextLength();
- bool selection_differs = (new_sel.cp_min != sel_before_change_.cp_min) ||
- (new_sel.cp_max != sel_before_change_.cp_max);
+ bool selection_differs =
+ ((new_sel.cp_min != new_sel.cp_max) ||
+ (sel_before_change_.cp_min != sel_before_change_.cp_max)) &&
+ ((new_sel.cp_min != sel_before_change_.cp_min) ||
+ (new_sel.cp_max != sel_before_change_.cp_max));
bool at_end_of_edit = (new_sel.cp_min == length && new_sel.cp_max == length);
// See if the text or selection have changed since OnBeforePossibleChange().
@@ -1626,18 +1625,13 @@ void AutocompleteEditViewGtk::HandleViewMoveFocus(GtkWidget* widget,
bool handled = false;
// Trigger Tab to search behavior only when Tab key is pressed.
- if (model_->is_keyword_hint() && !model_->keyword().empty()) {
- if (enable_tab_to_search_) {
- model_->AcceptKeyword();
- handled = true;
- }
+ if (model_->is_keyword_hint()) {
+ handled = model_->AcceptKeyword();
+ } else if (GTK_WIDGET_VISIBLE(instant_view_)) {
+ controller_->OnCommitSuggestedText(GetText());
+ handled = true;
} else {
- if (GTK_WIDGET_VISIBLE(instant_view_)) {
- controller_->OnCommitSuggestedText(GetText());
- handled = true;
- } else {
- handled = controller_->AcceptCurrentInstantPreview();
- }
+ handled = controller_->AcceptCurrentInstantPreview();
}
if (handled) {