Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 258 additions & 0 deletions patches/helium/settings/add-autocomplete-exclusion-options.patch
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
+ Search autocomplete suggestions
+ Local search suggestions
  1. "autocomplete" is not used anywhere on this page, suggestions are referred to as "suggestions".
  2. "Search suggestions" implies that they come from the search engine, but they're generated locally. not sure if what i'm suggesting is the ideal phrasing for this, though

+ </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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
+ // 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.
+ // Aside from providing history autocomplete, HistoryURLProvider is also
+ // responsible for navigating to exact urls (i.e. https://example.com/).
+ // If the user disabled history autocomplete, we need to disable just that,
+ // not the entire provider.

+ search_url_database_ = search_url_database_ && client()->GetPrefs()->GetBoolean(
+ omnibox::kAutocompleteHistoryEnabled);
Comment on lines +197 to +198
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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);
+ search_url_database_ = search_url_database_ && client()->GetPrefs()->GetBoolean(
+ omnibox::kAutocompleteHistoryEnabled);

+
// 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_) {
1 change: 1 addition & 0 deletions patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ helium/settings/fix-appearance-page.patch
helium/settings/enable-quad9-doh-option.patch
helium/settings/reorder-settings-menu.patch
helium/settings/add-search-engine-button.patch
helium/settings/add-autocomplete-exclusion-options.patch

helium/hop/setup.patch
helium/hop/disable-password-manager.patch
Expand Down