Skip to content

Commit

Permalink
Revert "[DanglingPtr] Remove patching for AutocompleteMatch (#26606)"
Browse files Browse the repository at this point in the history
This reverts commit b894151.
  • Loading branch information
emerick committed Jan 2, 2025
1 parent 457e9b3 commit 2bb9f1f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "brave/components/ai_rewriter/common/buildflags/buildflags.h"
#include "brave/components/tor/buildflags/buildflags.h"
#include "brave/grit/brave_theme_resources.h"
#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
#include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_list.h"
Expand Down Expand Up @@ -73,14 +72,15 @@ namespace {

AutocompleteMatch GetAutocompleteMatchForText(Profile* profile,
const std::u16string& text) {
// `AutocompleteClassifierFactory` ultimately instantiates a
// `BraveAutocompleteSchemeClassifier` instance, as the substitution gets
// applied on the header for `ChromeAutocompleteSchemeClassifier`.
auto* classifier = AutocompleteClassifierFactory::GetForProfile(profile);
CHECK(classifier);
AutocompleteMatch match;
classifier->Classify(text, false, false,
metrics::OmniboxEventProto::INVALID_SPEC, &match, NULL);
AutocompleteClassifier classifier(
std::make_unique<AutocompleteController>(
std::make_unique<ChromeAutocompleteProviderClient>(profile),
AutocompleteClassifier::DefaultOmniboxProviders()),
std::make_unique<BraveAutocompleteSchemeClassifier>(profile));
classifier.Classify(text, false, false,
metrics::OmniboxEventProto::INVALID_SPEC, &match, NULL);
classifier.Shutdown();
return match;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class BraveHistoryQuickProviderTest : public testing::Test {
}

void TearDown() override {
ac_matches_.clear();
provider_ = nullptr;
client_.reset();
}
Expand Down Expand Up @@ -243,8 +242,9 @@ class BraveHistoryQuickProviderTest : public testing::Test {
base::ScopedTempDir history_dir_;
std::unique_ptr<FakeAutocompleteProviderClient> client_;

scoped_refptr<BraveHistoryQuickProvider> provider_;
ACMatches ac_matches_; // The resulting matches after running RunTest.

scoped_refptr<BraveHistoryQuickProvider> provider_;
};

BraveHistoryQuickProviderTest::SetShouldContain::SetShouldContain(
Expand Down
13 changes: 13 additions & 0 deletions patches/components-omnibox-browser-autocomplete_match.h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/components/omnibox/browser/autocomplete_match.h b/components/omnibox/browser/autocomplete_match.h
index 804afdcf39427df21c501b3d20ccf455886a2876..97b0cb227db751c359eaf0e1abcbaefd078c4b19 100644
--- a/components/omnibox/browser/autocomplete_match.h
+++ b/components/omnibox/browser/autocomplete_match.h
@@ -717,7 +717,7 @@ struct AutocompleteMatch {
// The provider of this match, used to remember which provider the user had
// selected when the input changes. This may be NULL, in which case there is
// no provider (or memory of the user's selection).
- raw_ptr<AutocompleteProvider> provider = nullptr;
+ raw_ptr<AutocompleteProvider, DanglingUntriaged> provider = nullptr;

// The relevance of this match. See table in autocomplete_provider.h for
// scores returned by various providers. This is used to rank matches among

0 comments on commit 2bb9f1f

Please sign in to comment.