🧇 Fix some tests that break when the feature is enabled
Addresses some issues from the undefined behaviour FYI bot.
Fixed: b:321280848
Bug: b:318801987
Change-Id: Ie0fd848f022488021758440d2b46f23fb69d83c2
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5224181
Reviewed-by: David Roger <droger@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Commit-Queue: Nicolas Dossou-Gbété <dgn@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1250210}
diff --git a/components/search_engines/template_url_service.cc b/components/search_engines/template_url_service.cc
index 473095ed..8537a10 100644
--- a/components/search_engines/template_url_service.cc
+++ b/components/search_engines/template_url_service.cc
@@ -1000,7 +1000,11 @@
}
}
- if (selection_added) {
+ if (selection_added &&
+ // The choice record below should only be done when called from a path
+ // associated with a fully featured search engine choice screen.
+ choice_made_location != search_engines::ChoiceMadeLocation::kOther) {
+ CHECK(search_engine_choice_service_); // See b/321280848.
search_engine_choice_service_->RecordChoiceMade(choice_made_location, this);
}