Prevent search suggestions from clipboard text. (#31336)

* Prevent search suggestions from clipboard text.
This commit is contained in:
Pavel Beloborodov
2025-10-02 13:40:37 +01:00
committed by GitHub
parent 6eb06e18fc
commit 1bcd49f4ab
2 changed files with 14 additions and 14 deletions
@@ -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 <components/omnibox/browser/omnibox_edit_model.cc>
@@ -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)
@@ -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);