| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 
 | // Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module searchbox.mojom;
import "components/omnibox/browser/omnibox.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/time.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "url/mojom/url.mojom";
// See components/omnibox/browser/autocomplete_match.h.
struct ACMatchClassification {
  uint32 offset;
  int32 style;
};
// See components/omnibox/browser/actions/omnibox_action.h
struct Action {
  mojo_base.mojom.String16 a11y_label;
  mojo_base.mojom.String16 hint;
  mojo_base.mojom.String16 suggestion_contents;
  // The url for the action icon. This is a relative url pointing to a
  // bundled resource and is used directly in CSS to show the icon.
  // |icon_path| is a relative url or a data URI.
  string icon_path;
};
// See components/omnibox/browser/suggestion_answer.h
struct SuggestionAnswer {
  mojo_base.mojom.String16 first_line;
  mojo_base.mojom.String16 second_line;
};
struct AutocompleteMatch {
  mojo_base.mojom.String16 a11y_label;
  bool allowed_to_be_default_match;
  array<Action> actions;
  SuggestionAnswer? answer;
  mojo_base.mojom.String16 contents;
  array<ACMatchClassification> contents_class;
  mojo_base.mojom.String16 description;
  array<ACMatchClassification> description_class;
  url.mojom.Url destination_url;
  mojo_base.mojom.String16 inline_autocompletion;
  mojo_base.mojom.String16 fill_into_edit;
  bool? is_weather_answer_suggestion;
  // The path for the suggestion icon. This is a relative url pointing to a
  // bundled resource and is used directly in CSS to show the icon.
  string icon_path;
  // The url for the suggestion icon. |icon_url| is an external url or
  // a data URI.
  url.mojom.Url icon_url;
  // Used to paint a placeholder while fetching |image_url|. These two fields
  // are valid for entity suggestions only. Entity suggestions have a |type| of
  // 'search-suggest-entity'.
  string image_dominant_color;
  // The image url for entity suggestions. |image_url| is an external url or
  // a data URI.
  string image_url;
  // Used to determine if the match is a non-canned AI suggestion.
  bool is_noncanned_aim_suggestion;
  // Used to determine if the match has an image, calculator answer,
  // suggestion answer, or enterprise search aggregator people suggestion.
  bool is_rich_suggestion;
  bool is_search_type;  // Result of AutocompleteMatch::IsSearchType().
  // Used to determine if the match is an enterprise search aggregator people
  // suggestion.
  bool is_enterprise_search_aggregator_people_type;
  string type;  // Result of AutocompleteMatchType::ToString().
  mojo_base.mojom.String16 remove_button_a11y_label;
  bool swap_contents_and_description;
  // ID of the group the suggestion belongs to. 0 if it does not belong to any.
  int32 suggestion_group_id;
  bool supports_deletion;
  // Holds the common part of tail suggestion. Not every match has a tail
  // suggestion prefix. For example, the tail suggestion prefix for "hobbit
  // holes for sale in" is "hobbit holes for sale" and the match contents
  // would be the text following "sale".
  mojo_base.mojom.String16? tail_suggest_common_prefix;
};
// Information about a suggested tab in the WebUI.
struct TabInfo {
  // The unique identifier of the tab.
  int32 tab_id;
  // The title of the tab.
  string title;
  // The URL of the tab.
  url.mojom.Url url;
  // The time the tab was last active.
  mojo_base.mojom.TimeTicks last_active;
};
// Indicates whether a suggestion group is in the primary or the secondary
// column of suggestions. See //third_party/omnibox_proto/groups.proto.
enum SideType {
  kDefaultPrimary = 0,
  kSecondary = 1,
};
// Indicates whether a suggestion group should be rendered vertically or
// horizontally. See //third_party/omnibox_proto/groups.proto.
enum RenderType {
  kDefaultVertical = 0,
  kHorizontal = 1,
  kGrid = 2,
};
struct SuggestionGroup {
  mojo_base.mojom.String16 header;  // Header for suggestion group.
  RenderType render_type = RenderType.kDefaultVertical;
  SideType side_type = SideType.kDefaultPrimary;
};
struct AutocompleteResult {
  mojo_base.mojom.String16 input;
  // Map of suggestion group IDs to their respective info.
  map<int32, SuggestionGroup> suggestion_groups_map;
  array<AutocompleteMatch> matches;
  mojo_base.mojom.String16? smart_compose_inline_hint;
};
enum SelectionLineState {
  kNormal = 1,
  kKeywordMode = 2,
  kFocusedButtonAction = 3,
  kFocusedButtonRemoveSuggestion = 4,
};
// See components/omnibox/browser/omnibox_popup_selection.h
struct OmniboxPopupSelection {
  uint8 line;
  SelectionLineState state;
  uint8 action_index;
};
// Browser-side handler for requests from WebUI page. The web pages that embed
// searchboxes which communicate with this interface are chrome://new-tab-page
// and two chrome-untrusted://lens pages.
interface PageHandler {
  // The SearchboxBrowserProxy singleton calls this when it's first initialized.
  SetPage(pending_remote<Page> page);
  // Informs the handler and model about focus state changes.
  OnFocusChanged(bool focused);
  // Queries autocomplete matches from the browser.
  QueryAutocomplete(
      mojo_base.mojom.String16 input, bool prevent_inline_autocomplete);
  // Cancels the current autocomplete query. Clears the result set if
  // |clear_result| is true.
  StopAutocomplete(bool clear_result);
  // Handles navigation to an autocomplete match (i.e. an item in the realbox's
  // list of matches).
  // Note: |url| is only used to confirm the match |line| selection.
  // |mouse_button| indicates which mouse button was pressed on the match. See
  // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
  OpenAutocompleteMatch(uint8 line,
                        url.mojom.Url url,
                        bool are_matches_showing,
                        uint8 mouse_button,
                        bool alt_key,
                        bool ctrl_key,
                        bool meta_key,
                        bool shift_key);
  // Informs the browser that the user has changed the selected suggestion. The
  // new suggestion is located at |line|. |navigation_predictor|
  // indicates the event that indicated navigation was likely.
  // |url| is only used to confirm the match |line| selection.
  OnNavigationLikely(uint8 line,
                     url.mojom.Url url,
                     omnibox.mojom.NavigationPredictor navigation_predictor);
  // Deletes the AutocompleteMatch in the current results by |line| number if
  // it is deletable. |url| is used to confirm the match |line| selection.
  DeleteAutocompleteMatch(uint8 line, url.mojom.Url url);
  // Executes the Pedal Action. match_selection_timestamp is the number of
  // microseconds since Jan. 1, 1970 (ECMAScript epoch).
  // |url| is only used to confirm the match |line| selection.
  ExecuteAction(uint8 line,
                uint8 action_index,
                url.mojom.Url url,
                mojo_base.mojom.TimeTicks match_selection_timestamp,
                uint8 mouse_button,
                bool alt_key,
                bool ctrl_key,
                bool meta_key,
                bool shift_key);
  // Called when the popup results view element size is changed.
  PopupElementSizeChanged(gfx.mojom.Size size);
  // Notifies browser that thumbnail has been removed.
  OnThumbnailRemoved();
  // Returns information about recent tabs.
  GetRecentTabs() => (array<TabInfo> tabs);
};
// WebUI-side handler for requests from the browser.
interface Page {
  // Updates the page with the autocomplete results.
  AutocompleteResultChanged(AutocompleteResult result);
  // Updates the UI's selected line and action based on the |selection| and
  // |old_selection|.
  UpdateSelection(
      OmniboxPopupSelection old_selection, OmniboxPopupSelection selection);
  // Called to set searchbox input.
  SetInputText(string input);
  // Sets searchbox thumbnail.
  SetThumbnail(string thumbnail_url, bool is_deletable);
};
 |