Skip to content

Commit

Permalink
[Omnibox] Fix added for omnibox crashes when spannable autocomplete m…
Browse files Browse the repository at this point in the history
…odel feature disabled and excessive recycled view pool flag is enabled.

Regular autocomplete model (not the spannable one) will send a empty auto complete suggestion whenever the user tries to initiate the search and unfocus omnibox. Without RemoveExcessiveRecycledViewClearCalls feature, this case will be caught with logic check for `getSuggestionVisibilityState()` at the start of the function `onSuggestionsReceived`. And this CL added url bar focus check when auto complete model tries to provide any suggestions.

Bug: 1373795
Change-Id: Ief91cc1872e51f2ba6faa829527a42c9af7a6083
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4021550
Reviewed-by: Tomasz Wiszkowski <ender@google.com>
Commit-Queue: Rong Tan <rongtan@google.com>
Cr-Commit-Position: refs/heads/main@{#1070629}
  • Loading branch information
Rong Tan authored and Chromium LUCI CQ committed Nov 12, 2022
1 parent 1310ca1 commit 2c8c159
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener,
private boolean mShouldCacheSuggestions;
private boolean mClearFocusAfterNavigation;
private boolean mClearFocusAfterNavigationAsynchronously;
private boolean mUrlHasFocus;

// TODO(crbug.com/1373795): Remove interface SuggestionVisibilityState and
// mSuggestionVisibilityState after feature OmniboxRemoveExcessiveRecycledViewClearCalls is
Expand Down Expand Up @@ -309,6 +310,7 @@ void onNativeInitialized() {

/** @see org.chromium.chrome.browser.omnibox.UrlFocusChangeListener#onUrlFocusChange(boolean) */
void onUrlFocusChange(boolean hasFocus) {
mUrlHasFocus = hasFocus;
if (hasFocus) {
dismissDeleteDialog(DialogDismissalCause.DISMISSED_BY_NATIVE);
mRefineActionUsage = RefineActionUsage.NOT_USED;
Expand Down Expand Up @@ -747,7 +749,9 @@ public void onSuggestionsReceived(
&& !newSuggestions.isEmpty()) {
defaultMatchIsSearch = newSuggestions.get(0).isSearchSuggestion();
}
mDelegate.onSuggestionsChanged(inlineAutocompleteText, defaultMatchIsSearch);
if (!OmniboxFeatures.shouldRemoveExcessiveRecycledViewClearCalls() || mUrlHasFocus) {
mDelegate.onSuggestionsChanged(inlineAutocompleteText, defaultMatchIsSearch);
}
if (!OmniboxFeatures.shouldRemoveExcessiveRecycledViewClearCalls()) {
updateOmniboxSuggestionsVisibility();
}
Expand Down

0 comments on commit 2c8c159

Please sign in to comment.