update cef interfaces from upstream

This commit is contained in:
zmike 2015-09-14 14:02:35 -04:00
parent f749fe4125
commit 5f9aac6c1a
11 changed files with 364 additions and 35 deletions

View file

@ -942,6 +942,157 @@ impl CefWrap<*mut cef_navigation_entry_visitor_t> for Option<CefNavigationEntryV
}
//
// Callback structure for cef_browser_host_t::PrintToPDF. The functions of this
// structure will be called on the browser process UI thread.
//
#[repr(C)]
pub struct _cef_pdf_print_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Method that will be executed when the PDF printing has completed. |path| is
// the output path. |ok| will be true (1) if the printing completed
// successfully or false (0) otherwise.
//
pub on_pdf_print_finished: Option<extern "C" fn(
this: *mut cef_pdf_print_callback_t, path: *const types::cef_string_t,
ok: libc::c_int) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: u32,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_pdf_print_callback_t = _cef_pdf_print_callback_t;
//
// Callback structure for cef_browser_host_t::PrintToPDF. The functions of this
// structure will be called on the browser process UI thread.
//
pub struct CefPdfPrintCallback {
c_object: *mut cef_pdf_print_callback_t,
}
impl Clone for CefPdfPrintCallback {
fn clone(&self) -> CefPdfPrintCallback{
unsafe {
if !self.c_object.is_null() &&
self.c_object as usize != mem::POST_DROP_USIZE {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefPdfPrintCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefPdfPrintCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() &&
self.c_object as usize != mem::POST_DROP_USIZE {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefPdfPrintCallback {
pub unsafe fn from_c_object(c_object: *mut cef_pdf_print_callback_t) -> CefPdfPrintCallback {
CefPdfPrintCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_pdf_print_callback_t) -> CefPdfPrintCallback {
if !c_object.is_null() &&
c_object as usize != mem::POST_DROP_USIZE {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefPdfPrintCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_pdf_print_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_pdf_print_callback_t {
unsafe {
if !self.c_object.is_null() &&
self.c_object as usize != mem::POST_DROP_USIZE {
eutil::add_ref(self.c_object as *mut types::cef_base_t);
}
self.c_object
}
}
pub fn is_null_cef_object(&self) -> bool {
self.c_object.is_null() || self.c_object as usize == mem::POST_DROP_USIZE
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null() && self.c_object as usize != mem::POST_DROP_USIZE
}
//
// Method that will be executed when the PDF printing has completed. |path| is
// the output path. |ok| will be true (1) if the printing completed
// successfully or false (0) otherwise.
//
pub fn on_pdf_print_finished(&self, path: &[u16], ok: libc::c_int) -> () {
if self.c_object.is_null() ||
self.c_object as usize == mem::POST_DROP_USIZE {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_pdf_print_finished.unwrap())(
self.c_object,
CefWrap::to_c(path),
CefWrap::to_c(ok)))
}
}
}
impl CefWrap<*mut cef_pdf_print_callback_t> for CefPdfPrintCallback {
fn to_c(rust_object: CefPdfPrintCallback) -> *mut cef_pdf_print_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_pdf_print_callback_t) -> CefPdfPrintCallback {
CefPdfPrintCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_pdf_print_callback_t> for Option<CefPdfPrintCallback> {
fn to_c(rust_object: Option<CefPdfPrintCallback>) -> *mut cef_pdf_print_callback_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_pdf_print_callback_t) -> Option<CefPdfPrintCallback> {
if c_object.is_null() &&
c_object as usize != mem::POST_DROP_USIZE {
None
} else {
Some(CefPdfPrintCallback::from_c_object_addref(c_object))
}
}
}
//
// Structure used to represent the browser process aspects of a browser window.
// The functions of this structure can only be called in the browser process.
@ -1062,6 +1213,17 @@ pub struct _cef_browser_host_t {
//
pub print: Option<extern "C" fn(this: *mut cef_browser_host_t) -> ()>,
//
// Print the current browser contents to the PDF file specified by |path| and
// execute |callback| on completion. The caller is responsible for deleting
// |path| when done. For PDF printing to work on Linux you must implement the
// cef_print_handler_t::GetPdfPaperSize function.
//
pub print_to_pdf: Option<extern "C" fn(this: *mut cef_browser_host_t,
path: *const types::cef_string_t,
settings: *const interfaces::cef_pdf_print_settings_t,
callback: *mut interfaces::cef_pdf_print_callback_t) -> ()>,
//
// Search for |searchText|. |identifier| can be used to have multiple searches
// running simultaniously. |forward| indicates whether to search forward or
@ -1231,6 +1393,26 @@ pub struct _cef_browser_host_t {
pub notify_move_or_resize_started: Option<extern "C" fn(
this: *mut cef_browser_host_t) -> ()>,
//
// Returns the maximum rate in frames per second (fps) that
// cef_render_handler_t:: OnPaint will be called for a windowless browser. The
// actual fps may be lower if the browser cannot generate frames at the
// requested rate. The minimum value is 1 and the maximum value is 60 (default
// 30). This function can only be called on the UI thread.
//
pub get_windowless_frame_rate: Option<extern "C" fn(
this: *mut cef_browser_host_t) -> libc::c_int>,
//
// Set the maximum rate in frames per second (fps) that cef_render_handler_t::
// OnPaint will be called for a windowless browser. The actual fps may be
// lower if the browser cannot generate frames at the requested rate. The
// minimum value is 1 and the maximum value is 60 (default 30). Can also be
// set at browser creation via cef_browser_tSettings.windowless_frame_rate.
//
pub set_windowless_frame_rate: Option<extern "C" fn(
this: *mut cef_browser_host_t, frame_rate: libc::c_int) -> ()>,
//
// Get the NSTextInputContext implementation for enabling IME on Mac when
// window rendering is disabled.
@ -1657,6 +1839,29 @@ impl CefBrowserHost {
}
}
//
// Print the current browser contents to the PDF file specified by |path| and
// execute |callback| on completion. The caller is responsible for deleting
// |path| when done. For PDF printing to work on Linux you must implement the
// cef_print_handler_t::GetPdfPaperSize function.
//
pub fn print_to_pdf(&self, path: &[u16],
settings: &interfaces::CefPdfPrintSettings,
callback: interfaces::CefPdfPrintCallback) -> () {
if self.c_object.is_null() ||
self.c_object as usize == mem::POST_DROP_USIZE {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).print_to_pdf.unwrap())(
self.c_object,
CefWrap::to_c(path),
CefWrap::to_c(settings),
CefWrap::to_c(callback)))
}
}
//
// Search for |searchText|. |identifier| can be used to have multiple searches
// running simultaniously. |forward| indicates whether to search forward or
@ -2041,6 +2246,45 @@ impl CefBrowserHost {
}
}
//
// Returns the maximum rate in frames per second (fps) that
// cef_render_handler_t:: OnPaint will be called for a windowless browser. The
// actual fps may be lower if the browser cannot generate frames at the
// requested rate. The minimum value is 1 and the maximum value is 60 (default
// 30). This function can only be called on the UI thread.
//
pub fn get_windowless_frame_rate(&self) -> libc::c_int {
if self.c_object.is_null() ||
self.c_object as usize == mem::POST_DROP_USIZE {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_windowless_frame_rate.unwrap())(
self.c_object))
}
}
//
// Set the maximum rate in frames per second (fps) that cef_render_handler_t::
// OnPaint will be called for a windowless browser. The actual fps may be
// lower if the browser cannot generate frames at the requested rate. The
// minimum value is 1 and the maximum value is 60 (default 30). Can also be
// set at browser creation via cef_browser_tSettings.windowless_frame_rate.
//
pub fn set_windowless_frame_rate(&self, frame_rate: libc::c_int) -> () {
if self.c_object.is_null() ||
self.c_object as usize == mem::POST_DROP_USIZE {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_windowless_frame_rate.unwrap())(
self.c_object,
CefWrap::to_c(frame_rate)))
}
}
//
// Get the NSTextInputContext implementation for enabling IME on Mac when
// window rendering is disabled.

View file

@ -58,10 +58,10 @@ pub struct _cef_cookie_manager_t {
pub base: types::cef_base_t,
//
// Set the schemes supported by this manager. By default only "http" and
// "https" schemes are supported. If |callback| is non-NULL it will be
// executed asnychronously on the IO thread after the change has been applied.
// Must be called before any cookies are accessed.
// Set the schemes supported by this manager. The default schemes ("http",
// "https", "ws" and "wss") will always be supported. If |callback| is non-
// NULL it will be executed asnychronously on the IO thread after the change
// has been applied. Must be called before any cookies are accessed.
//
pub set_supported_schemes: Option<extern "C" fn(
this: *mut cef_cookie_manager_t, schemes: &types::cef_string_list_t,
@ -222,10 +222,10 @@ impl CefCookieManager {
}
//
// Set the schemes supported by this manager. By default only "http" and
// "https" schemes are supported. If |callback| is non-NULL it will be
// executed asnychronously on the IO thread after the change has been applied.
// Must be called before any cookies are accessed.
// Set the schemes supported by this manager. The default schemes ("http",
// "https", "ws" and "wss") will always be supported. If |callback| is non-
// NULL it will be executed asnychronously on the IO thread after the change
// has been applied. Must be called before any cookies are accessed.
//
pub fn set_supported_schemes(&self, schemes: &Vec<String>,
callback: interfaces::CefCompletionCallback) -> () {

View file

@ -79,6 +79,17 @@ pub struct _cef_display_handler_t {
this: *mut cef_display_handler_t, browser: *mut interfaces::cef_browser_t,
icon_urls: &types::cef_string_list_t) -> ()>,
//
// Called when web content in the page has toggled fullscreen mode. If
// |fullscreen| is true (1) the content will automatically be sized to fill
// the browser content area. If |fullscreen| is false (0) the content will
// automatically return to its original size and position. The client is
// responsible for resizing the browser if desired.
//
pub on_fullscreen_mode_change: Option<extern "C" fn(
this: *mut cef_display_handler_t, browser: *mut interfaces::cef_browser_t,
fullscreen: libc::c_int) -> ()>,
//
// Called when the browser is about to display a tooltip. |text| contains the
// text that will be displayed in the tooltip. To handle the display of the
@ -248,6 +259,28 @@ impl CefDisplayHandler {
}
}
//
// Called when web content in the page has toggled fullscreen mode. If
// |fullscreen| is true (1) the content will automatically be sized to fill
// the browser content area. If |fullscreen| is false (0) the content will
// automatically return to its original size and position. The client is
// responsible for resizing the browser if desired.
//
pub fn on_fullscreen_mode_change(&self, browser: interfaces::CefBrowser,
fullscreen: libc::c_int) -> () {
if self.c_object.is_null() ||
self.c_object as usize == mem::POST_DROP_USIZE {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_fullscreen_mode_change.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(fullscreen)))
}
}
//
// Called when the browser is about to display a tooltip. |text| contains the
// text that will be displayed in the tooltip. To handle the display of the

View file

@ -68,6 +68,18 @@ pub struct _cef_drag_handler_t {
dragData: *mut interfaces::cef_drag_data_t,
mask: types::cef_drag_operations_mask_t) -> libc::c_int>,
//
// Called whenever draggable regions for the browser window change. These can
// be specified using the '-webkit-app-region: drag/no-drag' CSS-property. If
// draggable regions are never defined in a document this function will also
// never be called. If the last draggable region is removed from a document
// this function will be called with an NULL vector.
//
pub on_draggable_regions_changed: Option<extern "C" fn(
this: *mut cef_drag_handler_t, browser: *mut interfaces::cef_browser_t,
regions_count: libc::size_t,
regions: *const types::cef_draggable_region_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
@ -175,6 +187,30 @@ impl CefDragHandler {
CefWrap::to_c(mask)))
}
}
//
// Called whenever draggable regions for the browser window change. These can
// be specified using the '-webkit-app-region: drag/no-drag' CSS-property. If
// draggable regions are never defined in a document this function will also
// never be called. If the last draggable region is removed from a document
// this function will be called with an NULL vector.
//
pub fn on_draggable_regions_changed(&self, browser: interfaces::CefBrowser,
regions_count: libc::size_t,
regions: *const types::cef_draggable_region_t) -> () {
if self.c_object.is_null() ||
self.c_object as usize == mem::POST_DROP_USIZE {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_draggable_regions_changed.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(regions_count),
CefWrap::to_c(regions)))
}
}
}
impl CefWrap<*mut cef_drag_handler_t> for CefDragHandler {

View file

@ -105,14 +105,6 @@ pub struct _cef_navigation_entry_t {
pub has_post_data: Option<extern "C" fn(
this: *mut cef_navigation_entry_t) -> libc::c_int>,
//
// Returns the name of the sub-frame that navigated or an NULL value if the
// main frame navigated.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_frame_name: Option<extern "C" fn(
this: *mut cef_navigation_entry_t) -> types::cef_string_userfree_t>,
//
// Returns the time for the last known successful navigation completion. A
// navigation may be completed more than once if the page is reloaded. May be
@ -325,23 +317,6 @@ impl CefNavigationEntry {
}
}
//
// Returns the name of the sub-frame that navigated or an NULL value if the
// main frame navigated.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_frame_name(&self) -> String {
if self.c_object.is_null() ||
self.c_object as usize == mem::POST_DROP_USIZE {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_frame_name.unwrap())(
self.c_object))
}
}
//
// Returns the time for the last known successful navigation completion. A
// navigation may be completed more than once if the page is reloaded. May be

View file

@ -41,3 +41,7 @@ use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::mem;
use std::ptr;

View file

@ -41,3 +41,7 @@ use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::mem;
use std::ptr;

View file

@ -41,3 +41,7 @@ use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::mem;
use std::ptr;

View file

@ -396,6 +396,13 @@ pub struct _cef_print_handler_t {
pub on_print_reset: Option<extern "C" fn(this: *mut cef_print_handler_t) -> (
)>,
//
// Return the PDF paper size in device units. Used in combination with
// cef_browser_host_t::print_to_pdf().
//
pub get_pdf_paper_size: Option<extern "C" fn(this: *mut cef_print_handler_t,
device_units_per_inch: libc::c_int) -> types::cef_size_t>,
//
// The reference count. This will only be present for Rust instances!
//
@ -556,6 +563,24 @@ impl CefPrintHandler {
self.c_object))
}
}
//
// Return the PDF paper size in device units. Used in combination with
// cef_browser_host_t::print_to_pdf().
//
pub fn get_pdf_paper_size(&self,
device_units_per_inch: libc::c_int) -> types::cef_size_t {
if self.c_object.is_null() ||
self.c_object as usize == mem::POST_DROP_USIZE {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_pdf_paper_size.unwrap())(
self.c_object,
CefWrap::to_c(device_units_per_inch)))
}
}
}
impl CefWrap<*mut cef_print_handler_t> for CefPrintHandler {

View file

@ -41,3 +41,7 @@ use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::mem;
use std::ptr;

View file

@ -5,7 +5,7 @@
pub use interfaces::cef_app::{CefApp,cef_app_t,};
pub use interfaces::cef_auth_callback::{CefAuthCallback,cef_auth_callback_t,};
pub use interfaces::cef_browser_process_handler::{CefBrowserProcessHandler,cef_browser_process_handler_t,};
pub use interfaces::cef_browser::{CefBrowser,CefRunFileDialogCallback,CefNavigationEntryVisitor,CefBrowserHost,cef_browser_t,cef_run_file_dialog_callback_t,cef_navigation_entry_visitor_t,cef_browser_host_t,};
pub use interfaces::cef_browser::{CefBrowser,CefRunFileDialogCallback,CefNavigationEntryVisitor,CefPdfPrintCallback,CefBrowserHost,cef_browser_t,cef_run_file_dialog_callback_t,cef_navigation_entry_visitor_t,cef_pdf_print_callback_t,cef_browser_host_t,};
pub use interfaces::cef_callback::{CefCallback,CefCompletionCallback,cef_callback_t,cef_completion_callback_t,};
pub use interfaces::cef_client::{CefClient,cef_client_t,};
pub use interfaces::cef_command_line::{CefCommandLine,cef_command_line_t,};
@ -57,7 +57,7 @@ pub use interfaces::cef_values::{CefValue,CefBinaryValue,CefDictionaryValue,CefL
pub use interfaces::cef_web_plugin::{CefWebPluginInfo,CefWebPluginInfoVisitor,CefWebPluginUnstableCallback,cef_web_plugin_info_t,cef_web_plugin_info_visitor_t,cef_web_plugin_unstable_callback_t,};
pub use interfaces::cef_xml_reader::{CefXmlReader,cef_xml_reader_t,};
pub use interfaces::cef_zip_reader::{CefZipReader,cef_zip_reader_t,};
pub use types::{cef_window_handle_t,cef_cursor_handle_t,cef_string_t,cef_string_userfree_t,cef_string_utf8_t,cef_string_userfree_utf8_t,cef_string_utf16_t,cef_string_userfree_utf16_t,cef_string_wide_t,cef_string_userfree_wide_t,cef_main_args_t,cef_color_t,cef_mouse_event_t,CefMouseEvent,cef_key_event_t,CefKeyEvent,cef_point_t,CefValueType,CefProcessId,cef_settings_t,cef_base_t,CefBase,cef_window_info_t,CefWindowInfo,cef_time_t,cef_size_t,cef_page_range_t,cef_geoposition_t,CefGeoposition,cef_cookie_t,CefCookie,cef_popup_features_t,CefPopupFeatures,cef_screen_info_t,CefScreenInfo,cef_browser_settings_t,CefBrowserSettings,cef_cursor_info_t,CefCursorInfo,cef_request_context_settings_t,CefRequestContextSettings,cef_string_map_t,cef_string_multimap_t,cef_string_list_t,cef_text_input_context_t,cef_event_handle_t,cef_state_t,cef_thread_id_t,cef_navigation_type_t,cef_mouse_button_type_t,cef_postdataelement_type_t,cef_urlrequest_flags_t,cef_urlrequest_status_t,cef_errorcode_t,cef_key_event_type_t,cef_paint_element_type_t,cef_dom_document_type_t,cef_file_dialog_mode_t,cef_value_type_t,cef_process_id_t,cef_log_severity_t,cef_menu_item_type_t,cef_context_menu_type_flags_t,cef_context_menu_media_type_t,cef_context_menu_media_state_flags_t,cef_context_menu_edit_state_flags_t,cef_event_flags_t,cef_dom_event_phase_t,cef_dom_node_type_t,cef_focus_source_t,cef_jsdialog_type_t,cef_duplex_mode_t,cef_color_model_t,cef_resource_type_t,cef_transition_type_t,cef_termination_status_t,cef_v8_accesscontrol_t,cef_v8_propertyattribute_t,cef_xml_node_type_t,cef_geoposition_error_code_t,cef_drag_operations_mask_t,cef_xml_encoding_type_t,cef_window_open_disposition_t,cef_cursor_type_t,cef_return_value_t,};
pub use types::{cef_string_map_t,cef_string_multimap_t,cef_string_list_t,cef_window_handle_t,cef_cursor_handle_t,cef_string_t,cef_string_userfree_t,cef_string_utf8_t,cef_string_userfree_utf8_t,cef_string_utf16_t,cef_string_userfree_utf16_t,cef_string_wide_t,cef_string_userfree_wide_t,cef_main_args_t,cef_color_t,cef_mouse_event_t,CefMouseEvent,cef_errorcode_t,cef_key_event_t,CefKeyEvent,cef_point_t,CefValueType,CefProcessId,cef_settings_t,cef_base_t,CefBase,cef_window_info_t,CefWindowInfo,cef_time_t,cef_size_t,cef_page_range_t,cef_geoposition_t,CefGeoposition,cef_cookie_t,CefCookie,cef_popup_features_t,CefPopupFeatures,cef_screen_info_t,CefScreenInfo,cef_browser_settings_t,CefBrowserSettings,cef_cursor_info_t,CefCursorInfo,cef_request_context_settings_t,CefRequestContextSettings,cef_text_input_context_t,cef_event_handle_t,cef_state_t,cef_thread_id_t,cef_navigation_type_t,cef_mouse_button_type_t,cef_postdataelement_type_t,cef_urlrequest_flags_t,cef_urlrequest_status_t,cef_key_event_type_t,cef_paint_element_type_t,cef_dom_document_type_t,cef_file_dialog_mode_t,cef_value_type_t,cef_process_id_t,cef_log_severity_t,cef_menu_item_type_t,cef_context_menu_type_flags_t,cef_context_menu_media_type_t,cef_context_menu_media_state_flags_t,cef_context_menu_edit_state_flags_t,cef_event_flags_t,cef_dom_event_phase_t,cef_dom_node_type_t,cef_focus_source_t,cef_jsdialog_type_t,cef_duplex_mode_t,cef_color_model_t,cef_resource_type_t,cef_transition_type_t,cef_termination_status_t,cef_v8_accesscontrol_t,cef_v8_propertyattribute_t,cef_xml_node_type_t,cef_geoposition_error_code_t,cef_drag_operations_mask_t,cef_xml_encoding_type_t,cef_window_open_disposition_t,cef_cursor_type_t,cef_return_value_t,};