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

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

Issue 10824261: Fix handling of inline autocomplete text vis-a-vis Instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bf5901d5c47ac8eb5291de1fbe61987dff7a69fa..82537dbdbe996aa46f2745812114719a1c8cee73 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -649,10 +649,11 @@ bool OmniboxEditModel::AcceptKeyword() {
// Ensure the current selection is saved before showing keyword mode
// so that moving to another line and then reverting the text will restore
// the current state properly.
+ bool save_original_selection = !has_temporary_text_;
+ has_temporary_text_ = true;
view_->OnTemporaryTextMaybeChanged(
DisplayTextFromUserText(CurrentMatch().fill_into_edit),
- !has_temporary_text_);
- has_temporary_text_ = true;
+ save_original_selection);
content::RecordAction(UserMetricsAction("AcceptedKeywordHint"));
return true;
@@ -1120,19 +1121,25 @@ bool OmniboxEditModel::DoInstant(
return false;
if (user_input_in_progress_ && popup_->IsOpen()) {
- string16 text = view_->GetText();
- AutocompleteInput::RemoveForcedQueryStringIfNecessary(
- autocomplete_controller_->input().type(), &text);
-
- // If there's any inline autocompletion, split it out from |text|.
- if (!inline_autocomplete_text_.empty()) {
- DCHECK_GE(text.size(), inline_autocomplete_text_.size());
- text.resize(text.size() - inline_autocomplete_text_.size());
- *suggested_text = inline_autocomplete_text_;
+ // The two pieces of text we want to send Instant, viz., what the user has
+ // typed, and any inline autocomplete suggestion.
+ string16 user_text = user_text_;
+ *suggested_text = inline_autocomplete_text_;
+
+ // If there's temporary text, that overrides the user_text. In this case, we
+ // should ignore any inline_autocomplete_text_, because it won't be visible.
+ if (has_temporary_text_) {
+ user_text = CurrentMatch().fill_into_edit;
+ suggested_text->clear();
}
- return instant->Update(match, text, UseVerbatimInstant(), suggested_text,
- complete_behavior);
+ // Remove any keywords and "?" prefix.
+ user_text = DisplayTextFromUserText(user_text);
+ AutocompleteInput::RemoveForcedQueryStringIfNecessary(
+ autocomplete_controller_->input().type(), &user_text);
+
+ return instant->Update(match, user_text, UseVerbatimInstant(),
+ suggested_text, complete_behavior);
}
// It's possible DoInstant() was called due to an OnChanged() event from the
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698