Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2073)

Unified Diff: chrome/browser/autocomplete/autocomplete_edit.cc

Issue 6731036: Enabled pressing TAB to cycle through the Omnibox results. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Enabled pressing TAB to cycle through the Omnibox results, removed moving the caret to the Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/autocomplete_edit.cc
===================================================================
--- chrome/browser/autocomplete/autocomplete_edit.cc (revision 79782)
+++ chrome/browser/autocomplete/autocomplete_edit.cc (working copy)
@@ -77,6 +77,7 @@
paste_state_(NONE),
control_key_state_(UP),
is_keyword_hint_(false),
+ result_frozen_(false),
paste_and_go_transition_(PageTransition::TYPED),
profile_(profile),
update_instant_(true),
@@ -542,13 +543,15 @@
update_instant_ = true;
}
-bool AutocompleteEditModel::AcceptKeyword() {
+bool AutocompleteEditModel::AcceptKeyword(bool update_result) {
DCHECK(is_keyword_hint_ && !keyword_.empty());
view_->OnBeforePossibleChange();
+ result_frozen_ = !update_result;
view_->SetWindowTextAndCaretPos(string16(), 0);
is_keyword_hint_ = false;
view_->OnAfterPossibleChange();
+ result_frozen_ = false;
just_deleted_text_ = false; // OnAfterPossibleChange() erroneously sets this
// since the edit contents have disappeared. It
// doesn't really matter, but we clear it to be
@@ -631,7 +634,7 @@
InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
has_temporary_text_ = false;
if (KeywordIsSelected())
- AcceptKeyword();
+ AcceptKeyword(true);
}
if ((old_state != DOWN_WITH_CHANGE) && popup_->IsOpen()) {
// Autocomplete history provider results may change, so refresh the
@@ -674,6 +677,7 @@
GURL* destination_for_temporary_text_change,
const string16& keyword,
bool is_keyword_hint) {
+
Peter Kasting 2011/04/01 00:09:09 Nit: Don't add a blank line
// Update keyword/hint-related local state.
bool keyword_state_changed = (keyword_ != keyword) ||
((is_keyword_hint_ != is_keyword_hint) && !keyword.empty());
@@ -681,6 +685,21 @@
keyword_ = keyword;
is_keyword_hint_ = is_keyword_hint;
+ // If the current result has a duplicate keyword with a
+ // more relevant result, don't show a hint.
+ if (is_keyword_hint && popup_->selected_line() >= 1) {
+ const AutocompleteResult& result = this->result();
+ const AutocompleteResult::const_iterator match(result.begin() +
+ popup_->selected_line());
+ const AutocompleteResult::const_iterator found =
Peter Kasting 2011/04/01 00:09:09 Nit: It's probably simpler overall to eliminate th
+ std::search(result.begin(), match, match, match + 1,
+ AutocompleteMatch::KeywordsEqual);
+ if (found != match) {
+ is_keyword_hint_ = false;
+ keyword_.clear();
+ }
+ }
+
// |is_keyword_hint_| should always be false if |keyword_| is empty.
DCHECK(!keyword_.empty() || !is_keyword_hint_);
}
@@ -775,7 +794,8 @@
just_deleted_text_ = just_deleted_text;
}
- view_->UpdatePopup();
+ if (!result_frozen_)
+ view_->UpdatePopup();
// Change to keyword mode if the user has typed a keyword name and is now
// pressing space after the name. Accepting the keyword will update our
@@ -952,7 +972,7 @@
(old_user_text.length() + 1 >= new_user_text.length()) &&
!new_user_text.compare(0, new_user_text.length() - 1, old_user_text,
0, new_user_text.length() - 1) &&
- AcceptKeyword();
+ AcceptKeyword(true);
}
// static

Powered by Google App Engine
This is Rietveld 408576698