[omnibox][webui] Don't crash when focusing RHS AI button
Realbox handler maps the omnibox selection state enum to a mojom enum.
It didn't know what to do with a `LineState::FOCUSED_BUTTON_AIM`.
Bug: 445995099
Change-Id: I11cef81bc936385d84707072e588d832ce020b5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6967401
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Auto-Submit: manuk hovanesian <manukh@chromium.org>
Reviewed-by: Khalid Peer <khalidpeer@chromium.org>
Commit-Queue: Khalid Peer <khalidpeer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1517613}
diff --git a/chrome/browser/ui/webui/searchbox/realbox_handler.cc b/chrome/browser/ui/webui/searchbox/realbox_handler.cc
index a826501..4b1ae39 100644
--- a/chrome/browser/ui/webui/searchbox/realbox_handler.cc
+++ b/chrome/browser/ui/webui/searchbox/realbox_handler.cc
@@ -55,6 +55,7 @@
#include "ui/base/window_open_disposition_utils.h"
namespace {
+
class RealboxOmniboxClient final : public SearchboxOmniboxClient {
public:
RealboxOmniboxClient(Profile* profile, content::WebContents* web_contents);
@@ -82,6 +83,28 @@
profile_metrics::GetBrowserProfileType(profile_));
}
+searchbox::mojom::SelectionLineState ConvertLineState(
+ OmniboxPopupSelection::LineState state) {
+ switch (state) {
+ case OmniboxPopupSelection::LineState::NORMAL:
+ return searchbox::mojom::SelectionLineState::kNormal;
+ case OmniboxPopupSelection::LineState::KEYWORD_MODE:
+ return searchbox::mojom::SelectionLineState::kKeywordMode;
+ case OmniboxPopupSelection::LineState::FOCUSED_BUTTON_AIM:
+ // WebUi currently only cares about popup matches' selection states. No
+ // need to pipe in a selection state that's unique to the omnibox input.
+ return searchbox::mojom::SelectionLineState::kNormal;
+ case OmniboxPopupSelection::LineState::FOCUSED_BUTTON_ACTION:
+ return searchbox::mojom::SelectionLineState::kFocusedButtonAction;
+ case OmniboxPopupSelection::LineState::FOCUSED_BUTTON_REMOVE_SUGGESTION:
+ return searchbox::mojom::SelectionLineState::
+ kFocusedButtonRemoveSuggestion;
+ default:
+ // Realbox doesn't support the other UIs and their focus states.
+ NOTREACHED() << state;
+ }
+}
+
} // namespace
RealboxHandler::RealboxHandler(
@@ -163,23 +186,6 @@
disposition);
}
-searchbox::mojom::SelectionLineState ConvertLineState(
- OmniboxPopupSelection::LineState state) {
- switch (state) {
- case OmniboxPopupSelection::LineState::NORMAL:
- return searchbox::mojom::SelectionLineState::kNormal;
- case OmniboxPopupSelection::LineState::KEYWORD_MODE:
- return searchbox::mojom::SelectionLineState::kKeywordMode;
- case OmniboxPopupSelection::LineState::FOCUSED_BUTTON_ACTION:
- return searchbox::mojom::SelectionLineState::kFocusedButtonAction;
- case OmniboxPopupSelection::LineState::FOCUSED_BUTTON_REMOVE_SUGGESTION:
- return searchbox::mojom::SelectionLineState::
- kFocusedButtonRemoveSuggestion;
- default:
- NOTREACHED();
- }
-}
-
void RealboxHandler::UpdateSelection(OmniboxPopupSelection old_selection,
OmniboxPopupSelection selection) {
page_->UpdateSelection(