[Android] Respect Show search suggestions in search widget (#36781)

* [Android] Respect `Show search suggestions` in search widget

* [Review] Use BravePref for the preference

* [Review] Change default value when profile is not ready
This commit is contained in:
samartnik
2026-05-28 17:49:13 +01:00
committed by GitHub
parent fcbe4adb3a
commit 9c94331634
6 changed files with 32 additions and 7 deletions
@@ -22,6 +22,7 @@ import org.chromium.chrome.browser.omnibox.suggestions.action.OmniboxActionDeleg
import org.chromium.chrome.browser.omnibox.suggestions.basic.BasicSuggestionProcessor.BookmarkState;
import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler.VoiceResult;
import org.chromium.chrome.browser.preferences.BravePref;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.profiles.ProfileManager;
import org.chromium.chrome.browser.share.ShareDelegate;
@@ -39,7 +40,6 @@ import java.util.function.Supplier;
@NullMarked
class BraveAutocompleteMediator extends AutocompleteMediator
implements BraveSuggestionHost, BraveLeoAutocompleteDelegate {
private static final String AUTOCOMPLETE_ENABLED = "brave.autocomplete_enabled";
private static final String LEO_START_WORD_UPPER_CASE = "LEO";
private final AutocompleteDelegate mDelegate;
@@ -120,7 +120,8 @@ class BraveAutocompleteMediator extends AutocompleteMediator
public boolean isAutoCompleteEnabled(WebContents webContents) {
if (ProfileManager.isInitialized()) {
Profile profile = Profile.fromWebContents(webContents);
if (profile != null && !UserPrefs.get(profile).getBoolean(AUTOCOMPLETE_ENABLED)) {
if (profile != null
&& !UserPrefs.get(profile).getBoolean(BravePref.AUTOCOMPLETE_ENABLED)) {
return false;
}
}