]> git.sesse.net Git - casparcg/blob - dependencies64/cef/include/cef_context_menu_handler.h
* Merged html producer and updated to latest CEF version (does not have satisfactory...
[casparcg] / dependencies64 / cef / include / cef_context_menu_handler.h
1 // Copyright (c) 2012 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 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
35 //
36
37 #ifndef CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_
38 #define CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_
39 #pragma once
40
41 #include "include/cef_base.h"
42 #include "include/cef_browser.h"
43 #include "include/cef_frame.h"
44 #include "include/cef_menu_model.h"
45
46 class CefContextMenuParams;
47
48 ///
49 // Implement this interface to handle context menu events. The methods of this
50 // class will be called on the UI thread.
51 ///
52 /*--cef(source=client)--*/
53 class CefContextMenuHandler : public virtual CefBase {
54  public:
55   typedef cef_event_flags_t EventFlags;
56
57   ///
58   // Called before a context menu is displayed. |params| provides information
59   // about the context menu state. |model| initially contains the default
60   // context menu. The |model| can be cleared to show no context menu or
61   // modified to show a custom menu. Do not keep references to |params| or
62   // |model| outside of this callback.
63   ///
64   /*--cef()--*/
65   virtual void OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
66                                    CefRefPtr<CefFrame> frame,
67                                    CefRefPtr<CefContextMenuParams> params,
68                                    CefRefPtr<CefMenuModel> model) {}
69
70   ///
71   // Called to execute a command selected from the context menu. Return true if
72   // the command was handled or false for the default implementation. See
73   // cef_menu_id_t for the command ids that have default implementations. All
74   // user-defined command ids should be between MENU_ID_USER_FIRST and
75   // MENU_ID_USER_LAST. |params| will have the same values as what was passed to
76   // OnBeforeContextMenu(). Do not keep a reference to |params| outside of this
77   // callback.
78   ///
79   /*--cef()--*/
80   virtual bool OnContextMenuCommand(CefRefPtr<CefBrowser> browser,
81                                     CefRefPtr<CefFrame> frame,
82                                     CefRefPtr<CefContextMenuParams> params,
83                                     int command_id,
84                                     EventFlags event_flags) { return false; }
85
86   ///
87   // Called when the context menu is dismissed irregardless of whether the menu
88   // was empty or a command was selected.
89   ///
90   /*--cef()--*/
91   virtual void OnContextMenuDismissed(CefRefPtr<CefBrowser> browser,
92                                       CefRefPtr<CefFrame> frame) {}
93 };
94
95
96 ///
97 // Provides information about the context menu state. The ethods of this class
98 // can only be accessed on browser process the UI thread.
99 ///
100 /*--cef(source=library)--*/
101 class CefContextMenuParams : public virtual CefBase {
102  public:
103   typedef cef_context_menu_type_flags_t TypeFlags;
104   typedef cef_context_menu_media_type_t MediaType;
105   typedef cef_context_menu_media_state_flags_t MediaStateFlags;
106   typedef cef_context_menu_edit_state_flags_t EditStateFlags;
107
108   ///
109   // Returns the X coordinate of the mouse where the context menu was invoked.
110   // Coords are relative to the associated RenderView's origin.
111   ///
112   /*--cef()--*/
113   virtual int GetXCoord() =0;
114
115   ///
116   // Returns the Y coordinate of the mouse where the context menu was invoked.
117   // Coords are relative to the associated RenderView's origin.
118   ///
119   /*--cef()--*/
120   virtual int GetYCoord() =0;
121
122   ///
123   // Returns flags representing the type of node that the context menu was
124   // invoked on.
125   ///
126   /*--cef(default_retval=CM_TYPEFLAG_NONE)--*/
127   virtual TypeFlags GetTypeFlags() =0;
128
129   ///
130   // Returns the URL of the link, if any, that encloses the node that the
131   // context menu was invoked on.
132   ///
133   /*--cef()--*/
134   virtual CefString GetLinkUrl() =0;
135
136   ///
137   // Returns the link URL, if any, to be used ONLY for "copy link address". We
138   // don't validate this field in the frontend process.
139   ///
140   /*--cef()--*/
141   virtual CefString GetUnfilteredLinkUrl() =0;
142
143   ///
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.
146   ///
147   /*--cef()--*/
148   virtual CefString GetSourceUrl() =0;
149
150   ///
151   // Returns true if the context menu was invoked on an image which has
152   // non-empty contents.
153   ///
154   /*--cef()--*/
155   virtual bool HasImageContents() =0;
156
157   ///
158   // Returns the URL of the top level page that the context menu was invoked on.
159   ///
160   /*--cef()--*/
161   virtual CefString GetPageUrl() =0;
162
163   ///
164   // Returns the URL of the subframe that the context menu was invoked on.
165   ///
166   /*--cef()--*/
167   virtual CefString GetFrameUrl() =0;
168
169   ///
170   // Returns the character encoding of the subframe that the context menu was
171   // invoked on.
172   ///
173   /*--cef()--*/
174   virtual CefString GetFrameCharset() =0;
175
176   ///
177   // Returns the type of context node that the context menu was invoked on.
178   ///
179   /*--cef(default_retval=CM_MEDIATYPE_NONE)--*/
180   virtual MediaType GetMediaType() =0;
181
182   ///
183   // Returns flags representing the actions supported by the media element, if
184   // any, that the context menu was invoked on.
185   ///
186   /*--cef(default_retval=CM_MEDIAFLAG_NONE)--*/
187   virtual MediaStateFlags GetMediaStateFlags() =0;
188
189   ///
190   // Returns the text of the selection, if any, that the context menu was
191   // invoked on.
192   ///
193   /*--cef()--*/
194   virtual CefString GetSelectionText() =0;
195
196   ///
197   // Returns the text of the misspelled word, if any, that the context menu was
198   // invoked on.
199   ///
200   /*--cef()--*/
201   virtual CefString GetMisspelledWord() =0;
202
203   ///
204   // Returns true if suggestions exist, false otherwise. Fills in |suggestions|
205   // from the spell check service for the misspelled word if there is one.
206   ///
207   /*--cef()--*/
208   virtual bool GetDictionarySuggestions(std::vector<CefString>& suggestions) =0;
209
210   ///
211   // Returns true if the context menu was invoked on an editable node.
212   ///
213   /*--cef()--*/
214   virtual bool IsEditable() =0;
215
216   ///
217   // Returns true if the context menu was invoked on an editable node where
218   // spell-check is enabled.
219   ///
220   /*--cef()--*/
221   virtual bool IsSpellCheckEnabled() =0;
222
223   ///
224   // Returns flags representing the actions supported by the editable node, if
225   // any, that the context menu was invoked on.
226   ///
227   /*--cef(default_retval=CM_EDITFLAG_NONE)--*/
228   virtual EditStateFlags GetEditStateFlags() =0;
229 };
230
231 #endif  // CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_