-
-
Notifications
You must be signed in to change notification settings - Fork 285
helium/settings: add autocomplete options for search suggestions #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
potatosalad775
wants to merge
5
commits into
imputnet:main
Choose a base branch
from
potatosalad775:feat/omnibox-suggestion-options
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+259
−0
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e739af6
feat: add autocomplete options for search suggestions
potatosalad775 d63f89d
Merge branch 'main' into feat/omnibox-suggestion-options
potatosalad775 1f9cb65
Merge branch 'main' into feat/omnibox-suggestion-options
dumbmoron 64a3762
helium/add-autocomplete-options: refresh
dumbmoron c031642
helium/add-autocomplete-options: rename, and-ify search_url_database_
dumbmoron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
258 changes: 258 additions & 0 deletions
258
patches/helium/settings/add-autocomplete-exclusion-options.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,258 @@ | ||||||||||||||||||
| --- a/chrome/app/settings_strings.grdp | ||||||||||||||||||
| +++ b/chrome/app/settings_strings.grdp | ||||||||||||||||||
| @@ -2372,6 +2372,15 @@ | ||||||||||||||||||
| <message name="IDS_SETTINGS_SEARCH_MANAGE_SEARCH_ENGINES_EXPLANATION" desc="Explanation for the Manage Search Engines button."> | ||||||||||||||||||
| Create shortcuts for searching sites and manage your search engine | ||||||||||||||||||
| </message> | ||||||||||||||||||
| + <message name="IDS_SEARCH_AUTOCOMPLETE_TITLE" desc="Title for the search autocomplete options."> | ||||||||||||||||||
| + Search autocomplete suggestions | ||||||||||||||||||
| + </message> | ||||||||||||||||||
| + <message name="IDS_SEARCH_AUTOCOMPLETE_SHOW_HISTORY" desc="Label for the option to show search autocomplete suggestions from browsing history."> | ||||||||||||||||||
| + Show browsing history | ||||||||||||||||||
| + </message> | ||||||||||||||||||
| + <message name="IDS_SEARCH_AUTOCOMPLETE_SHOW_BOOKMARK" desc="Label for the option to show search autocomplete suggestions from bookmarks."> | ||||||||||||||||||
| + Show bookmarks | ||||||||||||||||||
| + </message> | ||||||||||||||||||
|
|
||||||||||||||||||
| <!-- Search Engines Page --> | ||||||||||||||||||
| <message name="IDS_SETTINGS_SEARCH_ENGINES" desc="Name of the settings page which manages search engines."> | ||||||||||||||||||
| --- a/chrome/browser/resources/settings/search_page/search_page.html | ||||||||||||||||||
| +++ b/chrome/browser/resources/settings/search_page/search_page.html | ||||||||||||||||||
| @@ -23,6 +23,14 @@ | ||||||||||||||||||
| margin-inline-end: auto; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| + .search-autocomplete-toggles { | ||||||||||||||||||
| + padding-inline-end: 0; | ||||||||||||||||||
| + } | ||||||||||||||||||
| + | ||||||||||||||||||
| + .search-autocomplete-toggles settings-toggle-button { | ||||||||||||||||||
| + padding-inline-start: 0; | ||||||||||||||||||
| + } | ||||||||||||||||||
| + | ||||||||||||||||||
| site-favicon { | ||||||||||||||||||
| --site-favicon-border-radius: 4px; | ||||||||||||||||||
| --site-favicon-height: var(--favicon-size); | ||||||||||||||||||
| @@ -82,6 +90,21 @@ | ||||||||||||||||||
| sub-label="$i18n{searchSuggestPrefDesc}"> | ||||||||||||||||||
| </settings-toggle-button> | ||||||||||||||||||
|
|
||||||||||||||||||
| + <!-- Autocomplete options --> | ||||||||||||||||||
| + <div class="cr-row"> | ||||||||||||||||||
| + $i18n{searchAutocompleteTitle} | ||||||||||||||||||
| + </div> | ||||||||||||||||||
| + <div class="list-frame search-autocomplete-toggles"> | ||||||||||||||||||
| + <settings-toggle-button id="searchAutocompleteHistoryToggle" | ||||||||||||||||||
| + pref="{{prefs.helium.omnibox.autocomplete.history_enabled}}" | ||||||||||||||||||
| + label="$i18n{showSearchAutocompleteHistory}"> | ||||||||||||||||||
| + </settings-toggle-button> | ||||||||||||||||||
| + <settings-toggle-button id="searchAutocompleteBookmarkToggle" class="hr" | ||||||||||||||||||
| + pref="{{prefs.helium.omnibox.autocomplete.bookmark_enabled}}" | ||||||||||||||||||
| + label="$i18n{showSearchAutocompleteBookmark}"> | ||||||||||||||||||
| + </settings-toggle-button> | ||||||||||||||||||
| + </div> | ||||||||||||||||||
| + | ||||||||||||||||||
| <template is="dom-if" | ||||||||||||||||||
| if="[[prefs.default_search_provider_data.template_url_data.extensionId]]"> | ||||||||||||||||||
| <div class="cr-row continuation"> | ||||||||||||||||||
| --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc | ||||||||||||||||||
| +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc | ||||||||||||||||||
| @@ -2729,6 +2729,11 @@ void AddSearchStrings(content::WebUIData | ||||||||||||||||||
| {"searchEnginesCancelButton", IDS_CANCEL}, | ||||||||||||||||||
| {"searchEnginesConfirmationToastLabel", | ||||||||||||||||||
| IDS_SEARCH_ENGINE_CHOICE_SETTINGS_CONFIRMATION_TOAST_LABEL}, | ||||||||||||||||||
| + {"searchAutocompleteTitle", IDS_SEARCH_AUTOCOMPLETE_TITLE}, | ||||||||||||||||||
| + {"showSearchAutocompleteHistory", | ||||||||||||||||||
| + IDS_SEARCH_AUTOCOMPLETE_SHOW_HISTORY}, | ||||||||||||||||||
| + {"showSearchAutocompleteBookmark", | ||||||||||||||||||
| + IDS_SEARCH_AUTOCOMPLETE_SHOW_BOOKMARK}, | ||||||||||||||||||
| }; | ||||||||||||||||||
| html_source->AddLocalizedStrings(kLocalizedStrings); | ||||||||||||||||||
| html_source->AddString("searchExplanationLearnMoreURL", | ||||||||||||||||||
| --- a/components/omnibox/browser/omnibox_pref_names.h | ||||||||||||||||||
| +++ b/components/omnibox/browser/omnibox_pref_names.h | ||||||||||||||||||
| @@ -81,6 +81,14 @@ inline constexpr char kShowAiModeOmnibox | ||||||||||||||||||
| // omnibox. | ||||||||||||||||||
| inline constexpr char kShowSearchTools[] = "omnibox.show_search_tools"; | ||||||||||||||||||
|
|
||||||||||||||||||
| +// Booleans that specify whether history suggestions are shown in the omnibox. | ||||||||||||||||||
| +inline constexpr char kAutocompleteHistoryEnabled[] = | ||||||||||||||||||
| + "helium.omnibox.autocomplete.history_enabled"; | ||||||||||||||||||
| + | ||||||||||||||||||
| +// Booleans that specify whether bookmark suggestions are shown in the omnibox. | ||||||||||||||||||
| +inline constexpr char kAutocompleteBookmarkEnabled[] = | ||||||||||||||||||
| + "helium.omnibox.autocomplete.bookmark_enabled"; | ||||||||||||||||||
| + | ||||||||||||||||||
| // How many times the various IPH suggestions were shown. | ||||||||||||||||||
| inline constexpr char kShownCountEnterpriseSearchAggregatorIph[] = | ||||||||||||||||||
| "omnibox.shown_count_enterprise_search_aggregator_iph"; | ||||||||||||||||||
| --- a/components/omnibox/browser/omnibox_prefs.cc | ||||||||||||||||||
| +++ b/components/omnibox/browser/omnibox_prefs.cc | ||||||||||||||||||
| @@ -32,6 +32,9 @@ void RegisterProfilePrefs(PrefRegistrySi | ||||||||||||||||||
| registry->RegisterBooleanPref( | ||||||||||||||||||
| kShowSearchTools, true, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | ||||||||||||||||||
|
|
||||||||||||||||||
| + registry->RegisterBooleanPref(omnibox::kAutocompleteHistoryEnabled, true); | ||||||||||||||||||
| + registry->RegisterBooleanPref(omnibox::kAutocompleteBookmarkEnabled, true); | ||||||||||||||||||
| + | ||||||||||||||||||
| registry->RegisterBooleanPref(omnibox::kDismissedGeminiIph, false); | ||||||||||||||||||
| registry->RegisterBooleanPref( | ||||||||||||||||||
| omnibox::kDismissedEnterpriseSearchAggregatorIphPrefName, false); | ||||||||||||||||||
| --- a/chrome/browser/extensions/api/settings_private/prefs_util.cc | ||||||||||||||||||
| +++ b/chrome/browser/extensions/api/settings_private/prefs_util.cc | ||||||||||||||||||
| @@ -510,6 +510,10 @@ const PrefsUtil::TypedPrefMap& PrefsUtil | ||||||||||||||||||
| settings_api::PrefType::kDictionary; | ||||||||||||||||||
| (*s_allowlist)[::omnibox::kKeywordSpaceTriggeringEnabled] = | ||||||||||||||||||
| settings_api::PrefType::kBoolean; | ||||||||||||||||||
| + (*s_allowlist)[::omnibox::kAutocompleteHistoryEnabled] = | ||||||||||||||||||
| + settings_api::PrefType::kBoolean; | ||||||||||||||||||
| + (*s_allowlist)[::omnibox::kAutocompleteBookmarkEnabled] = | ||||||||||||||||||
| + settings_api::PrefType::kBoolean; | ||||||||||||||||||
|
|
||||||||||||||||||
| // Site Settings prefs. | ||||||||||||||||||
| (*s_allowlist)[::content_settings::kGeneratedNotificationPref] = | ||||||||||||||||||
| --- a/components/omnibox/browser/bookmark_provider.cc | ||||||||||||||||||
| +++ b/components/omnibox/browser/bookmark_provider.cc | ||||||||||||||||||
| @@ -20,6 +20,7 @@ | ||||||||||||||||||
| #include "components/omnibox/browser/keyword_provider.h" | ||||||||||||||||||
| #include "components/omnibox/browser/match_compare.h" | ||||||||||||||||||
| #include "components/omnibox/browser/omnibox_field_trial.h" | ||||||||||||||||||
| +#include "components/omnibox/browser/omnibox_prefs.h" | ||||||||||||||||||
| #include "components/omnibox/browser/omnibox_triggered_feature_service.h" | ||||||||||||||||||
| #include "components/omnibox/browser/scoring_functor.h" | ||||||||||||||||||
| #include "components/omnibox/browser/titled_url_match_utils.h" | ||||||||||||||||||
| @@ -45,6 +46,10 @@ void BookmarkProvider::Start(const Autoc | ||||||||||||||||||
| TRACE_EVENT0("omnibox", "BookmarkProvider::Start"); | ||||||||||||||||||
| matches_.clear(); | ||||||||||||||||||
|
|
||||||||||||||||||
| + if (!client_->GetPrefs()->GetBoolean(omnibox::kAutocompleteBookmarkEnabled)) { | ||||||||||||||||||
| + return; | ||||||||||||||||||
| + } | ||||||||||||||||||
| + | ||||||||||||||||||
| if (input.IsZeroSuggest() || input.text().empty()) { | ||||||||||||||||||
| return; | ||||||||||||||||||
| } | ||||||||||||||||||
| --- a/components/omnibox/browser/history_fuzzy_provider.cc | ||||||||||||||||||
| +++ b/components/omnibox/browser/history_fuzzy_provider.cc | ||||||||||||||||||
| @@ -36,6 +36,7 @@ | ||||||||||||||||||
| #include "components/omnibox/browser/bookmark_provider.h" | ||||||||||||||||||
| #include "components/omnibox/browser/history_quick_provider.h" | ||||||||||||||||||
| #include "components/omnibox/browser/omnibox_field_trial.h" | ||||||||||||||||||
| +#include "components/omnibox/browser/omnibox_prefs.h" | ||||||||||||||||||
| #include "components/omnibox/browser/omnibox_triggered_feature_service.h" | ||||||||||||||||||
| #include "components/url_formatter/elide_url.h" | ||||||||||||||||||
| #include "third_party/metrics_proto/omnibox_event.pb.h" | ||||||||||||||||||
| @@ -497,6 +498,11 @@ void HistoryFuzzyProvider::Start(const A | ||||||||||||||||||
| bool minimal_changes) { | ||||||||||||||||||
| TRACE_EVENT0("omnibox", "HistoryFuzzyProvider::Start"); | ||||||||||||||||||
| matches_.clear(); | ||||||||||||||||||
| + | ||||||||||||||||||
| + if (!client()->GetPrefs()->GetBoolean(omnibox::kAutocompleteHistoryEnabled)) { | ||||||||||||||||||
| + return; | ||||||||||||||||||
| + } | ||||||||||||||||||
| + | ||||||||||||||||||
| if (input.IsZeroSuggest() || | ||||||||||||||||||
| input.type() == metrics::OmniboxInputType::EMPTY) { | ||||||||||||||||||
| return; | ||||||||||||||||||
| --- a/components/omnibox/browser/history_quick_provider.cc | ||||||||||||||||||
| +++ b/components/omnibox/browser/history_quick_provider.cc | ||||||||||||||||||
| @@ -33,6 +33,7 @@ | ||||||||||||||||||
| #include "components/omnibox/browser/keyword_provider.h" | ||||||||||||||||||
| #include "components/omnibox/browser/match_compare.h" | ||||||||||||||||||
| #include "components/omnibox/browser/omnibox_field_trial.h" | ||||||||||||||||||
| +#include "components/omnibox/browser/omnibox_prefs.h" | ||||||||||||||||||
| #include "components/omnibox/browser/omnibox_triggered_feature_service.h" | ||||||||||||||||||
| #include "components/omnibox/browser/url_prefix.h" | ||||||||||||||||||
| #include "components/omnibox/common/omnibox_features.h" | ||||||||||||||||||
| @@ -61,6 +62,11 @@ void HistoryQuickProvider::Start(const A | ||||||||||||||||||
| bool minimal_changes) { | ||||||||||||||||||
| TRACE_EVENT0("omnibox", "HistoryQuickProvider::Start"); | ||||||||||||||||||
| matches_.clear(); | ||||||||||||||||||
| + | ||||||||||||||||||
| + if (!client()->GetPrefs()->GetBoolean(omnibox::kAutocompleteHistoryEnabled)) { | ||||||||||||||||||
| + return; | ||||||||||||||||||
| + } | ||||||||||||||||||
| + | ||||||||||||||||||
| if (disabled_ || input.IsZeroSuggest() || | ||||||||||||||||||
| input.type() == metrics::OmniboxInputType::EMPTY) { | ||||||||||||||||||
| return; | ||||||||||||||||||
| --- a/components/omnibox/browser/history_url_provider.cc | ||||||||||||||||||
| +++ b/components/omnibox/browser/history_url_provider.cc | ||||||||||||||||||
| @@ -39,6 +39,7 @@ | ||||||||||||||||||
| #include "components/omnibox/browser/in_memory_url_index_types.h" | ||||||||||||||||||
| #include "components/omnibox/browser/keyword_provider.h" | ||||||||||||||||||
| #include "components/omnibox/browser/omnibox_field_trial.h" | ||||||||||||||||||
| +#include "components/omnibox/browser/omnibox_prefs.h" | ||||||||||||||||||
| #include "components/omnibox/browser/url_prefix.h" | ||||||||||||||||||
| #include "components/omnibox/browser/verbatim_match.h" | ||||||||||||||||||
| #include "components/prefs/pref_service.h" | ||||||||||||||||||
| @@ -429,6 +430,13 @@ void HistoryURLProvider::Start(const Aut | ||||||||||||||||||
| return; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| + // Unlike other providers, we can't simply stop the search here. The | ||||||||||||||||||
| + // HistoryURLProvider doesn't only search history, it is also responsible for | ||||||||||||||||||
| + // navigating to exact urls (i.e. https://example.com/), so we need to disable | ||||||||||||||||||
| + // **ONLY** history searches. Fortunately, Chromium has a flag for this. | ||||||||||||||||||
|
Comment on lines
+193
to
+196
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| + search_url_database_ = search_url_database_ && client()->GetPrefs()->GetBoolean( | ||||||||||||||||||
| + omnibox::kAutocompleteHistoryEnabled); | ||||||||||||||||||
|
Comment on lines
+197
to
+198
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| + | ||||||||||||||||||
| // Remove the keyword from input if we're in keyword mode for a starter pack | ||||||||||||||||||
| // engine. | ||||||||||||||||||
| const auto [autocomplete_input, starter_pack_engine] = | ||||||||||||||||||
| --- a/components/omnibox/browser/local_history_zero_suggest_provider.cc | ||||||||||||||||||
| +++ b/components/omnibox/browser/local_history_zero_suggest_provider.cc | ||||||||||||||||||
| @@ -110,6 +110,11 @@ void LocalHistoryZeroSuggestProvider::St | ||||||||||||||||||
| bool minimal_changes) { | ||||||||||||||||||
| TRACE_EVENT0("omnibox", "LocalHistoryZeroSuggestProvider::Start"); | ||||||||||||||||||
| Stop(AutocompleteStopReason::kClobbered); | ||||||||||||||||||
| + | ||||||||||||||||||
| + if (!client_->GetPrefs()->GetBoolean(omnibox::kAutocompleteHistoryEnabled)) { | ||||||||||||||||||
| + return; | ||||||||||||||||||
| + } | ||||||||||||||||||
| + | ||||||||||||||||||
| if (!AllowLocalHistoryZeroSuggestSuggestions(client_, input)) { | ||||||||||||||||||
| return; | ||||||||||||||||||
| } | ||||||||||||||||||
| --- a/components/omnibox/browser/search_provider.cc | ||||||||||||||||||
| +++ b/components/omnibox/browser/search_provider.cc | ||||||||||||||||||
| @@ -44,6 +44,7 @@ | ||||||||||||||||||
| #include "components/omnibox/browser/autocomplete_result.h" | ||||||||||||||||||
| #include "components/omnibox/browser/keyword_provider.h" | ||||||||||||||||||
| #include "components/omnibox/browser/omnibox_field_trial.h" | ||||||||||||||||||
| +#include "components/omnibox/browser/omnibox_prefs.h" | ||||||||||||||||||
| #include "components/omnibox/browser/omnibox_triggered_feature_service.h" | ||||||||||||||||||
| #include "components/omnibox/browser/page_classification_functions.h" | ||||||||||||||||||
| #include "components/omnibox/browser/remote_suggestions_service.h" | ||||||||||||||||||
| @@ -663,6 +664,10 @@ void SearchProvider::DoHistoryQuery(bool | ||||||||||||||||||
| if (base::CommandLine::ForCurrentProcess()->HasSwitch("omnibox-autocomplete-filtering")) | ||||||||||||||||||
| return; | ||||||||||||||||||
|
|
||||||||||||||||||
| + if (!client()->GetPrefs()->GetBoolean(omnibox::kAutocompleteHistoryEnabled)) { | ||||||||||||||||||
| + return; | ||||||||||||||||||
| + } | ||||||||||||||||||
| + | ||||||||||||||||||
| // The history query results are synchronous, so if minimal_changes is true, | ||||||||||||||||||
| // we still have the last results and don't need to do anything. | ||||||||||||||||||
| if (minimal_changes) | ||||||||||||||||||
| --- a/components/omnibox/browser/shortcuts_provider.cc | ||||||||||||||||||
| +++ b/components/omnibox/browser/shortcuts_provider.cc | ||||||||||||||||||
| @@ -37,6 +37,7 @@ | ||||||||||||||||||
| #include "components/omnibox/browser/history_cluster_provider.h" | ||||||||||||||||||
| #include "components/omnibox/browser/history_url_provider.h" | ||||||||||||||||||
| #include "components/omnibox/browser/omnibox_field_trial.h" | ||||||||||||||||||
| +#include "components/omnibox/browser/omnibox_prefs.h" | ||||||||||||||||||
| #include "components/omnibox/browser/omnibox_triggered_feature_service.h" | ||||||||||||||||||
| #include "components/omnibox/browser/url_prefix.h" | ||||||||||||||||||
| #include "components/omnibox/common/omnibox_feature_configs.h" | ||||||||||||||||||
| @@ -218,6 +219,10 @@ void ShortcutsProvider::Start(const Auto | ||||||||||||||||||
| TRACE_EVENT0("omnibox", "ShortcutsProvider::Start"); | ||||||||||||||||||
| matches_.clear(); | ||||||||||||||||||
|
|
||||||||||||||||||
| + if (!client_->GetPrefs()->GetBoolean(omnibox::kAutocompleteHistoryEnabled)) { | ||||||||||||||||||
| + return; | ||||||||||||||||||
| + } | ||||||||||||||||||
| + | ||||||||||||||||||
| if (input.IsZeroSuggest() || | ||||||||||||||||||
| input.type() == metrics::OmniboxInputType::EMPTY || | ||||||||||||||||||
| input.text().empty() || !initialized_) { | ||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.