summaryrefslogtreecommitdiffstats
path: root/chromium/components/omnibox/browser/omnibox.mojom
blob: e5de96ad12f4e03bdff0d7f7d837a0ef8963b005 (plain)
1
2
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
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module 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";

// Events that indicate that the user is about to navigate to a suggestion.
enum NavigationPredictor {
  kMouseDown = 1,            // The user pushed the mouse button down.
  kUpOrDownArrowButton = 2,  // The user pushed the down or up arrow button.
  kTouchDown = 3             // The user touched down on a suggestion.
};

// 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.
  string icon_url;
};

// 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 url 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_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 has an image, calculator answer or
  // suggestion answer.
  bool is_rich_suggestion;
  bool is_search_type;  // Result of AutocompleteMatch::IsSearchType().
  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;
};

// 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,
};

struct SuggestionGroup {
  mojo_base.mojom.String16 header;  // Header for suggestion group.
  mojo_base.mojom.String16 hide_group_a11y_label;
  mojo_base.mojom.String16 show_group_a11y_label;
  bool hidden;  // Whether suggestion group should be initially hidden.
  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;
};

enum SelectionLineState {
  kFocusedButtonHeader = 0,
  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.
interface PageHandler {
  // The RealboxBrowserProxy 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,
                     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);
  // Tells the browser to allow suggestions with the given suggestion group ID
  // to appear in the results if they currently are not allowed to or to prevent
  // them from appearing in the results if they are currently permitted to.
  ToggleSuggestionGroupIdVisibility(int32 suggestion_group_id);
  // 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);
};

// 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);
};