• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // ---------------------------------------------------------------------------
31 //
32 // This file was generated by the CEF translator tool and should not edited
33 // by hand. See the translator.README.txt file in the tools directory for
34 // more information.
35 //
36 // $hash=fd33ce439e4379d231b6be16bdc1786f314d98e4$
37 //
38 
39 #ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
40 #define CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
41 #pragma once
42 
43 #include "include/capi/cef_base_capi.h"
44 #include "include/capi/cef_browser_capi.h"
45 #include "include/capi/cef_frame_capi.h"
46 #include "include/capi/cef_menu_model_capi.h"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 struct _cef_context_menu_params_t;
53 
54 ///
55 // Callback structure used for continuation of custom context menu display.
56 ///
57 typedef struct _cef_run_context_menu_callback_t {
58   ///
59   // Base structure.
60   ///
61   cef_base_ref_counted_t base;
62 
63   ///
64   // Complete context menu display by selecting the specified |command_id| and
65   // |event_flags|.
66   ///
67   void(CEF_CALLBACK* cont)(struct _cef_run_context_menu_callback_t* self,
68                            int command_id,
69                            cef_event_flags_t event_flags);
70 
71   ///
72   // Cancel context menu display.
73   ///
74   void(CEF_CALLBACK* cancel)(struct _cef_run_context_menu_callback_t* self);
75 } cef_run_context_menu_callback_t;
76 
77 ///
78 // Implement this structure to handle context menu events. The functions of this
79 // structure will be called on the UI thread.
80 ///
81 typedef struct _cef_context_menu_handler_t {
82   ///
83   // Base structure.
84   ///
85   cef_base_ref_counted_t base;
86 
87   ///
88   // Called before a context menu is displayed. |params| provides information
89   // about the context menu state. |model| initially contains the default
90   // context menu. The |model| can be cleared to show no context menu or
91   // modified to show a custom menu. Do not keep references to |params| or
92   // |model| outside of this callback.
93   ///
94   void(CEF_CALLBACK* on_before_context_menu)(
95       struct _cef_context_menu_handler_t* self,
96       struct _cef_browser_t* browser,
97       struct _cef_frame_t* frame,
98       struct _cef_context_menu_params_t* params,
99       struct _cef_menu_model_t* model);
100 
101   ///
102   // Called to allow custom display of the context menu. |params| provides
103   // information about the context menu state. |model| contains the context menu
104   // model resulting from OnBeforeContextMenu. For custom display return true
105   // (1) and execute |callback| either synchronously or asynchronously with the
106   // selected command ID. For default display return false (0). Do not keep
107   // references to |params| or |model| outside of this callback.
108   ///
109   int(CEF_CALLBACK* run_context_menu)(
110       struct _cef_context_menu_handler_t* self,
111       struct _cef_browser_t* browser,
112       struct _cef_frame_t* frame,
113       struct _cef_context_menu_params_t* params,
114       struct _cef_menu_model_t* model,
115       struct _cef_run_context_menu_callback_t* callback);
116 
117   ///
118   // Called to execute a command selected from the context menu. Return true (1)
119   // if the command was handled or false (0) for the default implementation. See
120   // cef_menu_id_t for the command ids that have default implementations. All
121   // user-defined command ids should be between MENU_ID_USER_FIRST and
122   // MENU_ID_USER_LAST. |params| will have the same values as what was passed to
123   // on_before_context_menu(). Do not keep a reference to |params| outside of
124   // this callback.
125   ///
126   int(CEF_CALLBACK* on_context_menu_command)(
127       struct _cef_context_menu_handler_t* self,
128       struct _cef_browser_t* browser,
129       struct _cef_frame_t* frame,
130       struct _cef_context_menu_params_t* params,
131       int command_id,
132       cef_event_flags_t event_flags);
133 
134   ///
135   // Called when the context menu is dismissed irregardless of whether the menu
136   // was NULL or a command was selected.
137   ///
138   void(CEF_CALLBACK* on_context_menu_dismissed)(
139       struct _cef_context_menu_handler_t* self,
140       struct _cef_browser_t* browser,
141       struct _cef_frame_t* frame);
142 } cef_context_menu_handler_t;
143 
144 ///
145 // Provides information about the context menu state. The ethods of this
146 // structure can only be accessed on browser process the UI thread.
147 ///
148 typedef struct _cef_context_menu_params_t {
149   ///
150   // Base structure.
151   ///
152   cef_base_ref_counted_t base;
153 
154   ///
155   // Returns the X coordinate of the mouse where the context menu was invoked.
156   // Coords are relative to the associated RenderView's origin.
157   ///
158   int(CEF_CALLBACK* get_xcoord)(struct _cef_context_menu_params_t* self);
159 
160   ///
161   // Returns the Y coordinate of the mouse where the context menu was invoked.
162   // Coords are relative to the associated RenderView's origin.
163   ///
164   int(CEF_CALLBACK* get_ycoord)(struct _cef_context_menu_params_t* self);
165 
166   ///
167   // Returns flags representing the type of node that the context menu was
168   // invoked on.
169   ///
170   cef_context_menu_type_flags_t(CEF_CALLBACK* get_type_flags)(
171       struct _cef_context_menu_params_t* self);
172 
173   ///
174   // Returns the URL of the link, if any, that encloses the node that the
175   // context menu was invoked on.
176   ///
177   // The resulting string must be freed by calling cef_string_userfree_free().
178   cef_string_userfree_t(CEF_CALLBACK* get_link_url)(
179       struct _cef_context_menu_params_t* self);
180 
181   ///
182   // Returns the link URL, if any, to be used ONLY for "copy link address". We
183   // don't validate this field in the frontend process.
184   ///
185   // The resulting string must be freed by calling cef_string_userfree_free().
186   cef_string_userfree_t(CEF_CALLBACK* get_unfiltered_link_url)(
187       struct _cef_context_menu_params_t* self);
188 
189   ///
190   // Returns the source URL, if any, for the element that the context menu was
191   // invoked on. Example of elements with source URLs are img, audio, and video.
192   ///
193   // The resulting string must be freed by calling cef_string_userfree_free().
194   cef_string_userfree_t(CEF_CALLBACK* get_source_url)(
195       struct _cef_context_menu_params_t* self);
196 
197   ///
198   // Returns true (1) if the context menu was invoked on an image which has non-
199   // NULL contents.
200   ///
201   int(CEF_CALLBACK* has_image_contents)(
202       struct _cef_context_menu_params_t* self);
203 
204   ///
205   // Returns the title text or the alt text if the context menu was invoked on
206   // an image.
207   ///
208   // The resulting string must be freed by calling cef_string_userfree_free().
209   cef_string_userfree_t(CEF_CALLBACK* get_title_text)(
210       struct _cef_context_menu_params_t* self);
211 
212   ///
213   // Returns the URL of the top level page that the context menu was invoked on.
214   ///
215   // The resulting string must be freed by calling cef_string_userfree_free().
216   cef_string_userfree_t(CEF_CALLBACK* get_page_url)(
217       struct _cef_context_menu_params_t* self);
218 
219   ///
220   // Returns the URL of the subframe that the context menu was invoked on.
221   ///
222   // The resulting string must be freed by calling cef_string_userfree_free().
223   cef_string_userfree_t(CEF_CALLBACK* get_frame_url)(
224       struct _cef_context_menu_params_t* self);
225 
226   ///
227   // Returns the character encoding of the subframe that the context menu was
228   // invoked on.
229   ///
230   // The resulting string must be freed by calling cef_string_userfree_free().
231   cef_string_userfree_t(CEF_CALLBACK* get_frame_charset)(
232       struct _cef_context_menu_params_t* self);
233 
234   ///
235   // Returns the type of context node that the context menu was invoked on.
236   ///
237   cef_context_menu_media_type_t(CEF_CALLBACK* get_media_type)(
238       struct _cef_context_menu_params_t* self);
239 
240   ///
241   // Returns flags representing the actions supported by the media element, if
242   // any, that the context menu was invoked on.
243   ///
244   cef_context_menu_media_state_flags_t(CEF_CALLBACK* get_media_state_flags)(
245       struct _cef_context_menu_params_t* self);
246 
247   ///
248   // Returns the text of the selection, if any, that the context menu was
249   // invoked on.
250   ///
251   // The resulting string must be freed by calling cef_string_userfree_free().
252   cef_string_userfree_t(CEF_CALLBACK* get_selection_text)(
253       struct _cef_context_menu_params_t* self);
254 
255   ///
256   // Returns the text of the misspelled word, if any, that the context menu was
257   // invoked on.
258   ///
259   // The resulting string must be freed by calling cef_string_userfree_free().
260   cef_string_userfree_t(CEF_CALLBACK* get_misspelled_word)(
261       struct _cef_context_menu_params_t* self);
262 
263   ///
264   // Returns true (1) if suggestions exist, false (0) otherwise. Fills in
265   // |suggestions| from the spell check service for the misspelled word if there
266   // is one.
267   ///
268   int(CEF_CALLBACK* get_dictionary_suggestions)(
269       struct _cef_context_menu_params_t* self,
270       cef_string_list_t suggestions);
271 
272   ///
273   // Returns true (1) if the context menu was invoked on an editable node.
274   ///
275   int(CEF_CALLBACK* is_editable)(struct _cef_context_menu_params_t* self);
276 
277   ///
278   // Returns true (1) if the context menu was invoked on an editable node where
279   // spell-check is enabled.
280   ///
281   int(CEF_CALLBACK* is_spell_check_enabled)(
282       struct _cef_context_menu_params_t* self);
283 
284   ///
285   // Returns flags representing the actions supported by the editable node, if
286   // any, that the context menu was invoked on.
287   ///
288   cef_context_menu_edit_state_flags_t(CEF_CALLBACK* get_edit_state_flags)(
289       struct _cef_context_menu_params_t* self);
290 
291   ///
292   // Returns true (1) if the context menu contains items specified by the
293   // renderer process (for example, plugin placeholder or pepper plugin menu
294   // items).
295   ///
296   int(CEF_CALLBACK* is_custom_menu)(struct _cef_context_menu_params_t* self);
297 } cef_context_menu_params_t;
298 
299 #ifdef __cplusplus
300 }
301 #endif
302 
303 #endif  // CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
304