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 307ba14ddf24350c417df96f8594a44b12f1bd9f..0909741bc2de42341b5b9f53ffc386214241ae25 100644 |
| --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
| +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
| @@ -501,24 +501,15 @@ void OmniboxEditModel::SetInputInProgress(bool in_progress) { |
| time_user_first_modified_omnibox_ = base::TimeTicks::Now(); |
| content::RecordAction(base::UserMetricsAction("OmniboxInputInProgress")); |
| autocomplete_controller()->ResetSession(); |
| - // Once the user starts editing, re-enable URL replacement, so that it will |
| - // kick in if applicable once the edit is committed or reverted. (While the |
| - // edit is in progress, this won't have a visible effect.) |
| - controller_->GetToolbarModel()->set_url_replacement_enabled(true); |
| } |
| - // The following code handles three cases: |
| + // The following code handles two cases: |
| // * For HIDE_ON_USER_INPUT, it hides the chip when user input begins. |
| // * For HIDE_ON_MOUSE_RELEASE, which only hides the chip on mouse release if |
| // the omnibox is empty, it handles the "omnibox was not empty" case by |
| - // acting like HIDE_ON_USER_INPUT. (If the omnibox was empty, it |
| - // effectively no-ops.) |
| - // * For both hide behaviors, it allows the chip to be reshown once input |
| - // ends. (The chip won't actually be re-shown until there's no pending |
| - // typed navigation; see OriginChipView::ShouldShow() and |
| - // OriginChipDecoration::ShouldShow().) |
| - if (chrome::ShouldDisplayOriginChipV2()) |
| - controller()->GetToolbarModel()->set_origin_chip_enabled(!in_progress); |
| + // acting like HIDE_ON_USER_INPUT. |
| + if (chrome::ShouldDisplayOriginChipV2() && in_progress) |
| + controller()->GetToolbarModel()->set_origin_chip_enabled(false); |
| controller_->GetToolbarModel()->set_input_in_progress(in_progress); |
| controller_->Update(NULL); |
| @@ -970,6 +961,14 @@ bool OmniboxEditModel::OnEscapeKeyPressed() { |
| view_->Update(); |
| } |
| + // If URL replacement is enabled, we'll need to disable it and update the |
| + // permanent text below in order to bring the URL back. Unless search term |
| + // replacement is being performed, in which case we want to keep the search |
| + // terms. |
|
Peter Kasting
2014/03/27 22:04:12
Nit: How about this comment:
When using the origi
Justin Donnelly
2014/03/27 22:10:07
Done.
|
| + bool should_disable_url_replacement = |
| + controller_->GetToolbarModel()->url_replacement_enabled() && |
| + !controller_->GetToolbarModel()->WouldPerformSearchTermReplacement(true); |
| + |
| // If the user wasn't editing, but merely had focus in the edit, allow <esc> |
| // to be processed as an accelerator, so it can still be used to stop a load. |
| // When the permanent text isn't all selected we still fall through to the |
| @@ -977,8 +976,8 @@ bool OmniboxEditModel::OnEscapeKeyPressed() { |
| // <esc> to quickly replace all the text; this matches IE. |
| const bool has_zero_suggest_match = match.provider && |
| (match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST); |
| - if (!has_zero_suggest_match && !user_input_in_progress_ && |
| - view_->IsSelectAll()) |
| + if (!has_zero_suggest_match && !should_disable_url_replacement && |
| + !user_input_in_progress_ && view_->IsSelectAll()) |
| return false; |
| if (!user_text_.empty()) { |
| @@ -986,7 +985,12 @@ bool OmniboxEditModel::OnEscapeKeyPressed() { |
| OMNIBOX_USER_TEXT_CLEARED_WITH_ESCAPE, |
| OMNIBOX_USER_TEXT_CLEARED_NUM_OF_ITEMS); |
| } |
| - view_->RevertAll(); |
| + |
| + if (should_disable_url_replacement) { |
| + controller_->GetToolbarModel()->set_url_replacement_enabled(false); |
| + UpdatePermanentText(); |
| + } |
| + view_->RevertWithoutResettingSearchTermReplacement(); |
| view_->SelectAll(true); |
| return true; |
| } |