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..1c2d374422a8c750ec80ce6caa44d4fc58057136 100644 |
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
@@ -185,7 +185,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 +211,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 +242,12 @@ void OmniboxEditModel::OnChanged() { |
UMA_HISTOGRAM_ENUMERATION("AutocompleteActionPredictor.Action", |
recommended_action, |
AutocompleteActionPredictor::LAST_PREDICT_ACTION); |
- string16 suggested_text; |
- if (DoInstant(current_match, &suggested_text)) { |
- SetSuggestedText(suggested_text, instant_complete_behavior_); |
+ string16 suggested_text = inline_autocomplete_text_; |
+ InstantCompleteBehavior complete_behavior = INSTANT_COMPLETE_NOW; |
+ |
+ if (DoInstant(current_match, &suggested_text, &complete_behavior)) { |
+ SetSuggestedText(suggested_text, complete_behavior); |
} else { |
switch (recommended_action) { |
case AutocompleteActionPredictor::ACTION_PRERENDER: |
@@ -440,7 +443,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 +615,7 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, |
InstantController* instant = controller_->GetInstant(); |
if (instant && !popup_->IsOpen()) |
- instant->DestroyPreviewContents(); |
+ instant->Hide(); |
in_revert_ = false; |
} |
@@ -679,12 +682,11 @@ void OmniboxEditModel::OnSetFocus(bool control_down) { |
NotifySearchTabHelper(); |
} |
-void OmniboxEditModel::OnWillKillFocus(gfx::NativeView view_gaining_focus) { |
+void OmniboxEditModel::OnWillKillFocus() { |
SetSuggestedText(string16(), INSTANT_COMPLETE_NOW); |
- InstantController* instant = controller_->GetInstant(); |
- if (instant) |
- instant->OnAutocompleteLostFocus(view_gaining_focus); |
+ if (InstantController* instant = controller_->GetInstant()) |
+ instant->OnAutocompleteLostFocus(); |
NotifySearchTabHelper(); |
} |
@@ -1086,9 +1088,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 +1104,8 @@ bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match, |
return false; |
if (user_input_in_progress_ && popup_->IsOpen()) { |
- return instant->Update(match, view_->GetText(), UseVerbatimInstant(), |
- suggested_text); |
+ return instant->Update(match, DisplayTextFromUserText(user_text_), |
+ UseVerbatimInstant(), suggested_text, complete_behavior); |
} |
// It's possible DoInstant() was called due to an OnChanged() event from the |