]> git.sesse.net Git - casparcg/blob - dependencies64/cef/include/cef_browser.h
* Added Linux support for html producer
[casparcg] / dependencies64 / cef / include / cef_browser.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_BROWSER_H_
38 #define CEF_INCLUDE_CEF_BROWSER_H_
39 #pragma once
40
41 #include "include/cef_base.h"
42 #include "include/cef_frame.h"
43 #include "include/cef_process_message.h"
44 #include "include/cef_request_context.h"
45 #include <vector>
46
47 class CefBrowserHost;
48 class CefClient;
49
50
51 ///
52 // Class used to represent a browser window. When used in the browser process
53 // the methods of this class may be called on any thread unless otherwise
54 // indicated in the comments. When used in the render process the methods of
55 // this class may only be called on the main thread.
56 ///
57 /*--cef(source=library)--*/
58 class CefBrowser : public virtual CefBase {
59  public:
60   ///
61   // Returns the browser host object. This method can only be called in the
62   // browser process.
63   ///
64   /*--cef()--*/
65   virtual CefRefPtr<CefBrowserHost> GetHost() =0;
66
67   ///
68   // Returns true if the browser can navigate backwards.
69   ///
70   /*--cef()--*/
71   virtual bool CanGoBack() =0;
72
73   ///
74   // Navigate backwards.
75   ///
76   /*--cef()--*/
77   virtual void GoBack() =0;
78
79   ///
80   // Returns true if the browser can navigate forwards.
81   ///
82   /*--cef()--*/
83   virtual bool CanGoForward() =0;
84
85   ///
86   // Navigate forwards.
87   ///
88   /*--cef()--*/
89   virtual void GoForward() =0;
90
91   ///
92   // Returns true if the browser is currently loading.
93   ///
94   /*--cef()--*/
95   virtual bool IsLoading() =0;
96
97   ///
98   // Reload the current page.
99   ///
100   /*--cef()--*/
101   virtual void Reload() =0;
102
103   ///
104   // Reload the current page ignoring any cached data.
105   ///
106   /*--cef()--*/
107   virtual void ReloadIgnoreCache() =0;
108
109   ///
110   // Stop loading the page.
111   ///
112   /*--cef()--*/
113   virtual void StopLoad() =0;
114
115   ///
116   // Returns the globally unique identifier for this browser.
117   ///
118   /*--cef()--*/
119   virtual int GetIdentifier() =0;
120
121   ///
122   // Returns true if this object is pointing to the same handle as |that|
123   // object.
124   ///
125   /*--cef()--*/
126   virtual bool IsSame(CefRefPtr<CefBrowser> that) =0;
127
128   ///
129   // Returns true if the window is a popup window.
130   ///
131   /*--cef()--*/
132   virtual bool IsPopup() =0;
133
134   ///
135   // Returns true if a document has been loaded in the browser.
136   ///
137   /*--cef()--*/
138   virtual bool HasDocument() =0;
139
140   ///
141   // Returns the main (top-level) frame for the browser window.
142   ///
143   /*--cef()--*/
144   virtual CefRefPtr<CefFrame> GetMainFrame() =0;
145
146   ///
147   // Returns the focused frame for the browser window.
148   ///
149   /*--cef()--*/
150   virtual CefRefPtr<CefFrame> GetFocusedFrame() =0;
151
152   ///
153   // Returns the frame with the specified identifier, or NULL if not found.
154   ///
155   /*--cef(capi_name=get_frame_byident)--*/
156   virtual CefRefPtr<CefFrame> GetFrame(int64 identifier) =0;
157
158   ///
159   // Returns the frame with the specified name, or NULL if not found.
160   ///
161   /*--cef()--*/
162   virtual CefRefPtr<CefFrame> GetFrame(const CefString& name) =0;
163
164   ///
165   // Returns the number of frames that currently exist.
166   ///
167   /*--cef()--*/
168   virtual size_t GetFrameCount() =0;
169
170   ///
171   // Returns the identifiers of all existing frames.
172   ///
173   /*--cef(count_func=identifiers:GetFrameCount)--*/
174   virtual void GetFrameIdentifiers(std::vector<int64>& identifiers) =0;
175
176   ///
177   // Returns the names of all existing frames.
178   ///
179   /*--cef()--*/
180   virtual void GetFrameNames(std::vector<CefString>& names) =0;
181
182   //
183   // Send a message to the specified |target_process|. Returns true if the
184   // message was sent successfully.
185   ///
186   /*--cef()--*/
187   virtual bool SendProcessMessage(CefProcessId target_process,
188                                   CefRefPtr<CefProcessMessage> message) =0;
189 };
190
191
192 ///
193 // Callback interface for CefBrowserHost::RunFileDialog. The methods of this
194 // class will be called on the browser process UI thread.
195 ///
196 /*--cef(source=client)--*/
197 class CefRunFileDialogCallback : public virtual CefBase {
198  public:
199   ///
200   // Called asynchronously after the file dialog is dismissed. If the selection
201   // was successful |file_paths| will be a single value or a list of values
202   // depending on the dialog mode. If the selection was cancelled |file_paths|
203   // will be empty.
204   ///
205   /*--cef(capi_name=cont)--*/
206   virtual void OnFileDialogDismissed(
207       CefRefPtr<CefBrowserHost> browser_host,
208       const std::vector<CefString>& file_paths) =0;
209 };
210
211
212 ///
213 // Class used to represent the browser process aspects of a browser window. The
214 // methods of this class can only be called in the browser process. They may be
215 // called on any thread in that process unless otherwise indicated in the
216 // comments.
217 ///
218 /*--cef(source=library)--*/
219 class CefBrowserHost : public virtual CefBase {
220  public:
221   typedef cef_file_dialog_mode_t FileDialogMode;
222   typedef cef_mouse_button_type_t MouseButtonType;
223   typedef cef_paint_element_type_t PaintElementType;
224
225   ///
226   // Create a new browser window using the window parameters specified by
227   // |windowInfo|. All values will be copied internally and the actual window
228   // will be created on the UI thread. If |request_context| is empty the
229   // global request context will be used. This method can be called on any
230   // browser process thread and will not block.
231   ///
232   /*--cef(optional_param=client,optional_param=url,
233           optional_param=request_context)--*/
234   static bool CreateBrowser(const CefWindowInfo& windowInfo,
235                             CefRefPtr<CefClient> client,
236                             const CefString& url,
237                             const CefBrowserSettings& settings,
238                             CefRefPtr<CefRequestContext> request_context);
239
240   ///
241   // Create a new browser window using the window parameters specified by
242   // |windowInfo|. If |request_context| is empty the global request context
243   // will be used. This method can only be called on the browser process UI
244   // thread.
245   ///
246   /*--cef(optional_param=client,optional_param=url,
247           optional_param=request_context)--*/
248   static CefRefPtr<CefBrowser> CreateBrowserSync(
249       const CefWindowInfo& windowInfo,
250       CefRefPtr<CefClient> client,
251       const CefString& url,
252       const CefBrowserSettings& settings,
253       CefRefPtr<CefRequestContext> request_context);
254
255   ///
256   // Returns the hosted browser object.
257   ///
258   /*--cef()--*/
259   virtual CefRefPtr<CefBrowser> GetBrowser() =0;
260
261   ///
262   // Call this method before destroying a contained browser window. This method
263   // performs any internal cleanup that may be needed before the browser window
264   // is destroyed. See CefLifeSpanHandler::DoClose() documentation for
265   // additional usage information.
266   ///
267   /*--cef()--*/
268   virtual void ParentWindowWillClose() =0;
269
270   ///
271   // Request that the browser close. The JavaScript 'onbeforeunload' event will
272   // be fired. If |force_close| is false the event handler, if any, will be
273   // allowed to prompt the user and the user can optionally cancel the close.
274   // If |force_close| is true the prompt will not be displayed and the close
275   // will proceed. Results in a call to CefLifeSpanHandler::DoClose() if the
276   // event handler allows the close or if |force_close| is true. See
277   // CefLifeSpanHandler::DoClose() documentation for additional usage
278   // information.
279   ///
280   /*--cef()--*/
281   virtual void CloseBrowser(bool force_close) =0;
282
283   ///
284   // Set whether the browser is focused.
285   ///
286   /*--cef()--*/
287   virtual void SetFocus(bool focus) =0;
288
289   ///
290   // Set whether the window containing the browser is visible
291   // (minimized/unminimized, app hidden/unhidden, etc). Only used on Mac OS X.
292   ///
293   /*--cef()--*/
294   virtual void SetWindowVisibility(bool visible) =0;
295
296   ///
297   // Retrieve the window handle for this browser.
298   ///
299   /*--cef()--*/
300   virtual CefWindowHandle GetWindowHandle() =0;
301
302   ///
303   // Retrieve the window handle of the browser that opened this browser. Will
304   // return NULL for non-popup windows. This method can be used in combination
305   // with custom handling of modal windows.
306   ///
307   /*--cef()--*/
308   virtual CefWindowHandle GetOpenerWindowHandle() =0;
309
310   ///
311   // Returns the client for this browser.
312   ///
313   /*--cef()--*/
314   virtual CefRefPtr<CefClient> GetClient() =0;
315
316   ///
317   // Returns the request context for this browser.
318   ///
319   /*--cef()--*/
320   virtual CefRefPtr<CefRequestContext> GetRequestContext() =0;
321
322   ///
323   // Get the current zoom level. The default zoom level is 0.0. This method can
324   // only be called on the UI thread.
325   ///
326   /*--cef()--*/
327   virtual double GetZoomLevel() =0;
328
329   ///
330   // Change the zoom level to the specified value. Specify 0.0 to reset the
331   // zoom level. If called on the UI thread the change will be applied
332   // immediately. Otherwise, the change will be applied asynchronously on the
333   // UI thread.
334   ///
335   /*--cef()--*/
336   virtual void SetZoomLevel(double zoomLevel) =0;
337
338   ///
339   // Call to run a file chooser dialog. Only a single file chooser dialog may be
340   // pending at any given time. |mode| represents the type of dialog to display.
341   // |title| to the title to be used for the dialog and may be empty to show the
342   // default title ("Open" or "Save" depending on the mode). |default_file_name|
343   // is the default file name to select in the dialog. |accept_types| is a list
344   // of valid lower-cased MIME types or file extensions specified in an input
345   // element and is used to restrict selectable files to such types. |callback|
346   // will be executed after the dialog is dismissed or immediately if another
347   // dialog is already pending. The dialog will be initiated asynchronously on
348   // the UI thread.
349   ///
350   /*--cef(optional_param=title,optional_param=default_file_name,
351           optional_param=accept_types)--*/
352   virtual void RunFileDialog(FileDialogMode mode,
353                              const CefString& title,
354                              const CefString& default_file_name,
355                              const std::vector<CefString>& accept_types,
356                              CefRefPtr<CefRunFileDialogCallback> callback) =0;
357
358   ///
359   // Download the file at |url| using CefDownloadHandler.
360   ///
361   /*--cef()--*/
362   virtual void StartDownload(const CefString& url) =0;
363
364   ///
365   // Print the current browser contents.
366   ///
367   /*--cef()--*/
368   virtual void Print() =0;
369
370   ///
371   // Search for |searchText|. |identifier| can be used to have multiple searches
372   // running simultaniously. |forward| indicates whether to search forward or
373   // backward within the page. |matchCase| indicates whether the search should
374   // be case-sensitive. |findNext| indicates whether this is the first request
375   // or a follow-up.
376   ///
377   /*--cef()--*/
378   virtual void Find(int identifier, const CefString& searchText,
379                     bool forward, bool matchCase, bool findNext) =0;
380
381   ///
382   // Cancel all searches that are currently going on.
383   ///
384   /*--cef()--*/
385   virtual void StopFinding(bool clearSelection) =0;
386
387   ///
388   // Open developer tools in its own window.
389   ///
390   /*--cef()--*/
391   virtual void ShowDevTools(const CefWindowInfo& windowInfo,
392                             CefRefPtr<CefClient> client,
393                             const CefBrowserSettings& settings) =0;
394
395   ///
396   // Explicitly close the developer tools window if one exists for this browser
397   // instance.
398   ///
399   /*--cef()--*/
400   virtual void CloseDevTools() =0;
401
402   ///
403   // Set whether mouse cursor change is disabled.
404   ///
405   /*--cef()--*/
406   virtual void SetMouseCursorChangeDisabled(bool disabled) =0;
407
408   ///
409   // Returns true if mouse cursor change is disabled.
410   ///
411   /*--cef()--*/
412   virtual bool IsMouseCursorChangeDisabled() =0;
413
414   ///
415   // Returns true if window rendering is disabled.
416   ///
417   /*--cef()--*/
418   virtual bool IsWindowRenderingDisabled() =0;
419
420   ///
421   // Notify the browser that the widget has been resized. The browser will first
422   // call CefRenderHandler::GetViewRect to get the new size and then call
423   // CefRenderHandler::OnPaint asynchronously with the updated regions. This
424   // method is only used when window rendering is disabled.
425   ///
426   /*--cef()--*/
427   virtual void WasResized() =0;
428
429   ///
430   // Notify the browser that it has been hidden or shown. Layouting and
431   // CefRenderHandler::OnPaint notification will stop when the browser is
432   // hidden. This method is only used when window rendering is disabled.
433   ///
434   /*--cef()--*/
435   virtual void WasHidden(bool hidden) =0;
436
437   ///
438   // Send a notification to the browser that the screen info has changed. The
439   // browser will then call CefRenderHandler::GetScreenInfo to update the
440   // screen information with the new values. This simulates moving the webview
441   // window from one display to another, or changing the properties of the
442   // current display. This method is only used when window rendering is
443   // disabled.
444   ///
445   /*--cef()--*/
446   virtual void NotifyScreenInfoChanged() =0;
447
448   ///
449   // Invalidate the |dirtyRect| region of the view. The browser will call
450   // CefRenderHandler::OnPaint asynchronously with the updated regions. This
451   // method is only used when window rendering is disabled.
452   ///
453   /*--cef()--*/
454   virtual void Invalidate(const CefRect& dirtyRect, PaintElementType type) =0;
455
456   ///
457   // Send a key event to the browser.
458   ///
459   /*--cef()--*/
460   virtual void SendKeyEvent(const CefKeyEvent& event) =0;
461
462   ///
463   // Send a mouse click event to the browser. The |x| and |y| coordinates are
464   // relative to the upper-left corner of the view.
465   ///
466   /*--cef()--*/
467   virtual void SendMouseClickEvent(const CefMouseEvent& event,
468                                    MouseButtonType type,
469                                    bool mouseUp, int clickCount) =0;
470
471   ///
472   // Send a mouse move event to the browser. The |x| and |y| coordinates are
473   // relative to the upper-left corner of the view.
474   ///
475   /*--cef()--*/
476   virtual void SendMouseMoveEvent(const CefMouseEvent& event,
477                                   bool mouseLeave) =0;
478
479   ///
480   // Send a mouse wheel event to the browser. The |x| and |y| coordinates are
481   // relative to the upper-left corner of the view. The |deltaX| and |deltaY|
482   // values represent the movement delta in the X and Y directions respectively.
483   // In order to scroll inside select popups with window rendering disabled
484   // CefRenderHandler::GetScreenPoint should be implemented properly.
485   ///
486   /*--cef()--*/
487   virtual void SendMouseWheelEvent(const CefMouseEvent& event,
488                                    int deltaX, int deltaY) =0;
489
490   ///
491   // Send a focus event to the browser.
492   ///
493   /*--cef()--*/
494   virtual void SendFocusEvent(bool setFocus) =0;
495
496   ///
497   // Send a capture lost event to the browser.
498   ///
499   /*--cef()--*/
500   virtual void SendCaptureLostEvent() =0;
501
502   ///
503   // Get the NSTextInputContext implementation for enabling IME on Mac when
504   // window rendering is disabled.
505   ///
506   /*--cef(default_retval=NULL)--*/
507   virtual CefTextInputContext GetNSTextInputContext() =0;
508
509   ///
510   // Handles a keyDown event prior to passing it through the NSTextInputClient
511   // machinery.
512   ///
513   /*--cef()--*/
514   virtual void HandleKeyEventBeforeTextInputClient(CefEventHandle keyEvent) =0;
515
516   ///
517   // Performs any additional actions after NSTextInputClient handles the event.
518   ///
519   /*--cef()--*/
520   virtual void HandleKeyEventAfterTextInputClient(CefEventHandle keyEvent) =0;
521 };
522
523 #endif  // CEF_INCLUDE_CEF_BROWSER_H_