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

Unified Diff: chrome/browser/ui/omnibox/omnibox_edit_model.cc

Issue 11414303: Make Google Search autocomplete provider cursor aware. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years 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/ui/omnibox/omnibox_edit_model.cc
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
index 5a896518b4950c158196721bb311b55483a2f4cf..a5f2443c4959b9cbec50f72b5126e3ba9bdd5423 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -91,6 +91,7 @@ OmniboxEditModel::OmniboxEditModel(OmniboxView* view,
controller_(controller),
has_focus_(false),
user_input_in_progress_(false),
+ cursor_position_(string16::npos),
just_deleted_text_(false),
has_temporary_text_(false),
is_temporary_text_set_by_instant_(false),
@@ -449,13 +450,13 @@ void OmniboxEditModel::StartAutocomplete(
popup_->SetHoveredLine(OmniboxPopupModel::kNoMatch);
// We don't explicitly clear OmniboxPopupModel::manually_selected_match, as
// Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it.
- autocomplete_controller_->Start(
- user_text_, GetDesiredTLD(),
+ autocomplete_controller_->Start(AutocompleteInput(
+ user_text_, cursor_position_, GetDesiredTLD(),
prevent_inline_autocomplete || just_deleted_text_ ||
(has_selected_text && inline_autocomplete_text_.empty()) ||
(paste_state_ != NONE), keyword_is_selected,
keyword_is_selected || allow_exact_keyword_match_,
- AutocompleteInput::ALL_MATCHES);
+ AutocompleteInput::ALL_MATCHES));
}
void OmniboxEditModel::StopAutocomplete() {
@@ -966,6 +967,11 @@ bool OmniboxEditModel::OnAfterPossibleChange(const string16& old_text,
const bool no_selection = selection_start == selection_end;
+ // Update the cursor position based on the current selection. This works fine
+ // even if there is |no_selection|.
+ cursor_position_ = selection_start >= user_text_.length() ? string16::npos
+ : selection_start;
+
// Update the popup for the change, in the process changing to keyword mode
// if the user hit space in mid-string after a keyword.
// |allow_exact_keyword_match_| will be used by StartAutocomplete() method,

Powered by Google App Engine
This is Rietveld 408576698