--- a/chrome/browser/ungoogled_flag_choices.h +++ b/chrome/browser/ungoogled_flag_choices.h @@ -45,4 +45,19 @@ const FeatureEntry::Choice kBookmarkBarN "bookmark-bar-ntp", "never"}, }; +const FeatureEntry::Choice kOmniboxAutocompleteFiltering[] = { + {flags_ui::kGenericExperimentChoiceDefault, "", ""}, + {"Search suggestions only", + "omnibox-autocomplete-filtering", + "search"}, + {"Search suggestions and bookmarks", + "omnibox-autocomplete-filtering", + "search-bookmarks"}, + {"Search suggestions and internal chrome pages", + "omnibox-autocomplete-filtering", + "search-chrome"}, + {"Search suggestions, bookmarks, and internal chrome pages", + "omnibox-autocomplete-filtering", + "search-bookmarks-chrome"}, +}; #endif // CHROME_BROWSER_UNGOOGLED_FLAG_CHOICES_H_ --- a/chrome/browser/ungoogled_flag_entries.h +++ b/chrome/browser/ungoogled_flag_entries.h @@ -44,4 +44,8 @@ "Bookmark Bar on New-Tab-Page", "Disable the Bookmark Bar on the New-Tab-Page. ungoogled-chromium flag.", kOsDesktop, MULTI_VALUE_TYPE(kBookmarkBarNewTab)}, + {"omnibox-autocomplete-filtering", + "Omnibox Autocomplete Filtering", + "Restrict omnibox autocomplete results to a combination of search suggestions (if enabled), bookmarks, and internal chrome pages. ungoogled-chromium flag.", + kOsAll, MULTI_VALUE_TYPE(kOmniboxAutocompleteFiltering)}, #endif // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_ --- a/components/omnibox/browser/autocomplete_controller.cc +++ b/components/omnibox/browser/autocomplete_controller.cc @@ -15,6 +15,8 @@ #include "base/bind.h" #include "base/check_op.h" +#include "base/containers/contains.h" +#include "base/command_line.h" #include "base/feature_list.h" #include "base/format_macros.h" #include "base/metrics/histogram.h" @@ -276,6 +278,15 @@ AutocompleteController::AutocompleteCont search_service_worker_signal_sent_(false), template_url_service_(provider_client_->GetTemplateURLService()) { provider_types &= ~OmniboxFieldTrial::GetDisabledProviderTypes(); + if (base::CommandLine::ForCurrentProcess()->HasSwitch("omnibox-autocomplete-filtering")) { + const std::string flag_value = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII("omnibox-autocomplete-filtering"); + provider_types &= AutocompleteProvider::TYPE_KEYWORD | AutocompleteProvider::TYPE_SEARCH | + AutocompleteProvider::TYPE_HISTORY_URL | AutocompleteProvider::TYPE_BOOKMARK | AutocompleteProvider::TYPE_BUILTIN; + if (!base::Contains(flag_value, "bookmarks")) + provider_types &= ~AutocompleteProvider::TYPE_BOOKMARK; + if (!base::Contains(flag_value, "chrome")) + provider_types &= ~AutocompleteProvider::TYPE_BUILTIN; + } if (provider_types & AutocompleteProvider::TYPE_BOOKMARK) providers_.push_back(new BookmarkProvider(provider_client_.get())); if (provider_types & AutocompleteProvider::TYPE_BUILTIN) --- a/components/omnibox/browser/history_url_provider.cc +++ b/components/omnibox/browser/history_url_provider.cc @@ -551,6 +551,9 @@ void HistoryURLProvider::Start(const Aut if (fixed_up_input.type() != metrics::OmniboxInputType::QUERY) matches_.push_back(what_you_typed_match); + if (base::CommandLine::ForCurrentProcess()->HasSwitch("omnibox-autocomplete-filtering")) + return; + // We'll need the history service to run both passes, so try to obtain it. history::HistoryService* const history_service = client()->GetHistoryService(); --- a/components/omnibox/browser/search_provider.cc +++ b/components/omnibox/browser/search_provider.cc @@ -12,6 +12,7 @@ #include "base/base64.h" #include "base/bind.h" #include "base/callback.h" +#include "base/command_line.h" #include "base/feature_list.h" #include "base/i18n/break_iterator.h" #include "base/i18n/case_conversion.h" @@ -646,6 +647,9 @@ void SearchProvider::Run(bool query_is_p } void SearchProvider::DoHistoryQuery(bool minimal_changes) { + if (base::CommandLine::ForCurrentProcess()->HasSwitch("omnibox-autocomplete-filtering")) + 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/url_formatter/url_fixer.cc +++ b/components/url_formatter/url_fixer.cc @@ -9,6 +9,8 @@ #include #include "base/check_op.h" +#include "base/containers/contains.h" +#include "base/command_line.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/ranges/algorithm.h" @@ -607,6 +609,8 @@ GURL FixupURL(const std::string& text, c FixupHost(trimmed, parts.host, parts.scheme.is_valid(), desired_tld, &url); if (chrome_url && !parts.host.is_valid()) + if (!base::CommandLine::ForCurrentProcess()->HasSwitch("omnibox-autocomplete-filtering") || + base::Contains(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII("omnibox-autocomplete-filtering"), "chrome")) url.append(kChromeUIDefaultHost); FixupPort(trimmed, parts.port, &url); FixupPath(trimmed, parts.path, &url);