1 // Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
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
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.
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.
30 // ---------------------------------------------------------------------------
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
37 #ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
38 #define CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
41 #include "include/capi/cef_base_capi.h"
42 #include "include/capi/cef_browser_capi.h"
43 #include "include/capi/cef_frame_capi.h"
44 #include "include/capi/cef_menu_model_capi.h"
50 struct _cef_context_menu_params_t;
53 // Implement this structure to handle context menu events. The functions of this
54 // structure will be called on the UI thread.
56 typedef struct _cef_context_menu_handler_t {
63 // Called before a context menu is displayed. |params| provides information
64 // about the context menu state. |model| initially contains the default
65 // context menu. The |model| can be cleared to show no context menu or
66 // modified to show a custom menu. Do not keep references to |params| or
67 // |model| outside of this callback.
69 void (CEF_CALLBACK *on_before_context_menu)(
70 struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser,
71 struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params,
72 struct _cef_menu_model_t* model);
75 // Called to execute a command selected from the context menu. Return true (1)
76 // if the command was handled or false (0) for the default implementation. See
77 // cef_menu_id_t for the command ids that have default implementations. All
78 // user-defined command ids should be between MENU_ID_USER_FIRST and
79 // MENU_ID_USER_LAST. |params| will have the same values as what was passed to
80 // on_before_context_menu(). Do not keep a reference to |params| outside of
83 int (CEF_CALLBACK *on_context_menu_command)(
84 struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser,
85 struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params,
86 int command_id, cef_event_flags_t event_flags);
89 // Called when the context menu is dismissed irregardless of whether the menu
90 // was NULL or a command was selected.
92 void (CEF_CALLBACK *on_context_menu_dismissed)(
93 struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser,
94 struct _cef_frame_t* frame);
95 } cef_context_menu_handler_t;
99 // Provides information about the context menu state. The ethods of this
100 // structure can only be accessed on browser process the UI thread.
102 typedef struct _cef_context_menu_params_t {
109 // Returns the X coordinate of the mouse where the context menu was invoked.
110 // Coords are relative to the associated RenderView's origin.
112 int (CEF_CALLBACK *get_xcoord)(struct _cef_context_menu_params_t* self);
115 // Returns the Y coordinate of the mouse where the context menu was invoked.
116 // Coords are relative to the associated RenderView's origin.
118 int (CEF_CALLBACK *get_ycoord)(struct _cef_context_menu_params_t* self);
121 // Returns flags representing the type of node that the context menu was
124 cef_context_menu_type_flags_t (CEF_CALLBACK *get_type_flags)(
125 struct _cef_context_menu_params_t* self);
128 // Returns the URL of the link, if any, that encloses the node that the
129 // context menu was invoked on.
131 // The resulting string must be freed by calling cef_string_userfree_free().
132 cef_string_userfree_t (CEF_CALLBACK *get_link_url)(
133 struct _cef_context_menu_params_t* self);
136 // Returns the link URL, if any, to be used ONLY for "copy link address". We
137 // don't validate this field in the frontend process.
139 // The resulting string must be freed by calling cef_string_userfree_free().
140 cef_string_userfree_t (CEF_CALLBACK *get_unfiltered_link_url)(
141 struct _cef_context_menu_params_t* self);
144 // Returns the source URL, if any, for the element that the context menu was
145 // invoked on. Example of elements with source URLs are img, audio, and video.
147 // The resulting string must be freed by calling cef_string_userfree_free().
148 cef_string_userfree_t (CEF_CALLBACK *get_source_url)(
149 struct _cef_context_menu_params_t* self);
152 // Returns true (1) if the context menu was invoked on an image which has non-
155 int (CEF_CALLBACK *has_image_contents)(
156 struct _cef_context_menu_params_t* self);
159 // Returns the URL of the top level page that the context menu was invoked on.
161 // The resulting string must be freed by calling cef_string_userfree_free().
162 cef_string_userfree_t (CEF_CALLBACK *get_page_url)(
163 struct _cef_context_menu_params_t* self);
166 // Returns the URL of the subframe that the context menu was invoked on.
168 // The resulting string must be freed by calling cef_string_userfree_free().
169 cef_string_userfree_t (CEF_CALLBACK *get_frame_url)(
170 struct _cef_context_menu_params_t* self);
173 // Returns the character encoding of the subframe that the context menu was
176 // The resulting string must be freed by calling cef_string_userfree_free().
177 cef_string_userfree_t (CEF_CALLBACK *get_frame_charset)(
178 struct _cef_context_menu_params_t* self);
181 // Returns the type of context node that the context menu was invoked on.
183 cef_context_menu_media_type_t (CEF_CALLBACK *get_media_type)(
184 struct _cef_context_menu_params_t* self);
187 // Returns flags representing the actions supported by the media element, if
188 // any, that the context menu was invoked on.
190 cef_context_menu_media_state_flags_t (CEF_CALLBACK *get_media_state_flags)(
191 struct _cef_context_menu_params_t* self);
194 // Returns the text of the selection, if any, that the context menu was
197 // The resulting string must be freed by calling cef_string_userfree_free().
198 cef_string_userfree_t (CEF_CALLBACK *get_selection_text)(
199 struct _cef_context_menu_params_t* self);
202 // Returns the text of the misspelled word, if any, that the context menu was
205 // The resulting string must be freed by calling cef_string_userfree_free().
206 cef_string_userfree_t (CEF_CALLBACK *get_misspelled_word)(
207 struct _cef_context_menu_params_t* self);
210 // Returns true (1) if suggestions exist, false (0) otherwise. Fills in
211 // |suggestions| from the spell check service for the misspelled word if there
214 int (CEF_CALLBACK *get_dictionary_suggestions)(
215 struct _cef_context_menu_params_t* self, cef_string_list_t suggestions);
218 // Returns true (1) if the context menu was invoked on an editable node.
220 int (CEF_CALLBACK *is_editable)(struct _cef_context_menu_params_t* self);
223 // Returns true (1) if the context menu was invoked on an editable node where
224 // spell-check is enabled.
226 int (CEF_CALLBACK *is_spell_check_enabled)(
227 struct _cef_context_menu_params_t* self);
230 // Returns flags representing the actions supported by the editable node, if
231 // any, that the context menu was invoked on.
233 cef_context_menu_edit_state_flags_t (CEF_CALLBACK *get_edit_state_flags)(
234 struct _cef_context_menu_params_t* self);
235 } cef_context_menu_params_t;
242 #endif // CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_