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 481c0792b5c6018984c548f1620d04502503547c..ddde6218b800cd65270d1e69587e5db50368fafc 100644 |
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
@@ -93,11 +93,13 @@ enum UserTextClearedType { |
OmniboxEditModel::State::State(bool user_input_in_progress, |
const string16& user_text, |
+ const string16& suggest_text, |
const string16& keyword, |
bool is_keyword_hint, |
OmniboxFocusState focus_state) |
: user_input_in_progress(user_input_in_progress), |
user_text(user_text), |
+ suggest_text(suggest_text), |
keyword(keyword), |
is_keyword_hint(is_keyword_hint), |
focus_state(focus_state) { |
@@ -156,7 +158,11 @@ const OmniboxEditModel::State OmniboxEditModel::GetStateForTabSwitch() { |
} |
} |
- return State(user_input_in_progress_, user_text_, keyword_, is_keyword_hint_, |
+ return State(user_input_in_progress_, |
+ user_text_, |
+ view_->GetInstantSuggestion(), |
+ keyword_, |
+ is_keyword_hint_, |
focus_state_); |
} |
@@ -170,6 +176,7 @@ void OmniboxEditModel::RestoreState(const State& state) { |
is_keyword_hint_ = state.is_keyword_hint; |
view_->SetUserText(state.user_text, |
DisplayTextFromUserText(state.user_text), false); |
+ view_->SetInstantSuggestion(state.suggest_text); |
} |
} |
@@ -184,9 +191,11 @@ bool OmniboxEditModel::UpdatePermanentText(const string16& new_permanent_text) { |
// doesn't have focus, we want to revert the edit to show the new URL. (The |
// common case where the edit doesn't have focus is when the user has started |
// an edit and then abandoned it and clicked a link on the page.) |
+ string16 suggest_text = view_->GetInstantSuggestion(); |
const bool visibly_changed_permanent_text = |
(permanent_text_ != new_permanent_text) && |
- (!user_input_in_progress_ || !has_focus()); |
+ (!user_input_in_progress_ || !has_focus()) && |
+ (suggest_text.empty() || new_permanent_text != user_text_ + suggest_text); |
Peter Kasting
2013/03/30 18:48:21
Why do we have to add this final clause? At the l
sail
2013/04/02 22:32:06
This prevents the omnibox text from changing when
|
permanent_text_ = new_permanent_text; |
return visibly_changed_permanent_text; |
@@ -812,8 +821,6 @@ void OmniboxEditModel::OnWillKillFocus(gfx::NativeView view_gaining_focus) { |
view_gaining_focus); |
} |
- SetInstantSuggestion(InstantSuggestion()); |
- |
// TODO(jered): Rip this out along with StartZeroSuggest. |
autocomplete_controller_->StopZeroSuggest(); |
delegate_->NotifySearchTabHelper(user_input_in_progress_, !in_revert_); |