1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 import "mojo/public/mojom/base/string16.mojom";
8 import "services/network/public/mojom/referrer_policy.mojom";
9 import "third_party/blink/public/mojom/conversions/conversions.mojom";
10 import "ui/base/mojom/ui_base_types.mojom";
11 import "ui/gfx/geometry/mojom/geometry.mojom";
12 import "url/mojom/url.mojom";
14 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.blink_public.common
15 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ContextMenuDataMediaType
16 enum ContextMenuDataMediaType {
17 // No special node is in context.
20 // An image node is selected.
23 // A video node is selected.
26 // An audio node is selected.
29 // A canvas node is selected.
32 // A file node is selected.
35 // A plugin node is selected.
39 enum ContextMenuDataInputFieldType {
40 // Not an input field.
43 // type = text, search, email, url
59 enum CustomContextMenuItemType {
67 // Container for information about the form renderer id from where the context
68 // menu was triggered.
69 // autofill::FormRendererId
70 struct FormRendererId {
74 // Container for information about the field renderer id where the context menu
76 // autofill::FieldRendererId
77 struct FieldRendererId {
81 // Container for information about entries in an HTML select popup menu and
82 // custom entries of the context menu.
83 // TODO(crbug.com/1093904): Consider merging the MenuItem struct in
85 struct CustomContextMenuItem {
86 mojo_base.mojom.String16 label;
87 mojo_base.mojom.String16 icon;
88 mojo_base.mojom.String16 tool_tip;
89 CustomContextMenuItemType type;
92 bool has_directional_override;
95 array<CustomContextMenuItem> submenu;
98 // Mojo struct to represent blink::UntrustworthyContextMenuParams native struct.
99 struct UntrustworthyContextMenuParams {
100 // This is the type of Context Node that the context menu was invoked on.
101 ContextMenuDataMediaType media_type;
103 // These values represent the coordinates of the mouse when the context menu
104 // was invoked. Coords are relative to the associated RenderView's origin.
108 // This is the URL of the link that encloses the node the context menu was
110 url.mojom.Url link_url;
112 // The text associated with the link. May be an empty string if the contents
113 // of the link are an image.
114 // Will be empty if |link_url| is empty.
115 mojo_base.mojom.String16 link_text;
117 // The impression declared by the link. May be absl::nullopt even if
118 // |link_url| is non-empty.
119 Impression? impression;
121 // The link URL to be used ONLY for "copy link address". We don't validate
122 // this field in the frontend process.
123 url.mojom.Url unfiltered_link_url;
125 // This is the source URL for the element that the context menu was
126 // invoked on. Example of elements with source URLs are img, audio, and
128 url.mojom.Url src_url;
130 // This is true if the context menu was invoked on an image which has
131 // non-empty contents.
132 bool has_image_contents;
134 // These are the parameters for the media element that the context menu
138 // This is the text of the selection that the context menu was invoked on.
139 mojo_base.mojom.String16 selection_text;
141 // This is the title text of the selection that the context menu was
143 mojo_base.mojom.String16 title_text;
145 // This is the alt text of the selection that the context menu was
147 mojo_base.mojom.String16 alt_text;
149 // This is the suggested filename to be used when saving file through "Save
150 // Link As" option of context menu.
151 mojo_base.mojom.String16 suggested_filename;
153 // The misspelled word under the cursor, if any. Used to generate the
154 // |dictionary_suggestions| list.
155 mojo_base.mojom.String16 misspelled_word;
157 // Suggested replacements for a misspelled word under the cursor.
158 // This vector gets populated in the render process host
159 // by intercepting ViewHostMsg_ContextMenu in ResourceMessageFilter
160 // and populating dictionary_suggestions if the type is EDITABLE
161 // and the misspelled_word is not empty.
162 array<mojo_base.mojom.String16> dictionary_suggestions;
164 // If editable, flag for whether spell check is enabled or not.
165 bool spellcheck_enabled;
167 // Whether context is editable.
170 // Whether element is text
174 // Writing direction menu items.
175 int32 writing_direction_default;
176 int32 writing_direction_left_to_right;
177 int32 writing_direction_right_to_left;
179 // These flags indicate to the browser whether the renderer believes it is
180 // able to perform the corresponding action.
183 // The character encoding of the frame on which the menu is invoked.
184 string frame_charset;
186 // The referrer policy of the frame on which the menu is invoked.
187 network.mojom.ReferrerPolicy referrer_policy;
189 // If the context menu was created for a link, and we navigated to that url,
190 // this will contain the url that was navigated. This field may not be set
191 // if, for example, we are transitioning to an incognito window, since we
192 // want to sever any connection to the old renderer.
193 url.mojom.Url link_followed;
195 array<CustomContextMenuItem> custom_items;
197 ui.mojom.MenuSourceType source_type;
199 // If this node is an input field, the type of that field.
200 ContextMenuDataInputFieldType input_field_type;
202 // Rect representing the coordinates in the document space of the selection.
203 gfx.mojom.Rect selection_rect;
205 // Start position of the selection text.
206 int32 selection_start_offset;
208 // Whether the context contains text highlighted by a text fragment.
209 // See TextFragmentAnchor.
210 bool opened_from_highlight;
212 // The renderer id of the form that contains the input or textarea field.
213 // Not set if the initiating field is not an input or textarea field.
214 FormRendererId? form_renderer_id;
216 // The renderer id of the input or textarea field from where the context menu
217 // is opened. Not set if it is not an input or text area field.
218 FieldRendererId? field_renderer_id;
221 // Defines methods for Context menu to commnicate from the renderer to the
223 interface ContextMenuClient {
224 // Executes custom context menu action that was provided from Blink.
225 CustomContextMenuAction(uint32 action);
227 // Called in response to a blink.mojom.ShowContextMenu to let the renderer
228 // know that the menu has been closed.
229 ContextMenuClosed(url.mojom.Url link_followed);