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 297b4e0b76da83806c3f89e76d7bfc79713db71e..c454fdad0681959c38433ae18b8e5da731c27cae 100644 |
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
@@ -95,8 +95,7 @@ OmniboxEditModel::OmniboxEditModel(OmniboxView* view, |
is_keyword_hint_(false), |
profile_(profile), |
in_revert_(false), |
- allow_exact_keyword_match_(false), |
- instant_complete_behavior_(INSTANT_COMPLETE_DELAYED) { |
+ allow_exact_keyword_match_(false) { |
} |
OmniboxEditModel::~OmniboxEditModel() { |
@@ -184,8 +183,7 @@ void OmniboxEditModel::FinalizeInstantQuery(const string16& input_text, |
void OmniboxEditModel::SetSuggestedText(const string16& text, |
InstantCompleteBehavior behavior) { |
- instant_complete_behavior_ = behavior; |
- if (instant_complete_behavior_ == INSTANT_COMPLETE_NOW) { |
+ if (behavior == INSTANT_COMPLETE_NOW) { |
if (!text.empty()) |
FinalizeInstantQuery(view_->GetText(), text, false); |
else |
@@ -211,7 +209,8 @@ bool OmniboxEditModel::CommitSuggestedText(bool skip_inline_autocomplete) { |
bool OmniboxEditModel::AcceptCurrentInstantPreview() { |
InstantController* instant = controller_->GetInstant(); |
- return instant && instant->CommitIfCurrent(); |
+ return instant && instant->IsCurrent() && |
+ instant->CommitCurrentPreview(INSTANT_COMMIT_PRESSED_ENTER); |
} |
void OmniboxEditModel::OnChanged() { |
@@ -241,10 +240,12 @@ void OmniboxEditModel::OnChanged() { |
UMA_HISTOGRAM_ENUMERATION("AutocompleteActionPredictor.Action", |
recommended_action, |
AutocompleteActionPredictor::LAST_PREDICT_ACTION); |
+ |
string16 suggested_text; |
+ InstantCompleteBehavior complete_behavior = INSTANT_COMPLETE_NOW; |
- if (DoInstant(current_match, &suggested_text)) { |
- SetSuggestedText(suggested_text, instant_complete_behavior_); |
+ if (DoInstant(current_match, &suggested_text, &complete_behavior)) { |
+ SetSuggestedText(suggested_text, complete_behavior); |
} else { |
switch (recommended_action) { |
case AutocompleteActionPredictor::ACTION_PRERENDER: |
@@ -440,7 +441,7 @@ void OmniboxEditModel::StopAutocomplete() { |
if (popup_->IsOpen() && !in_revert_) { |
InstantController* instant = controller_->GetInstant(); |
if (instant && !instant->commit_on_pointer_release()) |
- instant->DestroyPreviewContents(); |
+ instant->Hide(); |
} |
autocomplete_controller_->Stop(true); |
@@ -612,7 +613,7 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, |
InstantController* instant = controller_->GetInstant(); |
if (instant && !popup_->IsOpen()) |
- instant->DestroyPreviewContents(); |
+ instant->Hide(); |
in_revert_ = false; |
} |
@@ -682,8 +683,7 @@ void OmniboxEditModel::OnSetFocus(bool control_down) { |
void OmniboxEditModel::OnWillKillFocus(gfx::NativeView view_gaining_focus) { |
SetSuggestedText(string16(), INSTANT_COMPLETE_NOW); |
- InstantController* instant = controller_->GetInstant(); |
- if (instant) |
+ if (InstantController* instant = controller_->GetInstant()) |
instant->OnAutocompleteLostFocus(view_gaining_focus); |
NotifySearchTabHelper(); |
@@ -1086,9 +1086,12 @@ void OmniboxEditModel::NotifySearchTabHelper() { |
} |
} |
-bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match, |
- string16* suggested_text) { |
+bool OmniboxEditModel::DoInstant( |
+ const AutocompleteMatch& match, |
+ string16* suggested_text, |
+ InstantCompleteBehavior* complete_behavior) { |
DCHECK(suggested_text); |
+ DCHECK(complete_behavior); |
if (in_revert_) |
return false; |
@@ -1099,8 +1102,19 @@ bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match, |
return false; |
if (user_input_in_progress_ && popup_->IsOpen()) { |
- return instant->Update(match, view_->GetText(), UseVerbatimInstant(), |
- suggested_text); |
+ 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_; |
+ } |
+ |
+ return instant->Update(match, text, UseVerbatimInstant(), suggested_text, |
+ complete_behavior); |
} |
// It's possible DoInstant() was called due to an OnChanged() event from the |