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_BROWSER_CAPI_H_
38 #define CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
41 #include "include/capi/cef_base_capi.h"
42 #include "include/capi/cef_drag_data_capi.h"
43 #include "include/capi/cef_frame_capi.h"
44 #include "include/capi/cef_navigation_entry_capi.h"
45 #include "include/capi/cef_process_message_capi.h"
46 #include "include/capi/cef_request_context_capi.h"
52 struct _cef_browser_host_t;
56 // Structure used to represent a browser window. When used in the browser
57 // process the functions of this structure may be called on any thread unless
58 // otherwise indicated in the comments. When used in the render process the
59 // functions of this structure may only be called on the main thread.
61 typedef struct _cef_browser_t {
68 // Returns the browser host object. This function can only be called in the
71 struct _cef_browser_host_t* (CEF_CALLBACK *get_host)(
72 struct _cef_browser_t* self);
75 // Returns true (1) if the browser can navigate backwards.
77 int (CEF_CALLBACK *can_go_back)(struct _cef_browser_t* self);
80 // Navigate backwards.
82 void (CEF_CALLBACK *go_back)(struct _cef_browser_t* self);
85 // Returns true (1) if the browser can navigate forwards.
87 int (CEF_CALLBACK *can_go_forward)(struct _cef_browser_t* self);
92 void (CEF_CALLBACK *go_forward)(struct _cef_browser_t* self);
95 // Returns true (1) if the browser is currently loading.
97 int (CEF_CALLBACK *is_loading)(struct _cef_browser_t* self);
100 // Reload the current page.
102 void (CEF_CALLBACK *reload)(struct _cef_browser_t* self);
105 // Reload the current page ignoring any cached data.
107 void (CEF_CALLBACK *reload_ignore_cache)(struct _cef_browser_t* self);
110 // Stop loading the page.
112 void (CEF_CALLBACK *stop_load)(struct _cef_browser_t* self);
115 // Returns the globally unique identifier for this browser.
117 int (CEF_CALLBACK *get_identifier)(struct _cef_browser_t* self);
120 // Returns true (1) if this object is pointing to the same handle as |that|
123 int (CEF_CALLBACK *is_same)(struct _cef_browser_t* self,
124 struct _cef_browser_t* that);
127 // Returns true (1) if the window is a popup window.
129 int (CEF_CALLBACK *is_popup)(struct _cef_browser_t* self);
132 // Returns true (1) if a document has been loaded in the browser.
134 int (CEF_CALLBACK *has_document)(struct _cef_browser_t* self);
137 // Returns the main (top-level) frame for the browser window.
139 struct _cef_frame_t* (CEF_CALLBACK *get_main_frame)(
140 struct _cef_browser_t* self);
143 // Returns the focused frame for the browser window.
145 struct _cef_frame_t* (CEF_CALLBACK *get_focused_frame)(
146 struct _cef_browser_t* self);
149 // Returns the frame with the specified identifier, or NULL if not found.
151 struct _cef_frame_t* (CEF_CALLBACK *get_frame_byident)(
152 struct _cef_browser_t* self, int64 identifier);
155 // Returns the frame with the specified name, or NULL if not found.
157 struct _cef_frame_t* (CEF_CALLBACK *get_frame)(struct _cef_browser_t* self,
158 const cef_string_t* name);
161 // Returns the number of frames that currently exist.
163 size_t (CEF_CALLBACK *get_frame_count)(struct _cef_browser_t* self);
166 // Returns the identifiers of all existing frames.
168 void (CEF_CALLBACK *get_frame_identifiers)(struct _cef_browser_t* self,
169 size_t* identifiersCount, int64* identifiers);
172 // Returns the names of all existing frames.
174 void (CEF_CALLBACK *get_frame_names)(struct _cef_browser_t* self,
175 cef_string_list_t names);
178 // Send a message to the specified |target_process|. Returns true (1) if the
179 // message was sent successfully.
181 int (CEF_CALLBACK *send_process_message)(struct _cef_browser_t* self,
182 cef_process_id_t target_process,
183 struct _cef_process_message_t* message);
188 // Callback structure for cef_browser_host_t::RunFileDialog. The functions of
189 // this structure will be called on the browser process UI thread.
191 typedef struct _cef_run_file_dialog_callback_t {
198 // Called asynchronously after the file dialog is dismissed.
199 // |selected_accept_filter| is the 0-based index of the value selected from
200 // the accept filters array passed to cef_browser_host_t::RunFileDialog.
201 // |file_paths| will be a single value or a list of values depending on the
202 // dialog mode. If the selection was cancelled |file_paths| will be NULL.
204 void (CEF_CALLBACK *on_file_dialog_dismissed)(
205 struct _cef_run_file_dialog_callback_t* self, int selected_accept_filter,
206 cef_string_list_t file_paths);
207 } cef_run_file_dialog_callback_t;
211 // Callback structure for cef_browser_host_t::GetNavigationEntries. The
212 // functions of this structure will be called on the browser process UI thread.
214 typedef struct _cef_navigation_entry_visitor_t {
221 // Method that will be executed. Do not keep a reference to |entry| outside of
222 // this callback. Return true (1) to continue visiting entries or false (0) to
223 // stop. |current| is true (1) if this entry is the currently loaded
224 // navigation entry. |index| is the 0-based index of this entry and |total| is
225 // the total number of entries.
227 int (CEF_CALLBACK *visit)(struct _cef_navigation_entry_visitor_t* self,
228 struct _cef_navigation_entry_t* entry, int current, int index,
230 } cef_navigation_entry_visitor_t;
234 // Structure used to represent the browser process aspects of a browser window.
235 // The functions of this structure can only be called in the browser process.
236 // They may be called on any thread in that process unless otherwise indicated
239 typedef struct _cef_browser_host_t {
246 // Returns the hosted browser object.
248 struct _cef_browser_t* (CEF_CALLBACK *get_browser)(
249 struct _cef_browser_host_t* self);
252 // Request that the browser close. The JavaScript 'onbeforeunload' event will
253 // be fired. If |force_close| is false (0) the event handler, if any, will be
254 // allowed to prompt the user and the user can optionally cancel the close. If
255 // |force_close| is true (1) the prompt will not be displayed and the close
256 // will proceed. Results in a call to cef_life_span_handler_t::do_close() if
257 // the event handler allows the close or if |force_close| is true (1). See
258 // cef_life_span_handler_t::do_close() documentation for additional usage
261 void (CEF_CALLBACK *close_browser)(struct _cef_browser_host_t* self,
265 // Set whether the browser is focused.
267 void (CEF_CALLBACK *set_focus)(struct _cef_browser_host_t* self, int focus);
270 // Set whether the window containing the browser is visible
271 // (minimized/unminimized, app hidden/unhidden, etc). Only used on Mac OS X.
273 void (CEF_CALLBACK *set_window_visibility)(struct _cef_browser_host_t* self,
277 // Retrieve the window handle for this browser.
279 cef_window_handle_t (CEF_CALLBACK *get_window_handle)(
280 struct _cef_browser_host_t* self);
283 // Retrieve the window handle of the browser that opened this browser. Will
284 // return NULL for non-popup windows. This function can be used in combination
285 // with custom handling of modal windows.
287 cef_window_handle_t (CEF_CALLBACK *get_opener_window_handle)(
288 struct _cef_browser_host_t* self);
291 // Returns the client for this browser.
293 struct _cef_client_t* (CEF_CALLBACK *get_client)(
294 struct _cef_browser_host_t* self);
297 // Returns the request context for this browser.
299 struct _cef_request_context_t* (CEF_CALLBACK *get_request_context)(
300 struct _cef_browser_host_t* self);
303 // Get the current zoom level. The default zoom level is 0.0. This function
304 // can only be called on the UI thread.
306 double (CEF_CALLBACK *get_zoom_level)(struct _cef_browser_host_t* self);
309 // Change the zoom level to the specified value. Specify 0.0 to reset the zoom
310 // level. If called on the UI thread the change will be applied immediately.
311 // Otherwise, the change will be applied asynchronously on the UI thread.
313 void (CEF_CALLBACK *set_zoom_level)(struct _cef_browser_host_t* self,
317 // Call to run a file chooser dialog. Only a single file chooser dialog may be
318 // pending at any given time. |mode| represents the type of dialog to display.
319 // |title| to the title to be used for the dialog and may be NULL to show the
320 // default title ("Open" or "Save" depending on the mode). |default_file_path|
321 // is the path with optional directory and/or file name component that will be
322 // initially selected in the dialog. |accept_filters| are used to restrict the
323 // selectable file types and may any combination of (a) valid lower-cased MIME
324 // types (e.g. "text/*" or "image/*"), (b) individual file extensions (e.g.
325 // ".txt" or ".png"), or (c) combined description and file extension delimited
326 // using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg").
327 // |selected_accept_filter| is the 0-based index of the filter that will be
328 // selected by default. |callback| will be executed after the dialog is
329 // dismissed or immediately if another dialog is already pending. The dialog
330 // will be initiated asynchronously on the UI thread.
332 void (CEF_CALLBACK *run_file_dialog)(struct _cef_browser_host_t* self,
333 cef_file_dialog_mode_t mode, const cef_string_t* title,
334 const cef_string_t* default_file_path, cef_string_list_t accept_filters,
335 int selected_accept_filter,
336 struct _cef_run_file_dialog_callback_t* callback);
339 // Download the file at |url| using cef_download_handler_t.
341 void (CEF_CALLBACK *start_download)(struct _cef_browser_host_t* self,
342 const cef_string_t* url);
345 // Print the current browser contents.
347 void (CEF_CALLBACK *print)(struct _cef_browser_host_t* self);
350 // Search for |searchText|. |identifier| can be used to have multiple searches
351 // running simultaniously. |forward| indicates whether to search forward or
352 // backward within the page. |matchCase| indicates whether the search should
353 // be case-sensitive. |findNext| indicates whether this is the first request
354 // or a follow-up. The cef_find_handler_t instance, if any, returned via
355 // cef_client_t::GetFindHandler will be called to report find results.
357 void (CEF_CALLBACK *find)(struct _cef_browser_host_t* self, int identifier,
358 const cef_string_t* searchText, int forward, int matchCase,
362 // Cancel all searches that are currently going on.
364 void (CEF_CALLBACK *stop_finding)(struct _cef_browser_host_t* self,
368 // Open developer tools in its own window. If |inspect_element_at| is non-
369 // NULL the element at the specified (x,y) location will be inspected.
371 void (CEF_CALLBACK *show_dev_tools)(struct _cef_browser_host_t* self,
372 const struct _cef_window_info_t* windowInfo,
373 struct _cef_client_t* client,
374 const struct _cef_browser_settings_t* settings,
375 const cef_point_t* inspect_element_at);
378 // Explicitly close the developer tools window if one exists for this browser
381 void (CEF_CALLBACK *close_dev_tools)(struct _cef_browser_host_t* self);
384 // Retrieve a snapshot of current navigation entries as values sent to the
385 // specified visitor. If |current_only| is true (1) only the current
386 // navigation entry will be sent, otherwise all navigation entries will be
390 void (CEF_CALLBACK *get_navigation_entries)(struct _cef_browser_host_t* self,
391 struct _cef_navigation_entry_visitor_t* visitor, int current_only);
394 // Set whether mouse cursor change is disabled.
396 void (CEF_CALLBACK *set_mouse_cursor_change_disabled)(
397 struct _cef_browser_host_t* self, int disabled);
400 // Returns true (1) if mouse cursor change is disabled.
402 int (CEF_CALLBACK *is_mouse_cursor_change_disabled)(
403 struct _cef_browser_host_t* self);
406 // If a misspelled word is currently selected in an editable node calling this
407 // function will replace it with the specified |word|.
409 void (CEF_CALLBACK *replace_misspelling)(struct _cef_browser_host_t* self,
410 const cef_string_t* word);
413 // Add the specified |word| to the spelling dictionary.
415 void (CEF_CALLBACK *add_word_to_dictionary)(struct _cef_browser_host_t* self,
416 const cef_string_t* word);
419 // Returns true (1) if window rendering is disabled.
421 int (CEF_CALLBACK *is_window_rendering_disabled)(
422 struct _cef_browser_host_t* self);
425 // Notify the browser that the widget has been resized. The browser will first
426 // call cef_render_handler_t::GetViewRect to get the new size and then call
427 // cef_render_handler_t::OnPaint asynchronously with the updated regions. This
428 // function is only used when window rendering is disabled.
430 void (CEF_CALLBACK *was_resized)(struct _cef_browser_host_t* self);
433 // Notify the browser that it has been hidden or shown. Layouting and
434 // cef_render_handler_t::OnPaint notification will stop when the browser is
435 // hidden. This function is only used when window rendering is disabled.
437 void (CEF_CALLBACK *was_hidden)(struct _cef_browser_host_t* self, int hidden);
440 // Send a notification to the browser that the screen info has changed. The
441 // browser will then call cef_render_handler_t::GetScreenInfo to update the
442 // screen information with the new values. This simulates moving the webview
443 // window from one display to another, or changing the properties of the
444 // current display. This function is only used when window rendering is
447 void (CEF_CALLBACK *notify_screen_info_changed)(
448 struct _cef_browser_host_t* self);
451 // Invalidate the view. The browser will call cef_render_handler_t::OnPaint
452 // asynchronously. This function is only used when window rendering is
455 void (CEF_CALLBACK *invalidate)(struct _cef_browser_host_t* self,
456 cef_paint_element_type_t type);
459 // Send a key event to the browser.
461 void (CEF_CALLBACK *send_key_event)(struct _cef_browser_host_t* self,
462 const struct _cef_key_event_t* event);
465 // Send a mouse click event to the browser. The |x| and |y| coordinates are
466 // relative to the upper-left corner of the view.
468 void (CEF_CALLBACK *send_mouse_click_event)(struct _cef_browser_host_t* self,
469 const struct _cef_mouse_event_t* event, cef_mouse_button_type_t type,
470 int mouseUp, int clickCount);
473 // Send a mouse move event to the browser. The |x| and |y| coordinates are
474 // relative to the upper-left corner of the view.
476 void (CEF_CALLBACK *send_mouse_move_event)(struct _cef_browser_host_t* self,
477 const struct _cef_mouse_event_t* event, int mouseLeave);
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 // cef_render_handler_t::GetScreenPoint should be implemented properly.
486 void (CEF_CALLBACK *send_mouse_wheel_event)(struct _cef_browser_host_t* self,
487 const struct _cef_mouse_event_t* event, int deltaX, int deltaY);
490 // Send a focus event to the browser.
492 void (CEF_CALLBACK *send_focus_event)(struct _cef_browser_host_t* self,
496 // Send a capture lost event to the browser.
498 void (CEF_CALLBACK *send_capture_lost_event)(
499 struct _cef_browser_host_t* self);
502 // Notify the browser that the window hosting it is about to be moved or
503 // resized. This function is only used on Windows and Linux.
505 void (CEF_CALLBACK *notify_move_or_resize_started)(
506 struct _cef_browser_host_t* self);
509 // Get the NSTextInputContext implementation for enabling IME on Mac when
510 // window rendering is disabled.
512 cef_text_input_context_t (CEF_CALLBACK *get_nstext_input_context)(
513 struct _cef_browser_host_t* self);
516 // Handles a keyDown event prior to passing it through the NSTextInputClient
519 void (CEF_CALLBACK *handle_key_event_before_text_input_client)(
520 struct _cef_browser_host_t* self, cef_event_handle_t keyEvent);
523 // Performs any additional actions after NSTextInputClient handles the event.
525 void (CEF_CALLBACK *handle_key_event_after_text_input_client)(
526 struct _cef_browser_host_t* self, cef_event_handle_t keyEvent);
529 // Call this function when the user drags the mouse into the web view (before
530 // calling DragTargetDragOver/DragTargetLeave/DragTargetDrop). |drag_data|
531 // should not contain file contents as this type of data is not allowed to be
532 // dragged into the web view. File contents can be removed using
533 // cef_drag_data_t::ResetFileContents (for example, if |drag_data| comes from
534 // cef_render_handler_t::StartDragging). This function is only used when
535 // window rendering is disabled.
537 void (CEF_CALLBACK *drag_target_drag_enter)(struct _cef_browser_host_t* self,
538 struct _cef_drag_data_t* drag_data,
539 const struct _cef_mouse_event_t* event,
540 cef_drag_operations_mask_t allowed_ops);
543 // Call this function each time the mouse is moved across the web view during
544 // a drag operation (after calling DragTargetDragEnter and before calling
545 // DragTargetDragLeave/DragTargetDrop). This function is only used when window
546 // rendering is disabled.
548 void (CEF_CALLBACK *drag_target_drag_over)(struct _cef_browser_host_t* self,
549 const struct _cef_mouse_event_t* event,
550 cef_drag_operations_mask_t allowed_ops);
553 // Call this function when the user drags the mouse out of the web view (after
554 // calling DragTargetDragEnter). This function is only used when window
555 // rendering is disabled.
557 void (CEF_CALLBACK *drag_target_drag_leave)(struct _cef_browser_host_t* self);
560 // Call this function when the user completes the drag operation by dropping
561 // the object onto the web view (after calling DragTargetDragEnter). The
562 // object being dropped is |drag_data|, given as an argument to the previous
563 // DragTargetDragEnter call. This function is only used when window rendering
566 void (CEF_CALLBACK *drag_target_drop)(struct _cef_browser_host_t* self,
567 const struct _cef_mouse_event_t* event);
570 // Call this function when the drag operation started by a
571 // cef_render_handler_t::StartDragging call has ended either in a drop or by
572 // being cancelled. |x| and |y| are mouse coordinates relative to the upper-
573 // left corner of the view. If the web view is both the drag source and the
574 // drag target then all DragTarget* functions should be called before
575 // DragSource* mthods. This function is only used when window rendering is
578 void (CEF_CALLBACK *drag_source_ended_at)(struct _cef_browser_host_t* self,
579 int x, int y, cef_drag_operations_mask_t op);
582 // Call this function when the drag operation started by a
583 // cef_render_handler_t::StartDragging call has completed. This function may
584 // be called immediately without first calling DragSourceEndedAt to cancel a
585 // drag operation. If the web view is both the drag source and the drag target
586 // then all DragTarget* functions should be called before DragSource* mthods.
587 // This function is only used when window rendering is disabled.
589 void (CEF_CALLBACK *drag_source_system_drag_ended)(
590 struct _cef_browser_host_t* self);
591 } cef_browser_host_t;
595 // Create a new browser window using the window parameters specified by
596 // |windowInfo|. All values will be copied internally and the actual window will
597 // be created on the UI thread. If |request_context| is NULL the global request
598 // context will be used. This function can be called on any browser process
599 // thread and will not block.
601 CEF_EXPORT int cef_browser_host_create_browser(
602 const cef_window_info_t* windowInfo, struct _cef_client_t* client,
603 const cef_string_t* url, const struct _cef_browser_settings_t* settings,
604 struct _cef_request_context_t* request_context);
607 // Create a new browser window using the window parameters specified by
608 // |windowInfo|. If |request_context| is NULL the global request context will be
609 // used. This function can only be called on the browser process UI thread.
611 CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync(
612 const cef_window_info_t* windowInfo, struct _cef_client_t* client,
613 const cef_string_t* url, const struct _cef_browser_settings_t* settings,
614 struct _cef_request_context_t* request_context);
621 #endif // CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_