Commit 2ce7425d authored by Angela Yoeurng's avatar Angela Yoeurng Committed by Commit Bot

[Omnibox] Update Remove Suggestion button visibility to use popupmodel as source of truth

This fixes a bug that causes a "ghost" remove suggestion button when button row is enabled, and removes duplicate logic.

Bug: 1106062
Change-Id: I377b875fe2ec114c3ca9e708fa35cdf1c822f7f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2304938Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: Angela Yoeurng <yoangela@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790114}
parent fcb2adf4
......@@ -521,10 +521,12 @@ void OmniboxResultView::UpdateHoverState() {
void OmniboxResultView::UpdateRemoveSuggestionVisibility() {
bool old_visibility = remove_suggestion_button_->GetVisible();
bool new_visibility = match_.SupportsDeletion() &&
!match_.associated_keyword &&
!match_.ShouldShowTabMatchButtonInlineInResultView() &&
(IsMatchSelected() || IsMouseHovered());
bool new_visibility =
popup_contents_view_->model()->IsControlPresentOnMatch(
OmniboxPopupModel::Selection(
model_index_,
OmniboxPopupModel::FOCUSED_BUTTON_REMOVE_SUGGESTION)) &&
(IsMatchSelected() || IsMouseHovered());
remove_suggestion_button_->SetVisible(new_visibility);
......
......@@ -498,12 +498,6 @@ bool OmniboxPopupModel::IsControlPresentOnMatch(Selection selection) const {
return true;
case KEYWORD:
return match.associated_keyword != nullptr;
// TODO(orinj): Here is an opportunity to clean up the presentational
// logic that pkasting wanted to take out of AutocompleteMatch. The view
// should be driven by the model, so this is really the place to decide.
// In other words, this duplicates logic within OmniboxResultView.
// This is the proper place. OmniboxResultView should refer to here.
case FOCUSED_BUTTON_REMOVE_SUGGESTION:
// Remove suggestion buttons are suppressed for matches with an associated
// keyword or tab match, unless dedicated button row is enabled.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment