Chromium Code Reviews| 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 ff3e0fdf807670f05da05cea814aaf65656a3fdb..a69763828b46765982cba9feed7ba5e34d7b2162 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& instant_suggestion, |
| const string16& keyword, |
| bool is_keyword_hint, |
| OmniboxFocusState focus_state) |
| : user_input_in_progress(user_input_in_progress), |
| user_text(user_text), |
| + instant_suggestion(instant_suggestion), |
| 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.instant_suggestion); |
| } |
| } |
| @@ -183,10 +190,14 @@ bool OmniboxEditModel::UpdatePermanentText(const string16& new_permanent_text) { |
| // When there's a new URL, and the user is not editing anything or the edit |
| // 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.) |
| + // an edit and then abandoned it and clicked a link on the page.) The only |
| + // exception is if there's suggest text and the new URL is for a search result |
| + // for the full text. |
|
Peter Kasting
2013/04/03 00:35:35
This added comment describes what, not why. You n
sail
2013/04/03 19:34:11
Done.
|
| + string16 suggest_text = view_->GetInstantSuggestion(); |
|
Peter Kasting
2013/04/03 00:35:35
Nit: Name this |instant_suggestion|
sail
2013/04/03 19:34:11
Done.
|
| 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); |
| permanent_text_ = new_permanent_text; |
| return visibly_changed_permanent_text; |
| @@ -814,8 +825,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_); |