From 1bcd49f4abfa0f4b22aa690ae19ebfa665f4bdef Mon Sep 17 00:00:00 2001 From: Pavel Beloborodov <73575789+boocmp@users.noreply.github.com> Date: Thu, 2 Oct 2025 19:40:37 +0700 Subject: [PATCH] Prevent search suggestions from clipboard text. (#31336) * Prevent search suggestions from clipboard text. --- .../omnibox/browser/omnibox_edit_model.cc | 12 ++++++------ ...s-omnibox-browser-omnibox_edit_model.cc.patch | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/chromium_src/components/omnibox/browser/omnibox_edit_model.cc b/chromium_src/components/omnibox/browser/omnibox_edit_model.cc index 0f362f41a53..cccfb7d30bb 100644 --- a/chromium_src/components/omnibox/browser/omnibox_edit_model.cc +++ b/chromium_src/components/omnibox/browser/omnibox_edit_model.cc @@ -24,9 +24,9 @@ namespace { SetInputIsPastedFromClipboard(OmniboxController* omnibox_controller, bool is_input_pasted) { CHECK(omnibox_controller); - if (auto* autocomplete_controller = omnibox_controller->client() - ->GetAutocompleteClassifier() - ->autocomplete_controller()) { + + if (auto* autocomplete_controller = + omnibox_controller->autocomplete_controller()) { if (auto* search_provider = autocomplete_controller->search_provider()) { return search_provider->AsBraveSearchProvider() ->SetInputIsPastedFromClipboard(is_input_pasted); @@ -39,8 +39,8 @@ SetInputIsPastedFromClipboard(OmniboxController* omnibox_controller, #define CanPasteAndGo CanPasteAndGo_Chromium #define PasteAndGo PasteAndGo_Chromium #define GetSuperGIcon GetSuperGIcon_Unused -#define BRAVE_OMNIBOX_EDIT_MODEL_GET_INFO_FOR_CURRENT_TEXT \ - auto pasted = \ +#define BRAVE_OMNIBOX_EDIT_MODEL_START_AUTOCOMPLETE \ + auto pasted = \ SetInputIsPastedFromClipboard(controller_, paste_state_ != NONE); #include @@ -48,7 +48,7 @@ SetInputIsPastedFromClipboard(OmniboxController* omnibox_controller, #undef GetSuperGIcon #undef CanPasteAndGo #undef PasteAndGo -#undef BRAVE_OMNIBOX_EDIT_MODEL_GET_INFO_FOR_CURRENT_TEXT +#undef BRAVE_OMNIBOX_EDIT_MODEL_START_AUTOCOMPLETE bool OmniboxEditModel::CanPasteAndGo(const std::u16string& text) const { #if BUILDFLAG(ENABLE_COMMANDER) diff --git a/patches/components-omnibox-browser-omnibox_edit_model.cc.patch b/patches/components-omnibox-browser-omnibox_edit_model.cc.patch index ea6fb69e88b..9f1ac5361f9 100644 --- a/patches/components-omnibox-browser-omnibox_edit_model.cc.patch +++ b/patches/components-omnibox-browser-omnibox_edit_model.cc.patch @@ -1,12 +1,12 @@ diff --git a/components/omnibox/browser/omnibox_edit_model.cc b/components/omnibox/browser/omnibox_edit_model.cc -index 814e1aa0ee9cc8c308fd1dbbd28f53e3ae920d0a..7c30402cb72b009c938cdc3adce62a4781fabfb1 100644 +index 814e1aa0ee9cc8c308fd1dbbd28f53e3ae920d0a..0d8ddc43f1dab93ba4d14f12756c99f982b6fc55 100644 --- a/components/omnibox/browser/omnibox_edit_model.cc +++ b/components/omnibox/browser/omnibox_edit_model.cc -@@ -1569,6 +1569,7 @@ void OmniboxEditModel::GetInfoForCurrentText(AutocompleteMatch* match, - std::u16string text_for_match_generation = - user_input_in_progress() ? user_text_ : url_for_editing_; +@@ -652,6 +652,7 @@ void OmniboxEditModel::StartAutocomplete(bool has_selected_text, + input_.set_lens_overlay_suggest_inputs(*suggest_inputs); + } + ++ BRAVE_OMNIBOX_EDIT_MODEL_START_AUTOCOMPLETE + controller_->StartAutocomplete(input_); + } -+ BRAVE_OMNIBOX_EDIT_MODEL_GET_INFO_FOR_CURRENT_TEXT - controller_->client()->GetAutocompleteClassifier()->Classify( - MaybePrependKeyword(text_for_match_generation), is_keyword_selected(), - true, GetPageClassification(), match, alternate_nav_url);