servo: Merge #4102 - ports/cef: Use the CEF translator tool to generate the full set of CEF bindings (from pcwalton:cef-autogeneration); r=larsbergstrom

This replaces hand-implemented CEF bindings with proper Rust wrappers
automatically generated from the C++ headers. This means that, whenever
CEF's C++ headers change, we can easily generate both the appropriate C
API and the appropriate Rust API. It eliminates much of the hand-written
unsafe code within the CEF port, because the CEF translator tool now
knows how to generate Rust smart pointer wrappers for each class that
corrently perform reference counting.

Additionally, this commit adds utility macros (located in `macros.rs`)
that make it easier to correctly expose Rust objects as CEF objects.
They handle the marshaling of objects between Rust and CEF properly.
The net result of this is that you can write mostly-natural-looking Rust
in the CEF port and interact with it with a natural-looking C++ API on
the embedding side.

This setup relies on the branch of CEF located here:

    https://github.com/pcwalton/chromium-embedded-framework

To regenerate, follow the instructions in `ports/cef/README.md`. For
convenience, and because I don't anticipate the API to change much, I
have vendored in all of the appropriate interfaces.

r? @zmike or @larsbergstrom

Source-Repo: https://github.com/servo/servo
Source-Revision: 02c2f53ccd8b75ff0b87edfce4f2f9315a6417bd
This commit is contained in:
Patrick Walton 2014-11-27 23:18:44 -07:00
Родитель 5234e4a7a9
Коммит 860ec5ac31
82 изменённых файлов: 30955 добавлений и 1665 удалений

Просмотреть файл

@ -10,3 +10,12 @@ How to test:
Notes:
* Running with the Debug build in GDB is EXTREMELY slow on startup. Only use this if you are actively debugging an unimplemented CEF interaction.
* The contents of `interfaces/`, with the exception of `interfaces/mod.rs` is autogenerated. To
regenerate:
- Check out the `servo` branch of the following repository:
https://github.com/pcwalton/chromium-embedded-framework
- Change to the `tools` directory and run `./translator.sh`
- Run the following command to copy in the Rust header files, replacing `${SERVO_SRC}` with
the path to your Servo checkout:
$ cp ../libcef_dll/rust/*.rs ${SERVO_SRC}/ports/cef/interfaces/

Просмотреть файл

@ -2,95 +2,103 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use compositing::windowing::{WindowMethods};
use interfaces::{CefBrowser, CefClient, CefRequestContext, cef_browser_t, cef_client_t};
use interfaces::{cef_request_context_t};
use types::{cef_browser_settings_t, cef_string_t, cef_window_info_t};
use eutil::Downcast;
use glfw_app;
use libc::{calloc, size_t,c_int};
use libc::c_int;
use servo::Browser;
use servo_util::opts;
use std::cell::RefCell;
use std::mem;
use std::cell::{Cell, RefCell};
use std::rc::Rc;
use std::string;
use types::{cef_browser_settings_t, cef_browser_t, cef_client_t, cef_request_context_t, cef_string_t, cef_window_info_t};
pub type servo_browser_t = servo_browser;
pub struct servo_browser {
pub browser: cef_browser_t,
pub client: *mut cef_client_t,
pub servo_browser: Option<Browser<glfw_app::window::Window>>,
pub window: Rc<glfw_app::window::Window>,
pub callback_executed: bool
pub struct ServoCefBrowser {
pub client: CefClient,
pub servo_browser: RefCell<Option<Browser<glfw_app::window::Window>>>,
pub window: RefCell<Option<Rc<glfw_app::window::Window>>>,
pub callback_executed: Cell<bool>,
}
local_data_key!(pub GLOBAL_BROWSERS: RefCell<Vec<*mut servo_browser_t>>)
pub fn browser_callback_after_created(browser: *mut servo_browser_t) {
unsafe {
if (*browser).client.is_null() { return; }
let client = (*browser).client;
(*client).get_life_span_handler.map(|cb| {
let handler = cb(client);
if handler.is_not_null() {
(*handler).on_after_created.map(|createcb| createcb(handler, browser as *mut cef_browser_t));
}
});
(*browser).callback_executed = true;
impl ServoCefBrowser {
pub fn new(client: CefClient) -> ServoCefBrowser {
ServoCefBrowser {
client: client,
servo_browser: RefCell::new(None),
window: RefCell::new(None),
callback_executed: Cell::new(false),
}
}
}
fn browser_host_create(_window_info: *const cef_window_info_t,
client: *mut cef_client_t,
url: *const cef_string_t,
_settings: *const cef_browser_settings_t,
_request_context: *mut cef_request_context_t,
callback_executed: bool)
-> *mut cef_browser_t {
unsafe {
let mut urls = Vec::new();
if url.is_null() || (*url).str.is_null() {
urls.push("http://s27.postimg.org/vqbtrolyr/servo.jpg".to_string());
} else {
urls.push(string::raw::from_buf((*url).str as *const u8));
cef_class_impl! {
ServoCefBrowser : CefBrowser, cef_browser_t {}
}
local_data_key!(pub GLOBAL_BROWSERS: RefCell<Vec<CefBrowser>>)
pub fn browser_callback_after_created(browser: CefBrowser) {
if browser.downcast().client.is_null_cef_object() {
return
}
let client = browser.downcast().client.clone();
let life_span_handler = client.get_life_span_handler();
if life_span_handler.is_not_null_cef_object() {
life_span_handler.on_after_created(browser.clone());
}
browser.downcast().callback_executed.set(true);
}
fn browser_host_create(client: CefClient, callback_executed: bool) -> CefBrowser {
let mut urls = Vec::new();
urls.push("http://s27.postimg.org/vqbtrolyr/servo.jpg".to_string());
let mut opts = opts::default_opts();
opts.urls = urls;
let browser = ServoCefBrowser::new(client).as_cef_interface();
if callback_executed {
browser_callback_after_created(browser.clone());
}
match GLOBAL_BROWSERS.replace(None) {
Some(brs) => {
brs.borrow_mut().push(browser.clone());
GLOBAL_BROWSERS.replace(Some(brs));
},
None => {
let brs = RefCell::new(vec!(browser.clone()));
GLOBAL_BROWSERS.replace(Some(brs));
}
let mut opts = opts::default_opts();
opts.urls = urls;
let browser = calloc(1, mem::size_of::<servo_browser_t>() as size_t) as *mut servo_browser_t;
(*browser).browser.base.size = mem::size_of::<cef_browser_t>() as size_t;
(*browser).client = client;
if callback_executed {
browser_callback_after_created(browser);
}
match GLOBAL_BROWSERS.replace(None) {
Some(brs) => {
brs.borrow_mut().push(browser);
GLOBAL_BROWSERS.replace(Some(brs));
},
None => {
let brs = RefCell::new(vec!(browser));
GLOBAL_BROWSERS.replace(Some(brs));
}
}
browser as *mut cef_browser_t
}
browser
}
cef_static_method_impls! {
fn cef_browser_host_create_browser(_window_info: *const cef_window_info_t,
client: *mut cef_client_t,
_url: *const cef_string_t,
_browser_settings: *const cef_browser_settings_t,
_request_context: *mut cef_request_context_t)
-> c_int {
let _window_info: &cef_window_info_t = _window_info;
let client: CefClient = client;
let _url: &[u16] = _url;
let _browser_settings: &cef_browser_settings_t = _browser_settings;
let _request_context: CefRequestContext = _request_context;
browser_host_create(client, false);
1i32
}
fn cef_browser_host_create_browser_sync(_window_info: *const cef_window_info_t,
client: *mut cef_client_t,
_url: *const cef_string_t,
_browser_settings: *const cef_browser_settings_t,
_request_context: *mut cef_request_context_t)
-> *mut cef_browser_t {
let _window_info: &cef_window_info_t = _window_info;
let client: CefClient = client;
let _url: &[u16] = _url;
let _browser_settings: &cef_browser_settings_t = _browser_settings;
let _request_context: CefRequestContext = _request_context;
browser_host_create(client, true)
}
}
#[no_mangle]
pub extern "C" fn cef_browser_host_create_browser(window_info: *const cef_window_info_t,
client: *mut cef_client_t,
url: *const cef_string_t,
settings: *const cef_browser_settings_t,
request_context: *mut cef_request_context_t)
-> c_int {
browser_host_create(window_info, client, url, settings, request_context, false);
1
}
#[no_mangle]
pub extern "C" fn cef_browser_host_create_browser_sync(window_info: *const cef_window_info_t,
client: *mut cef_client_t,
url: *const cef_string_t,
settings: *const cef_browser_settings_t,
request_context: *mut cef_request_context_t)
-> *mut cef_browser_t {
browser_host_create(window_info, client, url, settings, request_context, true)
}

Просмотреть файл

@ -2,12 +2,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::cef_command_line_t;
use libc::{calloc, c_int, size_t};
use std::mem;
use std::string;
use std::c_vec::CVec;
use string::{cef_string_userfree_utf16_alloc, cef_string_utf16_set};
use types::{cef_command_line_t, cef_string_t, cef_string_userfree_t, cef_string_utf16_t};
use string as cef_string;
use string::cef_string_utf16_set;
use types::{cef_string_t, cef_string_userfree_t, cef_string_utf16_t};
type command_line_t = command_line;
struct command_line {
@ -41,9 +44,9 @@ pub fn command_line_init(argc: c_int, argv: *const *const u8) {
}
#[no_mangle]
pub extern "C" fn command_line_get_switch_value(cmd: *mut cef_command_line_t, name: *const cef_string_t) -> *mut cef_string_userfree_t {
pub extern "C" fn command_line_get_switch_value(cmd: *mut cef_command_line_t, name: *const cef_string_t) -> cef_string_userfree_t {
if cmd.is_null() || name.is_null() {
return 0 as *mut cef_string_userfree_t;
return cef_string::empty_utf16_string()
}
unsafe {
//technically cef_string_t can be any type of character size
@ -56,16 +59,19 @@ pub extern "C" fn command_line_get_switch_value(cmd: *mut cef_command_line_t, na
let o = s.as_slice().trim_left_chars('-');
//debug!("arg: {}", o);
if o.as_slice().starts_with(opt.as_slice()) {
let string = cef_string_userfree_utf16_alloc() as *mut cef_string_utf16_t;
let mut string = mem::uninitialized();
let arg = o.slice_from(opt.len() + 1).as_bytes();
arg.with_c_str(|c_str| {
cef_string_utf16_set(mem::transmute(c_str), arg.len() as size_t, string, 1);
cef_string_utf16_set(mem::transmute(c_str),
arg.len() as size_t,
&mut string,
1);
});
return string as *mut cef_string_userfree_t
return string
}
}
}
return 0 as *mut cef_string_userfree_t;
return cef_string::empty_utf16_string()
}
#[no_mangle]
@ -90,3 +96,9 @@ pub extern "C" fn cef_command_line_get_global() -> *mut cef_command_line_t {
}
}
}
cef_stub_static_method_impls! {
fn cef_command_line_create_command_line() -> *mut cef_command_line_t;
fn cef_command_line_get_global_command_line() -> *mut cef_command_line_t;
}

16
servo/ports/cef/cookie.rs Normal file
Просмотреть файл

@ -0,0 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::cef_cookie_manager_t;
use types::cef_string_t;
use libc::c_int;
cef_stub_static_method_impls! {
fn cef_cookie_manager_get_global_manager() -> *mut cef_cookie_manager_t;
fn cef_cookie_manager_create_manager(path: *const cef_string_t,
persist_session_cookies: c_int)
-> *mut cef_cookie_manager_t;
}

Просмотреть файл

@ -4,14 +4,25 @@
use browser::{GLOBAL_BROWSERS, browser_callback_after_created};
use command_line::command_line_init;
use interfaces::cef_app_t;
use eutil::Downcast;
use switches::{KPROCESSTYPE, KWAITFORDEBUGGER};
use types::{cef_main_args_t, cef_settings_t};
use glfw_app;
use libc::funcs::c95::string::strlen;
use libc::{c_int, c_void};
use libc::{c_char, c_int, c_void};
use native;
use servo::Browser;
use std::slice;
use switches::{KPROCESSTYPE, KWAITFORDEBUGGER};
use types::{cef_app_t, cef_main_args_t, cef_settings_t};
static CEF_API_HASH_UNIVERSAL: &'static [u8] = b"8efd129f4afc344bd04b2feb7f73a149b6c4e27f\0";
#[cfg(target_os="windows")]
static CEF_API_HASH_PLATFORM: &'static [u8] = b"5c7f3e50ff5265985d11dc1a466513e25748bedd\0";
#[cfg(target_os="macos")]
static CEF_API_HASH_PLATFORM: &'static [u8] = b"6813214accbf2ebfb6bdcf8d00654650b251bf3d\0";
#[cfg(target_os="linux")]
static CEF_API_HASH_PLATFORM: &'static [u8] = b"2bc564c3871965ef3a2531b528bda3e17fa17a6d\0";
#[no_mangle]
pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
@ -42,22 +53,36 @@ pub extern "C" fn cef_shutdown() {
pub extern "C" fn cef_run_message_loop() {
native::start(0, 0 as *const *const u8, proc() {
GLOBAL_BROWSERS.get().map(|refcellbrowsers| {
unsafe {
let browsers = refcellbrowsers.borrow();
let mut num = browsers.len();
for active_browser in browsers.iter() {
(**active_browser).window = glfw_app::create_window();
(**active_browser).servo_browser = Some(Browser::new(Some((**active_browser).window.clone())));
if !(**active_browser).callback_executed { browser_callback_after_created(*active_browser); }
let browsers = refcellbrowsers.borrow();
let mut num = browsers.len();
for active_browser in browsers.iter() {
*active_browser.downcast().window.borrow_mut() =
Some(glfw_app::create_window());
*active_browser.downcast().servo_browser.borrow_mut() =
Some(Browser::new((*active_browser.downcast()
.window
.borrow()).clone()));
if !active_browser.downcast().callback_executed.get() {
browser_callback_after_created((*active_browser).clone());
}
while num > 0 {
for active_browser in browsers.iter().filter(|&active_browser| (**active_browser).servo_browser.is_some()) {
let ref mut browser = **active_browser;
let mut servobrowser = browser.servo_browser.take().unwrap();
if !servobrowser.handle_event(browser.window.wait_events()) {
servobrowser.shutdown();
num -= 1;
}
}
while num > 0 {
for active_browser in browsers.iter()
.filter(|&active_browser| {
active_browser.downcast()
.servo_browser
.borrow()
.is_some()
}) {
let ref mut browser = active_browser.downcast();
let mut servobrowser = browser.servo_browser.borrow_mut().take().unwrap();
if !servobrowser.handle_event(browser.window
.borrow_mut()
.as_ref()
.unwrap()
.wait_events()) {
servobrowser.shutdown();
num -= 1;
}
}
}
@ -98,3 +123,18 @@ pub extern "C" fn cef_execute_process(args: *const cef_main_args_t,
//process type not specified, must be browser process (NOOP)
-1
}
#[no_mangle]
pub extern "C" fn cef_api_hash(entry: c_int) -> *const c_char {
if entry == 0 {
&CEF_API_HASH_PLATFORM[0] as *const u8 as *const c_char
} else {
&CEF_API_HASH_UNIVERSAL[0] as *const u8 as *const c_char
}
}
#[no_mangle]
pub extern "C" fn cef_get_min_log_level() -> c_int {
0
}

Просмотреть файл

@ -0,0 +1,10 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::{cef_drag_data_t};
cef_stub_static_method_impls! {
fn cef_drag_data_create() -> *mut cef_drag_data_t;
}

Просмотреть файл

@ -2,10 +2,23 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use libc::c_int;
use types::cef_base_t;
use libc::{mod, c_int, c_void, size_t};
use std::mem;
use std::slice;
use std::str;
/// Allows you to downcast a CEF interface to a CEF class instance.
///
/// FIXME(pcwalton): This is currently unsafe. I think the right way to make this safe is to (a)
/// forbid more than one Rust implementation of a given interface (easy to do by manufacturing an
/// impl that will conflict if there is more than one) and then (b) add a dynamic check to make
/// sure the `release` for the object is equal to `servo_release`.
pub trait Downcast<Class> {
fn downcast(&self) -> &Class;
}
pub fn slice_to_str(s: *const u8, l: uint, f: |&str| -> c_int) -> c_int {
unsafe {
slice::raw::buf_as_slice(s, l, |result| {
@ -13,3 +26,55 @@ pub fn slice_to_str(s: *const u8, l: uint, f: |&str| -> c_int) -> c_int {
})
}
}
/// Creates a new raw CEF object of the given type and sets up its reference counting machinery.
/// All fields are initialized to zero. It is the caller's responsibility to ensure that the given
/// type is a CEF type with `cef_base_t` as its first member.
pub unsafe fn create_cef_object<Base,Extra>(size: size_t) -> *mut Base {
let object = libc::calloc(1, (mem::size_of::<Base>() + mem::size_of::<Extra>()) as u64) as
*mut cef_base_t;
(*object).size = size;
(*object).add_ref = Some(servo_add_ref);
(*object).release = Some(servo_release);
*ref_count(object) = 1;
object as *mut Base
}
/// Returns a pointer to the Servo-specific reference count for the given object. This only works
/// on objects that Servo created!
unsafe fn ref_count(object: *mut cef_base_t) -> *mut uint {
// The reference count should be the first field of the extra data.
(object as *mut u8).offset((*object).size as int) as *mut uint
}
/// Increments the reference count on a CEF object. This only works on objects that Servo created!
extern "C" fn servo_add_ref(object: *mut cef_base_t) -> c_int {
unsafe {
let count = ref_count(object);
*count += 1;
*count as c_int
}
}
/// Decrements the reference count on a CEF object. If zero, frees it. This only works on objects
/// that Servo created!
extern "C" fn servo_release(object: *mut cef_base_t) -> c_int {
unsafe {
let count = ref_count(object);
*count -= 1;
let new_count = *count;
if new_count == 0 {
servo_free(object);
}
(new_count == 0) as c_int
}
}
unsafe fn servo_free(object: *mut cef_base_t) {
libc::free(object as *mut c_void);
}
pub unsafe fn add_ref(c_object: *mut cef_base_t) {
((*c_object).add_ref.unwrap())(c_object);
}

Просмотреть файл

@ -0,0 +1,305 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to provide handler implementations. Methods will be
// called by the process and/or thread indicated.
//
#[repr(C)]
pub struct _cef_app_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Provides an opportunity to view and/or modify command-line arguments before
// processing by CEF and Chromium. The |process_type| value will be NULL for
// the browser process. Do not keep a reference to the cef_command_line_t
// object passed to this function. The CefSettings.command_line_args_disabled
// value can be used to start with an NULL command-line object. Any values
// specified in CefSettings that equate to command-line arguments will be set
// before this function is called. Be cautious when using this function to
// modify command-line arguments for non-browser processes as this may result
// in undefined behavior including crashes.
//
pub on_before_command_line_processing: Option<extern "C" fn(
this: *mut cef_app_t, process_type: *const types::cef_string_t,
command_line: *mut interfaces::cef_command_line_t) -> ()>,
//
// Provides an opportunity to register custom schemes. Do not keep a reference
// to the |registrar| object. This function is called on the main thread for
// each process and the registered schemes should be the same across all
// processes.
//
pub on_register_custom_schemes: Option<extern "C" fn(this: *mut cef_app_t,
registrar: *mut interfaces::cef_scheme_registrar_t) -> ()>,
//
// Return the handler for resource bundle events. If
// CefSettings.pack_loading_disabled is true (1) a handler must be returned.
// If no handler is returned resources will be loaded from pack files. This
// function is called by the browser and render processes on multiple threads.
//
pub get_resource_bundle_handler: Option<extern "C" fn(
this: *mut cef_app_t) -> *mut interfaces::cef_resource_bundle_handler_t>,
//
// Return the handler for functionality specific to the browser process. This
// function is called on multiple threads in the browser process.
//
pub get_browser_process_handler: Option<extern "C" fn(
this: *mut cef_app_t) -> *mut interfaces::cef_browser_process_handler_t>,
//
// Return the handler for functionality specific to the render process. This
// function is called on the render process main thread.
//
pub get_render_process_handler: Option<extern "C" fn(
this: *mut cef_app_t) -> *mut interfaces::cef_render_process_handler_t>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_app_t = _cef_app_t;
//
// Implement this structure to provide handler implementations. Methods will be
// called by the process and/or thread indicated.
//
pub struct CefApp {
c_object: *mut cef_app_t,
}
impl Clone for CefApp {
fn clone(&self) -> CefApp{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefApp {
c_object: self.c_object,
}
}
}
}
impl Drop for CefApp {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefApp {
pub unsafe fn from_c_object(c_object: *mut cef_app_t) -> CefApp {
CefApp {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_app_t) -> CefApp {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefApp {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_app_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_app_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Provides an opportunity to view and/or modify command-line arguments before
// processing by CEF and Chromium. The |process_type| value will be NULL for
// the browser process. Do not keep a reference to the cef_command_line_t
// object passed to this function. The CefSettings.command_line_args_disabled
// value can be used to start with an NULL command-line object. Any values
// specified in CefSettings that equate to command-line arguments will be set
// before this function is called. Be cautious when using this function to
// modify command-line arguments for non-browser processes as this may result
// in undefined behavior including crashes.
//
pub fn on_before_command_line_processing(&self, process_type: &[u16],
command_line: interfaces::CefCommandLine) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_before_command_line_processing.unwrap())(
self.c_object,
CefWrap::to_c(process_type),
CefWrap::to_c(command_line)))
}
}
//
// Provides an opportunity to register custom schemes. Do not keep a reference
// to the |registrar| object. This function is called on the main thread for
// each process and the registered schemes should be the same across all
// processes.
//
pub fn on_register_custom_schemes(&self,
registrar: interfaces::CefSchemeRegistrar) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_register_custom_schemes.unwrap())(
self.c_object,
CefWrap::to_c(registrar)))
}
}
//
// Return the handler for resource bundle events. If
// CefSettings.pack_loading_disabled is true (1) a handler must be returned.
// If no handler is returned resources will be loaded from pack files. This
// function is called by the browser and render processes on multiple threads.
//
pub fn get_resource_bundle_handler(
&self) -> interfaces::CefResourceBundleHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_resource_bundle_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for functionality specific to the browser process. This
// function is called on multiple threads in the browser process.
//
pub fn get_browser_process_handler(
&self) -> interfaces::CefBrowserProcessHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_browser_process_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for functionality specific to the render process. This
// function is called on the render process main thread.
//
pub fn get_render_process_handler(
&self) -> interfaces::CefRenderProcessHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_render_process_handler.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_app_t> for CefApp {
fn to_c(rust_object: CefApp) -> *mut cef_app_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_app_t) -> CefApp {
CefApp::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_app_t> for Option<CefApp> {
fn to_c(rust_object: Option<CefApp>) -> *mut cef_app_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_app_t) -> Option<CefApp> {
if c_object.is_null() {
None
} else {
Some(CefApp::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,206 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Callback structure used for asynchronous continuation of authentication
// requests.
//
#[repr(C)]
pub struct _cef_auth_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Continue the authentication request.
//
pub cont: Option<extern "C" fn(this: *mut cef_auth_callback_t,
username: *const types::cef_string_t,
password: *const types::cef_string_t) -> ()>,
//
// Cancel the authentication request.
//
pub cancel: Option<extern "C" fn(this: *mut cef_auth_callback_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_auth_callback_t = _cef_auth_callback_t;
//
// Callback structure used for asynchronous continuation of authentication
// requests.
//
pub struct CefAuthCallback {
c_object: *mut cef_auth_callback_t,
}
impl Clone for CefAuthCallback {
fn clone(&self) -> CefAuthCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefAuthCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefAuthCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefAuthCallback {
pub unsafe fn from_c_object(c_object: *mut cef_auth_callback_t) -> CefAuthCallback {
CefAuthCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_auth_callback_t) -> CefAuthCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefAuthCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_auth_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_auth_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Continue the authentication request.
//
pub fn cont(&self, username: &[u16], password: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cont.unwrap())(
self.c_object,
CefWrap::to_c(username),
CefWrap::to_c(password)))
}
}
//
// Cancel the authentication request.
//
pub fn cancel(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cancel.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_auth_callback_t> for CefAuthCallback {
fn to_c(rust_object: CefAuthCallback) -> *mut cef_auth_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_auth_callback_t) -> CefAuthCallback {
CefAuthCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_auth_callback_t> for Option<CefAuthCallback> {
fn to_c(rust_object: Option<CefAuthCallback>) -> *mut cef_auth_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_auth_callback_t) -> Option<CefAuthCallback> {
if c_object.is_null() {
None
} else {
Some(CefAuthCallback::from_c_object_addref(c_object))
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,272 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure used to implement browser process callbacks. The functions of this
// structure will be called on the browser process main thread unless otherwise
// indicated.
//
#[repr(C)]
pub struct _cef_browser_process_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called on the browser process UI thread immediately after the CEF context
// has been initialized.
//
pub on_context_initialized: Option<extern "C" fn(
this: *mut cef_browser_process_handler_t) -> ()>,
//
// Called before a child process is launched. Will be called on the browser
// process UI thread when launching a render process and on the browser
// process IO thread when launching a GPU or plugin process. Provides an
// opportunity to modify the child process command line. Do not keep a
// reference to |command_line| outside of this function.
//
pub on_before_child_process_launch: Option<extern "C" fn(
this: *mut cef_browser_process_handler_t,
command_line: *mut interfaces::cef_command_line_t) -> ()>,
//
// Called on the browser process IO thread after the main thread has been
// created for a new render process. Provides an opportunity to specify extra
// information that will be passed to
// cef_render_process_handler_t::on_render_thread_created() in the render
// process. Do not keep a reference to |extra_info| outside of this function.
//
pub on_render_process_thread_created: Option<extern "C" fn(
this: *mut cef_browser_process_handler_t,
extra_info: *mut interfaces::cef_list_value_t) -> ()>,
//
// Return the handler for printing on Linux. If a print handler is not
// provided then printing will not be supported on the Linux platform.
//
pub get_print_handler: Option<extern "C" fn(
this: *mut cef_browser_process_handler_t) -> *mut interfaces::cef_print_handler_t>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_browser_process_handler_t = _cef_browser_process_handler_t;
//
// Structure used to implement browser process callbacks. The functions of this
// structure will be called on the browser process main thread unless otherwise
// indicated.
//
pub struct CefBrowserProcessHandler {
c_object: *mut cef_browser_process_handler_t,
}
impl Clone for CefBrowserProcessHandler {
fn clone(&self) -> CefBrowserProcessHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefBrowserProcessHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefBrowserProcessHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefBrowserProcessHandler {
pub unsafe fn from_c_object(c_object: *mut cef_browser_process_handler_t) -> CefBrowserProcessHandler {
CefBrowserProcessHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_browser_process_handler_t) -> CefBrowserProcessHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefBrowserProcessHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_browser_process_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_browser_process_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called on the browser process UI thread immediately after the CEF context
// has been initialized.
//
pub fn on_context_initialized(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_context_initialized.unwrap())(
self.c_object))
}
}
//
// Called before a child process is launched. Will be called on the browser
// process UI thread when launching a render process and on the browser
// process IO thread when launching a GPU or plugin process. Provides an
// opportunity to modify the child process command line. Do not keep a
// reference to |command_line| outside of this function.
//
pub fn on_before_child_process_launch(&self,
command_line: interfaces::CefCommandLine) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_before_child_process_launch.unwrap())(
self.c_object,
CefWrap::to_c(command_line)))
}
}
//
// Called on the browser process IO thread after the main thread has been
// created for a new render process. Provides an opportunity to specify extra
// information that will be passed to
// cef_render_process_handler_t::on_render_thread_created() in the render
// process. Do not keep a reference to |extra_info| outside of this function.
//
pub fn on_render_process_thread_created(&self,
extra_info: interfaces::CefListValue) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_render_process_thread_created.unwrap())(
self.c_object,
CefWrap::to_c(extra_info)))
}
}
//
// Return the handler for printing on Linux. If a print handler is not
// provided then printing will not be supported on the Linux platform.
//
pub fn get_print_handler(&self) -> interfaces::CefPrintHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_print_handler.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_browser_process_handler_t> for CefBrowserProcessHandler {
fn to_c(rust_object: CefBrowserProcessHandler) -> *mut cef_browser_process_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_browser_process_handler_t) -> CefBrowserProcessHandler {
CefBrowserProcessHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_browser_process_handler_t> for Option<CefBrowserProcessHandler> {
fn to_c(rust_object: Option<CefBrowserProcessHandler>) -> *mut cef_browser_process_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_browser_process_handler_t) -> Option<CefBrowserProcessHandler> {
if c_object.is_null() {
None
} else {
Some(CefBrowserProcessHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,336 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Generic callback structure used for asynchronous continuation.
//
#[repr(C)]
pub struct _cef_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Continue processing.
//
pub cont: Option<extern "C" fn(this: *mut cef_callback_t) -> ()>,
//
// Cancel processing.
//
pub cancel: Option<extern "C" fn(this: *mut cef_callback_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_callback_t = _cef_callback_t;
//
// Generic callback structure used for asynchronous continuation.
//
pub struct CefCallback {
c_object: *mut cef_callback_t,
}
impl Clone for CefCallback {
fn clone(&self) -> CefCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefCallback {
pub unsafe fn from_c_object(c_object: *mut cef_callback_t) -> CefCallback {
CefCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_callback_t) -> CefCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Continue processing.
//
pub fn cont(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cont.unwrap())(
self.c_object))
}
}
//
// Cancel processing.
//
pub fn cancel(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cancel.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_callback_t> for CefCallback {
fn to_c(rust_object: CefCallback) -> *mut cef_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_callback_t) -> CefCallback {
CefCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_callback_t> for Option<CefCallback> {
fn to_c(rust_object: Option<CefCallback>) -> *mut cef_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_callback_t) -> Option<CefCallback> {
if c_object.is_null() {
None
} else {
Some(CefCallback::from_c_object_addref(c_object))
}
}
}
//
// Generic callback structure used for asynchronous completion.
//
#[repr(C)]
pub struct _cef_completion_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Method that will be called once the task is complete.
//
pub on_complete: Option<extern "C" fn(
this: *mut cef_completion_callback_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_completion_callback_t = _cef_completion_callback_t;
//
// Generic callback structure used for asynchronous completion.
//
pub struct CefCompletionCallback {
c_object: *mut cef_completion_callback_t,
}
impl Clone for CefCompletionCallback {
fn clone(&self) -> CefCompletionCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefCompletionCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefCompletionCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefCompletionCallback {
pub unsafe fn from_c_object(c_object: *mut cef_completion_callback_t) -> CefCompletionCallback {
CefCompletionCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_completion_callback_t) -> CefCompletionCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefCompletionCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_completion_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_completion_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Method that will be called once the task is complete.
//
pub fn on_complete(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_complete.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_completion_callback_t> for CefCompletionCallback {
fn to_c(rust_object: CefCompletionCallback) -> *mut cef_completion_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_completion_callback_t) -> CefCompletionCallback {
CefCompletionCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_completion_callback_t> for Option<CefCompletionCallback> {
fn to_c(rust_object: Option<CefCompletionCallback>) -> *mut cef_completion_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_completion_callback_t) -> Option<CefCompletionCallback> {
if c_object.is_null() {
None
} else {
Some(CefCompletionCallback::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,463 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to provide handler implementations.
//
#[repr(C)]
pub struct _cef_client_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Return the handler for context menus. If no handler is provided the default
// implementation will be used.
//
pub get_context_menu_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_context_menu_handler_t>,
//
// Return the handler for dialogs. If no handler is provided the default
// implementation will be used.
//
pub get_dialog_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_dialog_handler_t>,
//
// Return the handler for browser display state events.
//
pub get_display_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_display_handler_t>,
//
// Return the handler for download events. If no handler is returned downloads
// will not be allowed.
//
pub get_download_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_download_handler_t>,
//
// Return the handler for drag events.
//
pub get_drag_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_drag_handler_t>,
//
// Return the handler for focus events.
//
pub get_focus_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_focus_handler_t>,
//
// Return the handler for geolocation permissions requests. If no handler is
// provided geolocation access will be denied by default.
//
pub get_geolocation_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_geolocation_handler_t>,
//
// Return the handler for JavaScript dialogs. If no handler is provided the
// default implementation will be used.
//
pub get_jsdialog_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_jsdialog_handler_t>,
//
// Return the handler for keyboard events.
//
pub get_keyboard_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_keyboard_handler_t>,
//
// Return the handler for browser life span events.
//
pub get_life_span_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_life_span_handler_t>,
//
// Return the handler for browser load status events.
//
pub get_load_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_load_handler_t>,
//
// Return the handler for off-screen rendering events.
//
pub get_render_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_render_handler_t>,
//
// Return the handler for browser request events.
//
pub get_request_handler: Option<extern "C" fn(
this: *mut cef_client_t) -> *mut interfaces::cef_request_handler_t>,
//
// Called when a new message is received from a different process. Return true
// (1) if the message was handled or false (0) otherwise. Do not keep a
// reference to or attempt to access the message outside of this callback.
//
pub on_process_message_received: Option<extern "C" fn(this: *mut cef_client_t,
browser: *mut interfaces::cef_browser_t,
source_process: interfaces::cef_process_id_t,
message: *mut interfaces::cef_process_message_t) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_client_t = _cef_client_t;
//
// Implement this structure to provide handler implementations.
//
pub struct CefClient {
c_object: *mut cef_client_t,
}
impl Clone for CefClient {
fn clone(&self) -> CefClient{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefClient {
c_object: self.c_object,
}
}
}
}
impl Drop for CefClient {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefClient {
pub unsafe fn from_c_object(c_object: *mut cef_client_t) -> CefClient {
CefClient {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_client_t) -> CefClient {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefClient {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_client_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_client_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Return the handler for context menus. If no handler is provided the default
// implementation will be used.
//
pub fn get_context_menu_handler(&self) -> interfaces::CefContextMenuHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_context_menu_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for dialogs. If no handler is provided the default
// implementation will be used.
//
pub fn get_dialog_handler(&self) -> interfaces::CefDialogHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_dialog_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for browser display state events.
//
pub fn get_display_handler(&self) -> interfaces::CefDisplayHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_display_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for download events. If no handler is returned downloads
// will not be allowed.
//
pub fn get_download_handler(&self) -> interfaces::CefDownloadHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_download_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for drag events.
//
pub fn get_drag_handler(&self) -> interfaces::CefDragHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_drag_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for focus events.
//
pub fn get_focus_handler(&self) -> interfaces::CefFocusHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_focus_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for geolocation permissions requests. If no handler is
// provided geolocation access will be denied by default.
//
pub fn get_geolocation_handler(&self) -> interfaces::CefGeolocationHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_geolocation_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for JavaScript dialogs. If no handler is provided the
// default implementation will be used.
//
pub fn get_jsdialog_handler(&self) -> interfaces::CefJSDialogHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_jsdialog_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for keyboard events.
//
pub fn get_keyboard_handler(&self) -> interfaces::CefKeyboardHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_keyboard_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for browser life span events.
//
pub fn get_life_span_handler(&self) -> interfaces::CefLifeSpanHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_life_span_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for browser load status events.
//
pub fn get_load_handler(&self) -> interfaces::CefLoadHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_load_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for off-screen rendering events.
//
pub fn get_render_handler(&self) -> interfaces::CefRenderHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_render_handler.unwrap())(
self.c_object))
}
}
//
// Return the handler for browser request events.
//
pub fn get_request_handler(&self) -> interfaces::CefRequestHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_request_handler.unwrap())(
self.c_object))
}
}
//
// Called when a new message is received from a different process. Return true
// (1) if the message was handled or false (0) otherwise. Do not keep a
// reference to or attempt to access the message outside of this callback.
//
pub fn on_process_message_received(&self, browser: interfaces::CefBrowser,
source_process: interfaces::CefProcessId,
message: interfaces::CefProcessMessage) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_process_message_received.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(source_process),
CefWrap::to_c(message)))
}
}
}
impl CefWrap<*mut cef_client_t> for CefClient {
fn to_c(rust_object: CefClient) -> *mut cef_client_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_client_t) -> CefClient {
CefClient::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_client_t> for Option<CefClient> {
fn to_c(rust_object: Option<CefClient>) -> *mut cef_client_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_client_t) -> Option<CefClient> {
if c_object.is_null() {
None
} else {
Some(CefClient::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,643 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure used to create and/or parse command line arguments. Arguments with
// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches
// will always precede any arguments without switch prefixes. Switches can
// optionally have a value specified using the '=' delimiter (e.g.
// "-switch=value"). An argument of "--" will terminate switch parsing with all
// subsequent tokens, regardless of prefix, being interpreted as non-switch
// arguments. Switch names are considered case-insensitive. This structure can
// be used before cef_initialize() is called.
//
#[repr(C)]
pub struct _cef_command_line_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
//
pub is_valid: Option<extern "C" fn(
this: *mut cef_command_line_t) -> libc::c_int>,
//
// Returns true (1) if the values of this object are read-only. Some APIs may
// expose read-only objects.
//
pub is_read_only: Option<extern "C" fn(
this: *mut cef_command_line_t) -> libc::c_int>,
//
// Returns a writable copy of this object.
//
pub copy: Option<extern "C" fn(
this: *mut cef_command_line_t) -> *mut interfaces::cef_command_line_t>,
//
// Initialize the command line with the specified |argc| and |argv| values.
// The first argument must be the name of the program. This function is only
// supported on non-Windows platforms.
//
pub init_from_argv: Option<extern "C" fn(this: *mut cef_command_line_t,
argc: libc::c_int, argv: *const *const libc::c_char) -> ()>,
//
// Initialize the command line with the string returned by calling
// GetCommandLineW(). This function is only supported on Windows.
//
pub init_from_string: Option<extern "C" fn(this: *mut cef_command_line_t,
command_line: *const types::cef_string_t) -> ()>,
//
// Reset the command-line switches and arguments but leave the program
// component unchanged.
//
pub reset: Option<extern "C" fn(this: *mut cef_command_line_t) -> ()>,
//
// Retrieve the original command line string as a vector of strings. The argv
// array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* }
//
pub get_argv: Option<extern "C" fn(this: *mut cef_command_line_t,
argv: types::cef_string_list_t) -> ()>,
//
// Constructs and returns the represented command line string. Use this
// function cautiously because quoting behavior is unclear.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_command_line_string: Option<extern "C" fn(
this: *mut cef_command_line_t) -> types::cef_string_userfree_t>,
//
// Get the program part of the command line string (the first item).
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_program: Option<extern "C" fn(
this: *mut cef_command_line_t) -> types::cef_string_userfree_t>,
//
// Set the program part of the command line string (the first item).
//
pub set_program: Option<extern "C" fn(this: *mut cef_command_line_t,
program: *const types::cef_string_t) -> ()>,
//
// Returns true (1) if the command line has switches.
//
pub has_switches: Option<extern "C" fn(
this: *mut cef_command_line_t) -> libc::c_int>,
//
// Returns true (1) if the command line contains the given switch.
//
pub has_switch: Option<extern "C" fn(this: *mut cef_command_line_t,
name: *const types::cef_string_t) -> libc::c_int>,
//
// Returns the value associated with the given switch. If the switch has no
// value or isn't present this function returns the NULL string.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_switch_value: Option<extern "C" fn(this: *mut cef_command_line_t,
name: *const types::cef_string_t) -> types::cef_string_userfree_t>,
//
// Returns the map of switch names and values. If a switch has no value an
// NULL string is returned.
//
pub get_switches: Option<extern "C" fn(this: *mut cef_command_line_t,
switches: types::cef_string_map_t) -> ()>,
//
// Add a switch to the end of the command line. If the switch has no value
// pass an NULL value string.
//
pub append_switch: Option<extern "C" fn(this: *mut cef_command_line_t,
name: *const types::cef_string_t) -> ()>,
//
// Add a switch with the specified value to the end of the command line.
//
pub append_switch_with_value: Option<extern "C" fn(
this: *mut cef_command_line_t, name: *const types::cef_string_t,
value: *const types::cef_string_t) -> ()>,
//
// True if there are remaining command line arguments.
//
pub has_arguments: Option<extern "C" fn(
this: *mut cef_command_line_t) -> libc::c_int>,
//
// Get the remaining command line arguments.
//
pub get_arguments: Option<extern "C" fn(this: *mut cef_command_line_t,
arguments: types::cef_string_list_t) -> ()>,
//
// Add an argument to the end of the command line.
//
pub append_argument: Option<extern "C" fn(this: *mut cef_command_line_t,
argument: *const types::cef_string_t) -> ()>,
//
// Insert a command before the current command. Common for debuggers, like
// "valgrind" or "gdb --args".
//
pub prepend_wrapper: Option<extern "C" fn(this: *mut cef_command_line_t,
wrapper: *const types::cef_string_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_command_line_t = _cef_command_line_t;
//
// Structure used to create and/or parse command line arguments. Arguments with
// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches
// will always precede any arguments without switch prefixes. Switches can
// optionally have a value specified using the '=' delimiter (e.g.
// "-switch=value"). An argument of "--" will terminate switch parsing with all
// subsequent tokens, regardless of prefix, being interpreted as non-switch
// arguments. Switch names are considered case-insensitive. This structure can
// be used before cef_initialize() is called.
//
pub struct CefCommandLine {
c_object: *mut cef_command_line_t,
}
impl Clone for CefCommandLine {
fn clone(&self) -> CefCommandLine{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefCommandLine {
c_object: self.c_object,
}
}
}
}
impl Drop for CefCommandLine {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefCommandLine {
pub unsafe fn from_c_object(c_object: *mut cef_command_line_t) -> CefCommandLine {
CefCommandLine {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_command_line_t) -> CefCommandLine {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefCommandLine {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_command_line_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_command_line_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
//
pub fn is_valid(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_valid.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the values of this object are read-only. Some APIs may
// expose read-only objects.
//
pub fn is_read_only(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_read_only.unwrap())(
self.c_object))
}
}
//
// Returns a writable copy of this object.
//
pub fn copy(&self) -> interfaces::CefCommandLine {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).copy.unwrap())(
self.c_object))
}
}
//
// Initialize the command line with the specified |argc| and |argv| values.
// The first argument must be the name of the program. This function is only
// supported on non-Windows platforms.
//
pub fn init_from_argv(&self, argc: libc::c_int, argv: &&str) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).init_from_argv.unwrap())(
self.c_object,
CefWrap::to_c(argc),
CefWrap::to_c(argv)))
}
}
//
// Initialize the command line with the string returned by calling
// GetCommandLineW(). This function is only supported on Windows.
//
pub fn init_from_string(&self, command_line: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).init_from_string.unwrap())(
self.c_object,
CefWrap::to_c(command_line)))
}
}
//
// Reset the command-line switches and arguments but leave the program
// component unchanged.
//
pub fn reset(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).reset.unwrap())(
self.c_object))
}
}
//
// Retrieve the original command line string as a vector of strings. The argv
// array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* }
//
pub fn get_argv(&self, argv: Vec<String>) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_argv.unwrap())(
self.c_object,
CefWrap::to_c(argv)))
}
}
//
// Constructs and returns the represented command line string. Use this
// function cautiously because quoting behavior is unclear.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_command_line_string(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_command_line_string.unwrap())(
self.c_object))
}
}
//
// Get the program part of the command line string (the first item).
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_program(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_program.unwrap())(
self.c_object))
}
}
//
// Set the program part of the command line string (the first item).
//
pub fn set_program(&self, program: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_program.unwrap())(
self.c_object,
CefWrap::to_c(program)))
}
}
//
// Returns true (1) if the command line has switches.
//
pub fn has_switches(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).has_switches.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the command line contains the given switch.
//
pub fn has_switch(&self, name: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).has_switch.unwrap())(
self.c_object,
CefWrap::to_c(name)))
}
}
//
// Returns the value associated with the given switch. If the switch has no
// value or isn't present this function returns the NULL string.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_switch_value(&self, name: &[u16]) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_switch_value.unwrap())(
self.c_object,
CefWrap::to_c(name)))
}
}
//
// Returns the map of switch names and values. If a switch has no value an
// NULL string is returned.
//
pub fn get_switches(&self, switches: HashMap<String,String>) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_switches.unwrap())(
self.c_object,
CefWrap::to_c(switches)))
}
}
//
// Add a switch to the end of the command line. If the switch has no value
// pass an NULL value string.
//
pub fn append_switch(&self, name: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).append_switch.unwrap())(
self.c_object,
CefWrap::to_c(name)))
}
}
//
// Add a switch with the specified value to the end of the command line.
//
pub fn append_switch_with_value(&self, name: &[u16], value: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).append_switch_with_value.unwrap())(
self.c_object,
CefWrap::to_c(name),
CefWrap::to_c(value)))
}
}
//
// True if there are remaining command line arguments.
//
pub fn has_arguments(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).has_arguments.unwrap())(
self.c_object))
}
}
//
// Get the remaining command line arguments.
//
pub fn get_arguments(&self, arguments: Vec<String>) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_arguments.unwrap())(
self.c_object,
CefWrap::to_c(arguments)))
}
}
//
// Add an argument to the end of the command line.
//
pub fn append_argument(&self, argument: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).append_argument.unwrap())(
self.c_object,
CefWrap::to_c(argument)))
}
}
//
// Insert a command before the current command. Common for debuggers, like
// "valgrind" or "gdb --args".
//
pub fn prepend_wrapper(&self, wrapper: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).prepend_wrapper.unwrap())(
self.c_object,
CefWrap::to_c(wrapper)))
}
}
//
// Create a new cef_command_line_t instance.
//
pub fn create_command_line() -> interfaces::CefCommandLine {
unsafe {
CefWrap::to_rust(
::command_line::cef_command_line_create_command_line(
))
}
}
//
// Returns the singleton global cef_command_line_t object. The returned object
// will be read-only.
//
pub fn get_global_command_line() -> interfaces::CefCommandLine {
unsafe {
CefWrap::to_rust(
::command_line::cef_command_line_get_global_command_line(
))
}
}
}
impl CefWrap<*mut cef_command_line_t> for CefCommandLine {
fn to_c(rust_object: CefCommandLine) -> *mut cef_command_line_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_command_line_t) -> CefCommandLine {
CefCommandLine::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_command_line_t> for Option<CefCommandLine> {
fn to_c(rust_object: Option<CefCommandLine>) -> *mut cef_command_line_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_command_line_t) -> Option<CefCommandLine> {
if c_object.is_null() {
None
} else {
Some(CefCommandLine::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,825 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to handle context menu events. The functions of this
// structure will be called on the UI thread.
//
#[repr(C)]
pub struct _cef_context_menu_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called before a context menu is displayed. |params| provides information
// about the context menu state. |model| initially contains the default
// context menu. The |model| can be cleared to show no context menu or
// modified to show a custom menu. Do not keep references to |params| or
// |model| outside of this callback.
//
pub on_before_context_menu: Option<extern "C" fn(
this: *mut cef_context_menu_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
params: *mut interfaces::cef_context_menu_params_t,
model: *mut interfaces::cef_menu_model_t) -> ()>,
//
// Called to execute a command selected from the context menu. Return true (1)
// if the command was handled or false (0) for the default implementation. See
// cef_menu_id_t for the command ids that have default implementations. All
// user-defined command ids should be between MENU_ID_USER_FIRST and
// MENU_ID_USER_LAST. |params| will have the same values as what was passed to
// on_before_context_menu(). Do not keep a reference to |params| outside of
// this callback.
//
pub on_context_menu_command: Option<extern "C" fn(
this: *mut cef_context_menu_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
params: *mut interfaces::cef_context_menu_params_t,
command_id: libc::c_int,
event_flags: types::cef_event_flags_t) -> libc::c_int>,
//
// Called when the context menu is dismissed irregardless of whether the menu
// was NULL or a command was selected.
//
pub on_context_menu_dismissed: Option<extern "C" fn(
this: *mut cef_context_menu_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_context_menu_handler_t = _cef_context_menu_handler_t;
//
// Implement this structure to handle context menu events. The functions of this
// structure will be called on the UI thread.
//
pub struct CefContextMenuHandler {
c_object: *mut cef_context_menu_handler_t,
}
impl Clone for CefContextMenuHandler {
fn clone(&self) -> CefContextMenuHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefContextMenuHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefContextMenuHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefContextMenuHandler {
pub unsafe fn from_c_object(c_object: *mut cef_context_menu_handler_t) -> CefContextMenuHandler {
CefContextMenuHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_context_menu_handler_t) -> CefContextMenuHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefContextMenuHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_context_menu_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_context_menu_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called before a context menu is displayed. |params| provides information
// about the context menu state. |model| initially contains the default
// context menu. The |model| can be cleared to show no context menu or
// modified to show a custom menu. Do not keep references to |params| or
// |model| outside of this callback.
//
pub fn on_before_context_menu(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, params: interfaces::CefContextMenuParams,
model: interfaces::CefMenuModel) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_before_context_menu.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(params),
CefWrap::to_c(model)))
}
}
//
// Called to execute a command selected from the context menu. Return true (1)
// if the command was handled or false (0) for the default implementation. See
// cef_menu_id_t for the command ids that have default implementations. All
// user-defined command ids should be between MENU_ID_USER_FIRST and
// MENU_ID_USER_LAST. |params| will have the same values as what was passed to
// on_before_context_menu(). Do not keep a reference to |params| outside of
// this callback.
//
pub fn on_context_menu_command(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, params: interfaces::CefContextMenuParams,
command_id: libc::c_int,
event_flags: types::cef_event_flags_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_context_menu_command.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(params),
CefWrap::to_c(command_id),
CefWrap::to_c(event_flags)))
}
}
//
// Called when the context menu is dismissed irregardless of whether the menu
// was NULL or a command was selected.
//
pub fn on_context_menu_dismissed(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_context_menu_dismissed.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame)))
}
}
}
impl CefWrap<*mut cef_context_menu_handler_t> for CefContextMenuHandler {
fn to_c(rust_object: CefContextMenuHandler) -> *mut cef_context_menu_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_context_menu_handler_t) -> CefContextMenuHandler {
CefContextMenuHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_context_menu_handler_t> for Option<CefContextMenuHandler> {
fn to_c(rust_object: Option<CefContextMenuHandler>) -> *mut cef_context_menu_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_context_menu_handler_t) -> Option<CefContextMenuHandler> {
if c_object.is_null() {
None
} else {
Some(CefContextMenuHandler::from_c_object_addref(c_object))
}
}
}
//
// Provides information about the context menu state. The ethods of this
// structure can only be accessed on browser process the UI thread.
//
#[repr(C)]
pub struct _cef_context_menu_params_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Returns the X coordinate of the mouse where the context menu was invoked.
// Coords are relative to the associated RenderView's origin.
//
pub get_xcoord: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> libc::c_int>,
//
// Returns the Y coordinate of the mouse where the context menu was invoked.
// Coords are relative to the associated RenderView's origin.
//
pub get_ycoord: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> libc::c_int>,
//
// Returns flags representing the type of node that the context menu was
// invoked on.
//
pub get_type_flags: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> types::cef_context_menu_type_flags_t>,
//
// Returns the URL of the link, if any, that encloses the node that the
// context menu was invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_link_url: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>,
//
// Returns the link URL, if any, to be used ONLY for "copy link address". We
// don't validate this field in the frontend process.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_unfiltered_link_url: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>,
//
// Returns the source URL, if any, for the element that the context menu was
// invoked on. Example of elements with source URLs are img, audio, and video.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_source_url: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>,
//
// Returns true (1) if the context menu was invoked on an image which has non-
// NULL contents.
//
pub has_image_contents: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> libc::c_int>,
//
// Returns the URL of the top level page that the context menu was invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_page_url: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>,
//
// Returns the URL of the subframe that the context menu was invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_frame_url: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>,
//
// Returns the character encoding of the subframe that the context menu was
// invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_frame_charset: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>,
//
// Returns the type of context node that the context menu was invoked on.
//
pub get_media_type: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> types::cef_context_menu_media_type_t>,
//
// Returns flags representing the actions supported by the media element, if
// any, that the context menu was invoked on.
//
pub get_media_state_flags: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> types::cef_context_menu_media_state_flags_t>,
//
// Returns the text of the selection, if any, that the context menu was
// invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_selection_text: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>,
//
// Returns the text of the misspelled word, if any, that the context menu was
// invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_misspelled_word: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>,
//
// Returns the hash of the misspelled word, if any, that the context menu was
// invoked on.
//
pub get_misspelling_hash: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> libc::c_int>,
//
// Returns true (1) if suggestions exist, false (0) otherwise. Fills in
// |suggestions| from the spell check service for the misspelled word if there
// is one.
//
pub get_dictionary_suggestions: Option<extern "C" fn(
this: *mut cef_context_menu_params_t,
suggestions: types::cef_string_list_t) -> libc::c_int>,
//
// Returns true (1) if the context menu was invoked on an editable node.
//
pub is_editable: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> libc::c_int>,
//
// Returns true (1) if the context menu was invoked on an editable node where
// spell-check is enabled.
//
pub is_spell_check_enabled: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> libc::c_int>,
//
// Returns flags representing the actions supported by the editable node, if
// any, that the context menu was invoked on.
//
pub get_edit_state_flags: Option<extern "C" fn(
this: *mut cef_context_menu_params_t) -> types::cef_context_menu_edit_state_flags_t>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_context_menu_params_t = _cef_context_menu_params_t;
//
// Provides information about the context menu state. The ethods of this
// structure can only be accessed on browser process the UI thread.
//
pub struct CefContextMenuParams {
c_object: *mut cef_context_menu_params_t,
}
impl Clone for CefContextMenuParams {
fn clone(&self) -> CefContextMenuParams{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefContextMenuParams {
c_object: self.c_object,
}
}
}
}
impl Drop for CefContextMenuParams {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefContextMenuParams {
pub unsafe fn from_c_object(c_object: *mut cef_context_menu_params_t) -> CefContextMenuParams {
CefContextMenuParams {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_context_menu_params_t) -> CefContextMenuParams {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefContextMenuParams {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_context_menu_params_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_context_menu_params_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Returns the X coordinate of the mouse where the context menu was invoked.
// Coords are relative to the associated RenderView's origin.
//
pub fn get_xcoord(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_xcoord.unwrap())(
self.c_object))
}
}
//
// Returns the Y coordinate of the mouse where the context menu was invoked.
// Coords are relative to the associated RenderView's origin.
//
pub fn get_ycoord(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_ycoord.unwrap())(
self.c_object))
}
}
//
// Returns flags representing the type of node that the context menu was
// invoked on.
//
pub fn get_type_flags(&self) -> types::cef_context_menu_type_flags_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_type_flags.unwrap())(
self.c_object))
}
}
//
// Returns the URL of the link, if any, that encloses the node that the
// context menu was invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_link_url(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_link_url.unwrap())(
self.c_object))
}
}
//
// Returns the link URL, if any, to be used ONLY for "copy link address". We
// don't validate this field in the frontend process.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_unfiltered_link_url(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_unfiltered_link_url.unwrap())(
self.c_object))
}
}
//
// Returns the source URL, if any, for the element that the context menu was
// invoked on. Example of elements with source URLs are img, audio, and video.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_source_url(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_source_url.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the context menu was invoked on an image which has non-
// NULL contents.
//
pub fn has_image_contents(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).has_image_contents.unwrap())(
self.c_object))
}
}
//
// Returns the URL of the top level page that the context menu was invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_page_url(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_page_url.unwrap())(
self.c_object))
}
}
//
// Returns the URL of the subframe that the context menu was invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_frame_url(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_frame_url.unwrap())(
self.c_object))
}
}
//
// Returns the character encoding of the subframe that the context menu was
// invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_frame_charset(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_frame_charset.unwrap())(
self.c_object))
}
}
//
// Returns the type of context node that the context menu was invoked on.
//
pub fn get_media_type(&self) -> types::cef_context_menu_media_type_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_media_type.unwrap())(
self.c_object))
}
}
//
// Returns flags representing the actions supported by the media element, if
// any, that the context menu was invoked on.
//
pub fn get_media_state_flags(
&self) -> types::cef_context_menu_media_state_flags_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_media_state_flags.unwrap())(
self.c_object))
}
}
//
// Returns the text of the selection, if any, that the context menu was
// invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_selection_text(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_selection_text.unwrap())(
self.c_object))
}
}
//
// Returns the text of the misspelled word, if any, that the context menu was
// invoked on.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_misspelled_word(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_misspelled_word.unwrap())(
self.c_object))
}
}
//
// Returns the hash of the misspelled word, if any, that the context menu was
// invoked on.
//
pub fn get_misspelling_hash(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_misspelling_hash.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if suggestions exist, false (0) otherwise. Fills in
// |suggestions| from the spell check service for the misspelled word if there
// is one.
//
pub fn get_dictionary_suggestions(&self,
suggestions: Vec<String>) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_dictionary_suggestions.unwrap())(
self.c_object,
CefWrap::to_c(suggestions)))
}
}
//
// Returns true (1) if the context menu was invoked on an editable node.
//
pub fn is_editable(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_editable.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the context menu was invoked on an editable node where
// spell-check is enabled.
//
pub fn is_spell_check_enabled(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_spell_check_enabled.unwrap())(
self.c_object))
}
}
//
// Returns flags representing the actions supported by the editable node, if
// any, that the context menu was invoked on.
//
pub fn get_edit_state_flags(
&self) -> types::cef_context_menu_edit_state_flags_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_edit_state_flags.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_context_menu_params_t> for CefContextMenuParams {
fn to_c(rust_object: CefContextMenuParams) -> *mut cef_context_menu_params_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_context_menu_params_t) -> CefContextMenuParams {
CefContextMenuParams::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_context_menu_params_t> for Option<CefContextMenuParams> {
fn to_c(rust_object: Option<CefContextMenuParams>) -> *mut cef_context_menu_params_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_context_menu_params_t) -> Option<CefContextMenuParams> {
if c_object.is_null() {
None
} else {
Some(CefContextMenuParams::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,561 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure used for managing cookies. The functions of this structure may be
// called on any thread unless otherwise indicated.
//
#[repr(C)]
pub struct _cef_cookie_manager_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Set the schemes supported by this manager. By default only "http" and
// "https" schemes are supported. 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) -> (
)>,
//
// Visit all cookies. The returned cookies are ordered by longest path, then
// by earliest creation date. Returns false (0) if cookies cannot be accessed.
//
pub visit_all_cookies: Option<extern "C" fn(this: *mut cef_cookie_manager_t,
visitor: *mut interfaces::cef_cookie_visitor_t) -> libc::c_int>,
//
// Visit a subset of cookies. The results are filtered by the given url
// scheme, host, domain and path. If |includeHttpOnly| is true (1) HTTP-only
// cookies will also be included in the results. The returned cookies are
// ordered by longest path, then by earliest creation date. Returns false (0)
// if cookies cannot be accessed.
//
pub visit_url_cookies: Option<extern "C" fn(this: *mut cef_cookie_manager_t,
url: *const types::cef_string_t, includeHttpOnly: libc::c_int,
visitor: *mut interfaces::cef_cookie_visitor_t) -> libc::c_int>,
//
// Sets a cookie given a valid URL and explicit user-provided cookie
// attributes. This function expects each attribute to be well-formed. It will
// check for disallowed characters (e.g. the ';' character is disallowed
// within the cookie value attribute) and will return false (0) without
// setting the cookie if such characters are found. This function must be
// called on the IO thread.
//
pub set_cookie: Option<extern "C" fn(this: *mut cef_cookie_manager_t,
url: *const types::cef_string_t,
cookie: *const interfaces::cef_cookie_t) -> libc::c_int>,
//
// Delete all cookies that match the specified parameters. If both |url| and
// values |cookie_name| are specified all host and domain cookies matching
// both will be deleted. If only |url| is specified all host cookies (but not
// domain cookies) irrespective of path will be deleted. If |url| is NULL all
// cookies for all hosts and domains will be deleted. Returns false (0) if a
// non- NULL invalid URL is specified or if cookies cannot be accessed. This
// function must be called on the IO thread.
//
pub delete_cookies: Option<extern "C" fn(this: *mut cef_cookie_manager_t,
url: *const types::cef_string_t,
cookie_name: *const types::cef_string_t) -> libc::c_int>,
//
// Sets the directory path that will be used for storing cookie data. If
// |path| is NULL data will be stored in memory only. Otherwise, data will be
// stored at the specified |path|. To persist session cookies (cookies without
// an expiry date or validity interval) set |persist_session_cookies| to true
// (1). Session cookies are generally intended to be transient and most Web
// browsers do not persist them. Returns false (0) if cookies cannot be
// accessed.
//
pub set_storage_path: Option<extern "C" fn(this: *mut cef_cookie_manager_t,
path: *const types::cef_string_t,
persist_session_cookies: libc::c_int) -> libc::c_int>,
//
// Flush the backing store (if any) to disk and execute the specified
// |callback| on the IO thread when done. Returns false (0) if cookies cannot
// be accessed.
//
pub flush_store: Option<extern "C" fn(this: *mut cef_cookie_manager_t,
callback: *mut interfaces::cef_completion_callback_t) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_cookie_manager_t = _cef_cookie_manager_t;
//
// Structure used for managing cookies. The functions of this structure may be
// called on any thread unless otherwise indicated.
//
pub struct CefCookieManager {
c_object: *mut cef_cookie_manager_t,
}
impl Clone for CefCookieManager {
fn clone(&self) -> CefCookieManager{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefCookieManager {
c_object: self.c_object,
}
}
}
}
impl Drop for CefCookieManager {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefCookieManager {
pub unsafe fn from_c_object(c_object: *mut cef_cookie_manager_t) -> CefCookieManager {
CefCookieManager {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_cookie_manager_t) -> CefCookieManager {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefCookieManager {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_cookie_manager_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_cookie_manager_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Set the schemes supported by this manager. By default only "http" and
// "https" schemes are supported. Must be called before any cookies are
// accessed.
//
pub fn set_supported_schemes(&self, schemes: Vec<String>) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_supported_schemes.unwrap())(
self.c_object,
CefWrap::to_c(schemes)))
}
}
//
// Visit all cookies. The returned cookies are ordered by longest path, then
// by earliest creation date. Returns false (0) if cookies cannot be accessed.
//
pub fn visit_all_cookies(&self,
visitor: interfaces::CefCookieVisitor) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).visit_all_cookies.unwrap())(
self.c_object,
CefWrap::to_c(visitor)))
}
}
//
// Visit a subset of cookies. The results are filtered by the given url
// scheme, host, domain and path. If |includeHttpOnly| is true (1) HTTP-only
// cookies will also be included in the results. The returned cookies are
// ordered by longest path, then by earliest creation date. Returns false (0)
// if cookies cannot be accessed.
//
pub fn visit_url_cookies(&self, url: &[u16], includeHttpOnly: libc::c_int,
visitor: interfaces::CefCookieVisitor) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).visit_url_cookies.unwrap())(
self.c_object,
CefWrap::to_c(url),
CefWrap::to_c(includeHttpOnly),
CefWrap::to_c(visitor)))
}
}
//
// Sets a cookie given a valid URL and explicit user-provided cookie
// attributes. This function expects each attribute to be well-formed. It will
// check for disallowed characters (e.g. the ';' character is disallowed
// within the cookie value attribute) and will return false (0) without
// setting the cookie if such characters are found. This function must be
// called on the IO thread.
//
pub fn set_cookie(&self, url: &[u16],
cookie: &interfaces::CefCookie) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_cookie.unwrap())(
self.c_object,
CefWrap::to_c(url),
CefWrap::to_c(cookie)))
}
}
//
// Delete all cookies that match the specified parameters. If both |url| and
// values |cookie_name| are specified all host and domain cookies matching
// both will be deleted. If only |url| is specified all host cookies (but not
// domain cookies) irrespective of path will be deleted. If |url| is NULL all
// cookies for all hosts and domains will be deleted. Returns false (0) if a
// non- NULL invalid URL is specified or if cookies cannot be accessed. This
// function must be called on the IO thread.
//
pub fn delete_cookies(&self, url: &[u16],
cookie_name: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).delete_cookies.unwrap())(
self.c_object,
CefWrap::to_c(url),
CefWrap::to_c(cookie_name)))
}
}
//
// Sets the directory path that will be used for storing cookie data. If
// |path| is NULL data will be stored in memory only. Otherwise, data will be
// stored at the specified |path|. To persist session cookies (cookies without
// an expiry date or validity interval) set |persist_session_cookies| to true
// (1). Session cookies are generally intended to be transient and most Web
// browsers do not persist them. Returns false (0) if cookies cannot be
// accessed.
//
pub fn set_storage_path(&self, path: &[u16],
persist_session_cookies: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_storage_path.unwrap())(
self.c_object,
CefWrap::to_c(path),
CefWrap::to_c(persist_session_cookies)))
}
}
//
// Flush the backing store (if any) to disk and execute the specified
// |callback| on the IO thread when done. Returns false (0) if cookies cannot
// be accessed.
//
pub fn flush_store(&self,
callback: interfaces::CefCompletionCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).flush_store.unwrap())(
self.c_object,
CefWrap::to_c(callback)))
}
}
//
// Returns the global cookie manager. By default data will be stored at
// CefSettings.cache_path if specified or in memory otherwise.
//
pub fn get_global_manager() -> interfaces::CefCookieManager {
unsafe {
CefWrap::to_rust(
::cookie::cef_cookie_manager_get_global_manager(
))
}
}
//
// Creates a new cookie manager. If |path| is NULL data will be stored in
// memory only. Otherwise, data will be stored at the specified |path|. To
// persist session cookies (cookies without an expiry date or validity
// interval) set |persist_session_cookies| to true (1). Session cookies are
// generally intended to be transient and most Web browsers do not persist
// them. Returns NULL if creation fails.
//
pub fn create_manager(path: &[u16],
persist_session_cookies: libc::c_int) -> interfaces::CefCookieManager {
unsafe {
CefWrap::to_rust(
::cookie::cef_cookie_manager_create_manager(
CefWrap::to_c(path),
CefWrap::to_c(persist_session_cookies)))
}
}
}
impl CefWrap<*mut cef_cookie_manager_t> for CefCookieManager {
fn to_c(rust_object: CefCookieManager) -> *mut cef_cookie_manager_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_cookie_manager_t) -> CefCookieManager {
CefCookieManager::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_cookie_manager_t> for Option<CefCookieManager> {
fn to_c(rust_object: Option<CefCookieManager>) -> *mut cef_cookie_manager_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_cookie_manager_t) -> Option<CefCookieManager> {
if c_object.is_null() {
None
} else {
Some(CefCookieManager::from_c_object_addref(c_object))
}
}
}
//
// Structure to implement for visiting cookie values. The functions of this
// structure will always be called on the IO thread.
//
#[repr(C)]
pub struct _cef_cookie_visitor_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Method that will be called once for each cookie. |count| is the 0-based
// index for the current cookie. |total| is the total number of cookies. Set
// |deleteCookie| to true (1) to delete the cookie currently being visited.
// Return false (0) to stop visiting cookies. This function may never be
// called if no cookies are found.
//
pub visit: Option<extern "C" fn(this: *mut cef_cookie_visitor_t,
cookie: *const interfaces::cef_cookie_t, count: libc::c_int,
total: libc::c_int, deleteCookie: *mut libc::c_int) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_cookie_visitor_t = _cef_cookie_visitor_t;
//
// Structure to implement for visiting cookie values. The functions of this
// structure will always be called on the IO thread.
//
pub struct CefCookieVisitor {
c_object: *mut cef_cookie_visitor_t,
}
impl Clone for CefCookieVisitor {
fn clone(&self) -> CefCookieVisitor{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefCookieVisitor {
c_object: self.c_object,
}
}
}
}
impl Drop for CefCookieVisitor {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefCookieVisitor {
pub unsafe fn from_c_object(c_object: *mut cef_cookie_visitor_t) -> CefCookieVisitor {
CefCookieVisitor {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_cookie_visitor_t) -> CefCookieVisitor {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefCookieVisitor {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_cookie_visitor_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_cookie_visitor_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Method that will be called once for each cookie. |count| is the 0-based
// index for the current cookie. |total| is the total number of cookies. Set
// |deleteCookie| to true (1) to delete the cookie currently being visited.
// Return false (0) to stop visiting cookies. This function may never be
// called if no cookies are found.
//
pub fn visit(&self, cookie: &interfaces::CefCookie, count: libc::c_int,
total: libc::c_int, deleteCookie: &mut libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).visit.unwrap())(
self.c_object,
CefWrap::to_c(cookie),
CefWrap::to_c(count),
CefWrap::to_c(total),
CefWrap::to_c(deleteCookie)))
}
}
}
impl CefWrap<*mut cef_cookie_visitor_t> for CefCookieVisitor {
fn to_c(rust_object: CefCookieVisitor) -> *mut cef_cookie_visitor_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_cookie_visitor_t) -> CefCookieVisitor {
CefCookieVisitor::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_cookie_visitor_t> for Option<CefCookieVisitor> {
fn to_c(rust_object: Option<CefCookieVisitor>) -> *mut cef_cookie_visitor_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_cookie_visitor_t) -> Option<CefCookieVisitor> {
if c_object.is_null() {
None
} else {
Some(CefCookieVisitor::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,374 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Callback structure for asynchronous continuation of file dialog requests.
//
#[repr(C)]
pub struct _cef_file_dialog_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Continue the file selection with the specified |file_paths|. This may be a
// single value or a list of values depending on the dialog mode. An NULL
// value is treated the same as calling cancel().
//
pub cont: Option<extern "C" fn(this: *mut cef_file_dialog_callback_t,
file_paths: types::cef_string_list_t) -> ()>,
//
// Cancel the file selection.
//
pub cancel: Option<extern "C" fn(this: *mut cef_file_dialog_callback_t) -> (
)>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_file_dialog_callback_t = _cef_file_dialog_callback_t;
//
// Callback structure for asynchronous continuation of file dialog requests.
//
pub struct CefFileDialogCallback {
c_object: *mut cef_file_dialog_callback_t,
}
impl Clone for CefFileDialogCallback {
fn clone(&self) -> CefFileDialogCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefFileDialogCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefFileDialogCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefFileDialogCallback {
pub unsafe fn from_c_object(c_object: *mut cef_file_dialog_callback_t) -> CefFileDialogCallback {
CefFileDialogCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_file_dialog_callback_t) -> CefFileDialogCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefFileDialogCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_file_dialog_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_file_dialog_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Continue the file selection with the specified |file_paths|. This may be a
// single value or a list of values depending on the dialog mode. An NULL
// value is treated the same as calling cancel().
//
pub fn cont(&self, file_paths: Vec<String>) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cont.unwrap())(
self.c_object,
CefWrap::to_c(file_paths)))
}
}
//
// Cancel the file selection.
//
pub fn cancel(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cancel.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_file_dialog_callback_t> for CefFileDialogCallback {
fn to_c(rust_object: CefFileDialogCallback) -> *mut cef_file_dialog_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_file_dialog_callback_t) -> CefFileDialogCallback {
CefFileDialogCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_file_dialog_callback_t> for Option<CefFileDialogCallback> {
fn to_c(rust_object: Option<CefFileDialogCallback>) -> *mut cef_file_dialog_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_file_dialog_callback_t) -> Option<CefFileDialogCallback> {
if c_object.is_null() {
None
} else {
Some(CefFileDialogCallback::from_c_object_addref(c_object))
}
}
}
//
// Implement this structure to handle dialog events. The functions of this
// structure will be called on the browser process UI thread.
//
#[repr(C)]
pub struct _cef_dialog_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called to run a file chooser dialog. |mode| represents the type of dialog
// to display. |title| to the title to be used for the dialog and may be NULL
// to show the default title ("Open" or "Save" depending on the mode).
// |default_file_name| is the default file name to select in the dialog.
// |accept_types| is a list of valid lower-cased MIME types or file extensions
// specified in an input element and is used to restrict selectable files to
// such types. To display a custom dialog return true (1) and execute
// |callback| either inline or at a later time. To display the default dialog
// return false (0).
//
pub on_file_dialog: Option<extern "C" fn(this: *mut cef_dialog_handler_t,
browser: *mut interfaces::cef_browser_t,
mode: types::cef_file_dialog_mode_t, title: *const types::cef_string_t,
default_file_name: *const types::cef_string_t,
accept_types: types::cef_string_list_t,
callback: *mut interfaces::cef_file_dialog_callback_t) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_dialog_handler_t = _cef_dialog_handler_t;
//
// Implement this structure to handle dialog events. The functions of this
// structure will be called on the browser process UI thread.
//
pub struct CefDialogHandler {
c_object: *mut cef_dialog_handler_t,
}
impl Clone for CefDialogHandler {
fn clone(&self) -> CefDialogHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefDialogHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefDialogHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefDialogHandler {
pub unsafe fn from_c_object(c_object: *mut cef_dialog_handler_t) -> CefDialogHandler {
CefDialogHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_dialog_handler_t) -> CefDialogHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefDialogHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_dialog_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_dialog_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called to run a file chooser dialog. |mode| represents the type of dialog
// to display. |title| to the title to be used for the dialog and may be NULL
// to show the default title ("Open" or "Save" depending on the mode).
// |default_file_name| is the default file name to select in the dialog.
// |accept_types| is a list of valid lower-cased MIME types or file extensions
// specified in an input element and is used to restrict selectable files to
// such types. To display a custom dialog return true (1) and execute
// |callback| either inline or at a later time. To display the default dialog
// return false (0).
//
pub fn on_file_dialog(&self, browser: interfaces::CefBrowser,
mode: types::cef_file_dialog_mode_t, title: &[u16],
default_file_name: &[u16], accept_types: Vec<String>,
callback: interfaces::CefFileDialogCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_file_dialog.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(mode),
CefWrap::to_c(title),
CefWrap::to_c(default_file_name),
CefWrap::to_c(accept_types),
CefWrap::to_c(callback)))
}
}
}
impl CefWrap<*mut cef_dialog_handler_t> for CefDialogHandler {
fn to_c(rust_object: CefDialogHandler) -> *mut cef_dialog_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_dialog_handler_t) -> CefDialogHandler {
CefDialogHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_dialog_handler_t> for Option<CefDialogHandler> {
fn to_c(rust_object: Option<CefDialogHandler>) -> *mut cef_dialog_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_dialog_handler_t) -> Option<CefDialogHandler> {
if c_object.is_null() {
None
} else {
Some(CefDialogHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,303 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to handle events related to browser display state.
// The functions of this structure will be called on the UI thread.
//
#[repr(C)]
pub struct _cef_display_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called when a frame's address has changed.
//
pub on_address_change: Option<extern "C" fn(this: *mut cef_display_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
url: *const types::cef_string_t) -> ()>,
//
// Called when the page title changes.
//
pub on_title_change: Option<extern "C" fn(this: *mut cef_display_handler_t,
browser: *mut interfaces::cef_browser_t,
title: *const types::cef_string_t) -> ()>,
//
// 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
// tooltip yourself return true (1). Otherwise, you can optionally modify
// |text| and then return false (0) to allow the browser to display the
// tooltip. When window rendering is disabled the application is responsible
// for drawing tooltips and the return value is ignored.
//
pub on_tooltip: Option<extern "C" fn(this: *mut cef_display_handler_t,
browser: *mut interfaces::cef_browser_t,
text: *mut types::cef_string_t) -> libc::c_int>,
//
// Called when the browser receives a status message. |value| contains the
// text that will be displayed in the status message.
//
pub on_status_message: Option<extern "C" fn(this: *mut cef_display_handler_t,
browser: *mut interfaces::cef_browser_t,
value: *const types::cef_string_t) -> ()>,
//
// Called to display a console message. Return true (1) to stop the message
// from being output to the console.
//
pub on_console_message: Option<extern "C" fn(this: *mut cef_display_handler_t,
browser: *mut interfaces::cef_browser_t,
message: *const types::cef_string_t, source: *const types::cef_string_t,
line: libc::c_int) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_display_handler_t = _cef_display_handler_t;
//
// Implement this structure to handle events related to browser display state.
// The functions of this structure will be called on the UI thread.
//
pub struct CefDisplayHandler {
c_object: *mut cef_display_handler_t,
}
impl Clone for CefDisplayHandler {
fn clone(&self) -> CefDisplayHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefDisplayHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefDisplayHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefDisplayHandler {
pub unsafe fn from_c_object(c_object: *mut cef_display_handler_t) -> CefDisplayHandler {
CefDisplayHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_display_handler_t) -> CefDisplayHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefDisplayHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_display_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_display_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called when a frame's address has changed.
//
pub fn on_address_change(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_address_change.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(url)))
}
}
//
// Called when the page title changes.
//
pub fn on_title_change(&self, browser: interfaces::CefBrowser,
title: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_title_change.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(title)))
}
}
//
// 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
// tooltip yourself return true (1). Otherwise, you can optionally modify
// |text| and then return false (0) to allow the browser to display the
// tooltip. When window rendering is disabled the application is responsible
// for drawing tooltips and the return value is ignored.
//
pub fn on_tooltip(&self, browser: interfaces::CefBrowser,
text: *mut types::cef_string_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_tooltip.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(text)))
}
}
//
// Called when the browser receives a status message. |value| contains the
// text that will be displayed in the status message.
//
pub fn on_status_message(&self, browser: interfaces::CefBrowser,
value: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_status_message.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(value)))
}
}
//
// Called to display a console message. Return true (1) to stop the message
// from being output to the console.
//
pub fn on_console_message(&self, browser: interfaces::CefBrowser,
message: &[u16], source: &[u16], line: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_console_message.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(message),
CefWrap::to_c(source),
CefWrap::to_c(line)))
}
}
}
impl CefWrap<*mut cef_display_handler_t> for CefDisplayHandler {
fn to_c(rust_object: CefDisplayHandler) -> *mut cef_display_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_display_handler_t) -> CefDisplayHandler {
CefDisplayHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_display_handler_t> for Option<CefDisplayHandler> {
fn to_c(rust_object: Option<CefDisplayHandler>) -> *mut cef_display_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_display_handler_t) -> Option<CefDisplayHandler> {
if c_object.is_null() {
None
} else {
Some(CefDisplayHandler::from_c_object_addref(c_object))
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,519 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Callback structure used to asynchronously continue a download.
//
#[repr(C)]
pub struct _cef_before_download_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Call to continue the download. Set |download_path| to the full file path
// for the download including the file name or leave blank to use the
// suggested name and the default temp directory. Set |show_dialog| to true
// (1) if you do wish to show the default "Save As" dialog.
//
pub cont: Option<extern "C" fn(this: *mut cef_before_download_callback_t,
download_path: *const types::cef_string_t, show_dialog: libc::c_int) -> (
)>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_before_download_callback_t = _cef_before_download_callback_t;
//
// Callback structure used to asynchronously continue a download.
//
pub struct CefBeforeDownloadCallback {
c_object: *mut cef_before_download_callback_t,
}
impl Clone for CefBeforeDownloadCallback {
fn clone(&self) -> CefBeforeDownloadCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefBeforeDownloadCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefBeforeDownloadCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefBeforeDownloadCallback {
pub unsafe fn from_c_object(c_object: *mut cef_before_download_callback_t) -> CefBeforeDownloadCallback {
CefBeforeDownloadCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_before_download_callback_t) -> CefBeforeDownloadCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefBeforeDownloadCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_before_download_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_before_download_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Call to continue the download. Set |download_path| to the full file path
// for the download including the file name or leave blank to use the
// suggested name and the default temp directory. Set |show_dialog| to true
// (1) if you do wish to show the default "Save As" dialog.
//
pub fn cont(&self, download_path: &[u16], show_dialog: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cont.unwrap())(
self.c_object,
CefWrap::to_c(download_path),
CefWrap::to_c(show_dialog)))
}
}
}
impl CefWrap<*mut cef_before_download_callback_t> for CefBeforeDownloadCallback {
fn to_c(rust_object: CefBeforeDownloadCallback) -> *mut cef_before_download_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_before_download_callback_t) -> CefBeforeDownloadCallback {
CefBeforeDownloadCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_before_download_callback_t> for Option<CefBeforeDownloadCallback> {
fn to_c(rust_object: Option<CefBeforeDownloadCallback>) -> *mut cef_before_download_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_before_download_callback_t) -> Option<CefBeforeDownloadCallback> {
if c_object.is_null() {
None
} else {
Some(CefBeforeDownloadCallback::from_c_object_addref(c_object))
}
}
}
//
// Callback structure used to asynchronously cancel a download.
//
#[repr(C)]
pub struct _cef_download_item_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Call to cancel the download.
//
pub cancel: Option<extern "C" fn(this: *mut cef_download_item_callback_t) -> (
)>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_download_item_callback_t = _cef_download_item_callback_t;
//
// Callback structure used to asynchronously cancel a download.
//
pub struct CefDownloadItemCallback {
c_object: *mut cef_download_item_callback_t,
}
impl Clone for CefDownloadItemCallback {
fn clone(&self) -> CefDownloadItemCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefDownloadItemCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefDownloadItemCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefDownloadItemCallback {
pub unsafe fn from_c_object(c_object: *mut cef_download_item_callback_t) -> CefDownloadItemCallback {
CefDownloadItemCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_download_item_callback_t) -> CefDownloadItemCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefDownloadItemCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_download_item_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_download_item_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Call to cancel the download.
//
pub fn cancel(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cancel.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_download_item_callback_t> for CefDownloadItemCallback {
fn to_c(rust_object: CefDownloadItemCallback) -> *mut cef_download_item_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_download_item_callback_t) -> CefDownloadItemCallback {
CefDownloadItemCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_download_item_callback_t> for Option<CefDownloadItemCallback> {
fn to_c(rust_object: Option<CefDownloadItemCallback>) -> *mut cef_download_item_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_download_item_callback_t) -> Option<CefDownloadItemCallback> {
if c_object.is_null() {
None
} else {
Some(CefDownloadItemCallback::from_c_object_addref(c_object))
}
}
}
//
// Structure used to handle file downloads. The functions of this structure will
// called on the browser process UI thread.
//
#[repr(C)]
pub struct _cef_download_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called before a download begins. |suggested_name| is the suggested name for
// the download file. By default the download will be canceled. Execute
// |callback| either asynchronously or in this function to continue the
// download if desired. Do not keep a reference to |download_item| outside of
// this function.
//
pub on_before_download: Option<extern "C" fn(
this: *mut cef_download_handler_t,
browser: *mut interfaces::cef_browser_t,
download_item: *mut interfaces::cef_download_item_t,
suggested_name: *const types::cef_string_t,
callback: *mut interfaces::cef_before_download_callback_t) -> ()>,
//
// Called when a download's status or progress information has been updated.
// This may be called multiple times before and after on_before_download().
// Execute |callback| either asynchronously or in this function to cancel the
// download if desired. Do not keep a reference to |download_item| outside of
// this function.
//
pub on_download_updated: Option<extern "C" fn(
this: *mut cef_download_handler_t,
browser: *mut interfaces::cef_browser_t,
download_item: *mut interfaces::cef_download_item_t,
callback: *mut interfaces::cef_download_item_callback_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_download_handler_t = _cef_download_handler_t;
//
// Structure used to handle file downloads. The functions of this structure will
// called on the browser process UI thread.
//
pub struct CefDownloadHandler {
c_object: *mut cef_download_handler_t,
}
impl Clone for CefDownloadHandler {
fn clone(&self) -> CefDownloadHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefDownloadHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefDownloadHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefDownloadHandler {
pub unsafe fn from_c_object(c_object: *mut cef_download_handler_t) -> CefDownloadHandler {
CefDownloadHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_download_handler_t) -> CefDownloadHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefDownloadHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_download_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_download_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called before a download begins. |suggested_name| is the suggested name for
// the download file. By default the download will be canceled. Execute
// |callback| either asynchronously or in this function to continue the
// download if desired. Do not keep a reference to |download_item| outside of
// this function.
//
pub fn on_before_download(&self, browser: interfaces::CefBrowser,
download_item: interfaces::CefDownloadItem, suggested_name: &[u16],
callback: interfaces::CefBeforeDownloadCallback) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_before_download.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(download_item),
CefWrap::to_c(suggested_name),
CefWrap::to_c(callback)))
}
}
//
// Called when a download's status or progress information has been updated.
// This may be called multiple times before and after on_before_download().
// Execute |callback| either asynchronously or in this function to cancel the
// download if desired. Do not keep a reference to |download_item| outside of
// this function.
//
pub fn on_download_updated(&self, browser: interfaces::CefBrowser,
download_item: interfaces::CefDownloadItem,
callback: interfaces::CefDownloadItemCallback) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_download_updated.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(download_item),
CefWrap::to_c(callback)))
}
}
}
impl CefWrap<*mut cef_download_handler_t> for CefDownloadHandler {
fn to_c(rust_object: CefDownloadHandler) -> *mut cef_download_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_download_handler_t) -> CefDownloadHandler {
CefDownloadHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_download_handler_t> for Option<CefDownloadHandler> {
fn to_c(rust_object: Option<CefDownloadHandler>) -> *mut cef_download_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_download_handler_t) -> Option<CefDownloadHandler> {
if c_object.is_null() {
None
} else {
Some(CefDownloadHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,495 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure used to represent a download item.
//
#[repr(C)]
pub struct _cef_download_item_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
//
pub is_valid: Option<extern "C" fn(
this: *mut cef_download_item_t) -> libc::c_int>,
//
// Returns true (1) if the download is in progress.
//
pub is_in_progress: Option<extern "C" fn(
this: *mut cef_download_item_t) -> libc::c_int>,
//
// Returns true (1) if the download is complete.
//
pub is_complete: Option<extern "C" fn(
this: *mut cef_download_item_t) -> libc::c_int>,
//
// Returns true (1) if the download has been canceled or interrupted.
//
pub is_canceled: Option<extern "C" fn(
this: *mut cef_download_item_t) -> libc::c_int>,
//
// Returns a simple speed estimate in bytes/s.
//
pub get_current_speed: Option<extern "C" fn(
this: *mut cef_download_item_t) -> i64>,
//
// Returns the rough percent complete or -1 if the receive total size is
// unknown.
//
pub get_percent_complete: Option<extern "C" fn(
this: *mut cef_download_item_t) -> libc::c_int>,
//
// Returns the total number of bytes.
//
pub get_total_bytes: Option<extern "C" fn(
this: *mut cef_download_item_t) -> i64>,
//
// Returns the number of received bytes.
//
pub get_received_bytes: Option<extern "C" fn(
this: *mut cef_download_item_t) -> i64>,
//
// Returns the time that the download started.
//
pub get_start_time: Option<extern "C" fn(
this: *mut cef_download_item_t) -> types::cef_time_t>,
//
// Returns the time that the download ended.
//
pub get_end_time: Option<extern "C" fn(
this: *mut cef_download_item_t) -> types::cef_time_t>,
//
// Returns the full path to the downloaded or downloading file.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_full_path: Option<extern "C" fn(
this: *mut cef_download_item_t) -> types::cef_string_userfree_t>,
//
// Returns the unique identifier for this download.
//
pub get_id: Option<extern "C" fn(this: *mut cef_download_item_t) -> u32>,
//
// Returns the URL.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_url: Option<extern "C" fn(
this: *mut cef_download_item_t) -> types::cef_string_userfree_t>,
//
// Returns the suggested file name.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_suggested_file_name: Option<extern "C" fn(
this: *mut cef_download_item_t) -> types::cef_string_userfree_t>,
//
// Returns the content disposition.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_content_disposition: Option<extern "C" fn(
this: *mut cef_download_item_t) -> types::cef_string_userfree_t>,
//
// Returns the mime type.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_mime_type: Option<extern "C" fn(
this: *mut cef_download_item_t) -> types::cef_string_userfree_t>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_download_item_t = _cef_download_item_t;
//
// Structure used to represent a download item.
//
pub struct CefDownloadItem {
c_object: *mut cef_download_item_t,
}
impl Clone for CefDownloadItem {
fn clone(&self) -> CefDownloadItem{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefDownloadItem {
c_object: self.c_object,
}
}
}
}
impl Drop for CefDownloadItem {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefDownloadItem {
pub unsafe fn from_c_object(c_object: *mut cef_download_item_t) -> CefDownloadItem {
CefDownloadItem {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_download_item_t) -> CefDownloadItem {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefDownloadItem {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_download_item_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_download_item_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
//
pub fn is_valid(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_valid.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the download is in progress.
//
pub fn is_in_progress(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_in_progress.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the download is complete.
//
pub fn is_complete(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_complete.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the download has been canceled or interrupted.
//
pub fn is_canceled(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_canceled.unwrap())(
self.c_object))
}
}
//
// Returns a simple speed estimate in bytes/s.
//
pub fn get_current_speed(&self) -> i64 {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_current_speed.unwrap())(
self.c_object))
}
}
//
// Returns the rough percent complete or -1 if the receive total size is
// unknown.
//
pub fn get_percent_complete(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_percent_complete.unwrap())(
self.c_object))
}
}
//
// Returns the total number of bytes.
//
pub fn get_total_bytes(&self) -> i64 {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_total_bytes.unwrap())(
self.c_object))
}
}
//
// Returns the number of received bytes.
//
pub fn get_received_bytes(&self) -> i64 {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_received_bytes.unwrap())(
self.c_object))
}
}
//
// Returns the time that the download started.
//
pub fn get_start_time(&self) -> types::cef_time_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_start_time.unwrap())(
self.c_object))
}
}
//
// Returns the time that the download ended.
//
pub fn get_end_time(&self) -> types::cef_time_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_end_time.unwrap())(
self.c_object))
}
}
//
// Returns the full path to the downloaded or downloading file.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_full_path(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_full_path.unwrap())(
self.c_object))
}
}
//
// Returns the unique identifier for this download.
//
pub fn get_id(&self) -> u32 {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_id.unwrap())(
self.c_object))
}
}
//
// Returns the URL.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_url(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_url.unwrap())(
self.c_object))
}
}
//
// Returns the suggested file name.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_suggested_file_name(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_suggested_file_name.unwrap())(
self.c_object))
}
}
//
// Returns the content disposition.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_content_disposition(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_content_disposition.unwrap())(
self.c_object))
}
}
//
// Returns the mime type.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_mime_type(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_mime_type.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_download_item_t> for CefDownloadItem {
fn to_c(rust_object: CefDownloadItem) -> *mut cef_download_item_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_download_item_t) -> CefDownloadItem {
CefDownloadItem::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_download_item_t> for Option<CefDownloadItem> {
fn to_c(rust_object: Option<CefDownloadItem>) -> *mut cef_download_item_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_download_item_t) -> Option<CefDownloadItem> {
if c_object.is_null() {
None
} else {
Some(CefDownloadItem::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,653 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure used to represent drag data. The functions of this structure may be
// called on any thread.
//
#[repr(C)]
pub struct _cef_drag_data_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Returns a copy of the current object.
//
pub clone: Option<extern "C" fn(
this: *mut cef_drag_data_t) -> *mut interfaces::cef_drag_data_t>,
//
// Returns true (1) if this object is read-only.
//
pub is_read_only: Option<extern "C" fn(
this: *mut cef_drag_data_t) -> libc::c_int>,
//
// Returns true (1) if the drag data is a link.
//
pub is_link: Option<extern "C" fn(this: *mut cef_drag_data_t) -> libc::c_int>,
//
// Returns true (1) if the drag data is a text or html fragment.
//
pub is_fragment: Option<extern "C" fn(
this: *mut cef_drag_data_t) -> libc::c_int>,
//
// Returns true (1) if the drag data is a file.
//
pub is_file: Option<extern "C" fn(this: *mut cef_drag_data_t) -> libc::c_int>,
//
// Return the link URL that is being dragged.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_link_url: Option<extern "C" fn(
this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>,
//
// Return the title associated with the link being dragged.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_link_title: Option<extern "C" fn(
this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>,
//
// Return the metadata, if any, associated with the link being dragged.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_link_metadata: Option<extern "C" fn(
this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>,
//
// Return the plain text fragment that is being dragged.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_fragment_text: Option<extern "C" fn(
this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>,
//
// Return the text/html fragment that is being dragged.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_fragment_html: Option<extern "C" fn(
this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>,
//
// Return the base URL that the fragment came from. This value is used for
// resolving relative URLs and may be NULL.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_fragment_base_url: Option<extern "C" fn(
this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>,
//
// Return the name of the file being dragged out of the browser window.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_file_name: Option<extern "C" fn(
this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>,
//
// Write the contents of the file being dragged out of the web view into
// |writer|. Returns the number of bytes sent to |writer|. If |writer| is NULL
// this function will return the size of the file contents in bytes. Call
// get_file_name() to get a suggested name for the file.
//
pub get_file_contents: Option<extern "C" fn(this: *mut cef_drag_data_t,
writer: *mut interfaces::cef_stream_writer_t) -> libc::size_t>,
//
// Retrieve the list of file names that are being dragged into the browser
// window.
//
pub get_file_names: Option<extern "C" fn(this: *mut cef_drag_data_t,
names: types::cef_string_list_t) -> libc::c_int>,
//
// Set the link URL that is being dragged.
//
pub set_link_url: Option<extern "C" fn(this: *mut cef_drag_data_t,
url: *const types::cef_string_t) -> ()>,
//
// Set the title associated with the link being dragged.
//
pub set_link_title: Option<extern "C" fn(this: *mut cef_drag_data_t,
title: *const types::cef_string_t) -> ()>,
//
// Set the metadata associated with the link being dragged.
//
pub set_link_metadata: Option<extern "C" fn(this: *mut cef_drag_data_t,
data: *const types::cef_string_t) -> ()>,
//
// Set the plain text fragment that is being dragged.
//
pub set_fragment_text: Option<extern "C" fn(this: *mut cef_drag_data_t,
text: *const types::cef_string_t) -> ()>,
//
// Set the text/html fragment that is being dragged.
//
pub set_fragment_html: Option<extern "C" fn(this: *mut cef_drag_data_t,
html: *const types::cef_string_t) -> ()>,
//
// Set the base URL that the fragment came from.
//
pub set_fragment_base_url: Option<extern "C" fn(this: *mut cef_drag_data_t,
base_url: *const types::cef_string_t) -> ()>,
//
// Reset the file contents. You should do this before calling
// cef_browser_host_t::DragTargetDragEnter as the web view does not allow us
// to drag in this kind of data.
//
pub reset_file_contents: Option<extern "C" fn(this: *mut cef_drag_data_t) -> (
)>,
//
// Add a file that is being dragged into the webview.
//
pub add_file: Option<extern "C" fn(this: *mut cef_drag_data_t,
path: *const types::cef_string_t,
display_name: *const types::cef_string_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_drag_data_t = _cef_drag_data_t;
//
// Structure used to represent drag data. The functions of this structure may be
// called on any thread.
//
pub struct CefDragData {
c_object: *mut cef_drag_data_t,
}
impl Clone for CefDragData {
fn clone(&self) -> CefDragData{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefDragData {
c_object: self.c_object,
}
}
}
}
impl Drop for CefDragData {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefDragData {
pub unsafe fn from_c_object(c_object: *mut cef_drag_data_t) -> CefDragData {
CefDragData {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_drag_data_t) -> CefDragData {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefDragData {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_drag_data_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_drag_data_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Returns a copy of the current object.
//
pub fn clone(&self) -> interfaces::CefDragData {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).clone.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if this object is read-only.
//
pub fn is_read_only(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_read_only.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the drag data is a link.
//
pub fn is_link(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_link.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the drag data is a text or html fragment.
//
pub fn is_fragment(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_fragment.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the drag data is a file.
//
pub fn is_file(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_file.unwrap())(
self.c_object))
}
}
//
// Return the link URL that is being dragged.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_link_url(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_link_url.unwrap())(
self.c_object))
}
}
//
// Return the title associated with the link being dragged.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_link_title(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_link_title.unwrap())(
self.c_object))
}
}
//
// Return the metadata, if any, associated with the link being dragged.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_link_metadata(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_link_metadata.unwrap())(
self.c_object))
}
}
//
// Return the plain text fragment that is being dragged.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_fragment_text(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_fragment_text.unwrap())(
self.c_object))
}
}
//
// Return the text/html fragment that is being dragged.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_fragment_html(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_fragment_html.unwrap())(
self.c_object))
}
}
//
// Return the base URL that the fragment came from. This value is used for
// resolving relative URLs and may be NULL.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_fragment_base_url(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_fragment_base_url.unwrap())(
self.c_object))
}
}
//
// Return the name of the file being dragged out of the browser window.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_file_name(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_file_name.unwrap())(
self.c_object))
}
}
//
// Write the contents of the file being dragged out of the web view into
// |writer|. Returns the number of bytes sent to |writer|. If |writer| is NULL
// this function will return the size of the file contents in bytes. Call
// get_file_name() to get a suggested name for the file.
//
pub fn get_file_contents(&self,
writer: interfaces::CefStreamWriter) -> libc::size_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_file_contents.unwrap())(
self.c_object,
CefWrap::to_c(writer)))
}
}
//
// Retrieve the list of file names that are being dragged into the browser
// window.
//
pub fn get_file_names(&self, names: Vec<String>) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_file_names.unwrap())(
self.c_object,
CefWrap::to_c(names)))
}
}
//
// Set the link URL that is being dragged.
//
pub fn set_link_url(&self, url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_link_url.unwrap())(
self.c_object,
CefWrap::to_c(url)))
}
}
//
// Set the title associated with the link being dragged.
//
pub fn set_link_title(&self, title: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_link_title.unwrap())(
self.c_object,
CefWrap::to_c(title)))
}
}
//
// Set the metadata associated with the link being dragged.
//
pub fn set_link_metadata(&self, data: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_link_metadata.unwrap())(
self.c_object,
CefWrap::to_c(data)))
}
}
//
// Set the plain text fragment that is being dragged.
//
pub fn set_fragment_text(&self, text: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_fragment_text.unwrap())(
self.c_object,
CefWrap::to_c(text)))
}
}
//
// Set the text/html fragment that is being dragged.
//
pub fn set_fragment_html(&self, html: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_fragment_html.unwrap())(
self.c_object,
CefWrap::to_c(html)))
}
}
//
// Set the base URL that the fragment came from.
//
pub fn set_fragment_base_url(&self, base_url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_fragment_base_url.unwrap())(
self.c_object,
CefWrap::to_c(base_url)))
}
}
//
// Reset the file contents. You should do this before calling
// cef_browser_host_t::DragTargetDragEnter as the web view does not allow us
// to drag in this kind of data.
//
pub fn reset_file_contents(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).reset_file_contents.unwrap())(
self.c_object))
}
}
//
// Add a file that is being dragged into the webview.
//
pub fn add_file(&self, path: &[u16], display_name: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).add_file.unwrap())(
self.c_object,
CefWrap::to_c(path),
CefWrap::to_c(display_name)))
}
}
//
// Create a new cef_drag_data_t object.
//
pub fn create() -> interfaces::CefDragData {
unsafe {
CefWrap::to_rust(
::drag_data::cef_drag_data_create(
))
}
}
}
impl CefWrap<*mut cef_drag_data_t> for CefDragData {
fn to_c(rust_object: CefDragData) -> *mut cef_drag_data_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_drag_data_t) -> CefDragData {
CefDragData::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_drag_data_t> for Option<CefDragData> {
fn to_c(rust_object: Option<CefDragData>) -> *mut cef_drag_data_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_drag_data_t) -> Option<CefDragData> {
if c_object.is_null() {
None
} else {
Some(CefDragData::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,197 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to handle events related to dragging. The functions
// of this structure will be called on the UI thread.
//
#[repr(C)]
pub struct _cef_drag_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called when an external drag event enters the browser window. |dragData|
// contains the drag event data and |mask| represents the type of drag
// operation. Return false (0) for default drag handling behavior or true (1)
// to cancel the drag event.
//
pub on_drag_enter: Option<extern "C" fn(this: *mut cef_drag_handler_t,
browser: *mut interfaces::cef_browser_t,
dragData: *mut interfaces::cef_drag_data_t,
mask: types::cef_drag_operations_mask_t) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_drag_handler_t = _cef_drag_handler_t;
//
// Implement this structure to handle events related to dragging. The functions
// of this structure will be called on the UI thread.
//
pub struct CefDragHandler {
c_object: *mut cef_drag_handler_t,
}
impl Clone for CefDragHandler {
fn clone(&self) -> CefDragHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefDragHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefDragHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefDragHandler {
pub unsafe fn from_c_object(c_object: *mut cef_drag_handler_t) -> CefDragHandler {
CefDragHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_drag_handler_t) -> CefDragHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefDragHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_drag_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_drag_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called when an external drag event enters the browser window. |dragData|
// contains the drag event data and |mask| represents the type of drag
// operation. Return false (0) for default drag handling behavior or true (1)
// to cancel the drag event.
//
pub fn on_drag_enter(&self, browser: interfaces::CefBrowser,
dragData: interfaces::CefDragData,
mask: types::cef_drag_operations_mask_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_drag_enter.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(dragData),
CefWrap::to_c(mask)))
}
}
}
impl CefWrap<*mut cef_drag_handler_t> for CefDragHandler {
fn to_c(rust_object: CefDragHandler) -> *mut cef_drag_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_drag_handler_t) -> CefDragHandler {
CefDragHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_drag_handler_t> for Option<CefDragHandler> {
fn to_c(rust_object: Option<CefDragHandler>) -> *mut cef_drag_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_drag_handler_t) -> Option<CefDragHandler> {
if c_object.is_null() {
None
} else {
Some(CefDragHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,242 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to handle events related to focus. The functions of
// this structure will be called on the UI thread.
//
#[repr(C)]
pub struct _cef_focus_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called when the browser component is about to loose focus. For instance, if
// focus was on the last HTML element and the user pressed the TAB key. |next|
// will be true (1) if the browser is giving focus to the next component and
// false (0) if the browser is giving focus to the previous component.
//
pub on_take_focus: Option<extern "C" fn(this: *mut cef_focus_handler_t,
browser: *mut interfaces::cef_browser_t, next: libc::c_int) -> ()>,
//
// Called when the browser component is requesting focus. |source| indicates
// where the focus request is originating from. Return false (0) to allow the
// focus to be set or true (1) to cancel setting the focus.
//
pub on_set_focus: Option<extern "C" fn(this: *mut cef_focus_handler_t,
browser: *mut interfaces::cef_browser_t,
source: types::cef_focus_source_t) -> libc::c_int>,
//
// Called when the browser component has received focus.
//
pub on_got_focus: Option<extern "C" fn(this: *mut cef_focus_handler_t,
browser: *mut interfaces::cef_browser_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_focus_handler_t = _cef_focus_handler_t;
//
// Implement this structure to handle events related to focus. The functions of
// this structure will be called on the UI thread.
//
pub struct CefFocusHandler {
c_object: *mut cef_focus_handler_t,
}
impl Clone for CefFocusHandler {
fn clone(&self) -> CefFocusHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefFocusHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefFocusHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefFocusHandler {
pub unsafe fn from_c_object(c_object: *mut cef_focus_handler_t) -> CefFocusHandler {
CefFocusHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_focus_handler_t) -> CefFocusHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefFocusHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_focus_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_focus_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called when the browser component is about to loose focus. For instance, if
// focus was on the last HTML element and the user pressed the TAB key. |next|
// will be true (1) if the browser is giving focus to the next component and
// false (0) if the browser is giving focus to the previous component.
//
pub fn on_take_focus(&self, browser: interfaces::CefBrowser,
next: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_take_focus.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(next)))
}
}
//
// Called when the browser component is requesting focus. |source| indicates
// where the focus request is originating from. Return false (0) to allow the
// focus to be set or true (1) to cancel setting the focus.
//
pub fn on_set_focus(&self, browser: interfaces::CefBrowser,
source: types::cef_focus_source_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_set_focus.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(source)))
}
}
//
// Called when the browser component has received focus.
//
pub fn on_got_focus(&self, browser: interfaces::CefBrowser) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_got_focus.unwrap())(
self.c_object,
CefWrap::to_c(browser)))
}
}
}
impl CefWrap<*mut cef_focus_handler_t> for CefFocusHandler {
fn to_c(rust_object: CefFocusHandler) -> *mut cef_focus_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_focus_handler_t) -> CefFocusHandler {
CefFocusHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_focus_handler_t> for Option<CefFocusHandler> {
fn to_c(rust_object: Option<CefFocusHandler>) -> *mut cef_focus_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_focus_handler_t) -> Option<CefFocusHandler> {
if c_object.is_null() {
None
} else {
Some(CefFocusHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,687 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure used to represent a frame in the browser window. When used in the
// browser process the functions of this structure may be called on any thread
// unless otherwise indicated in the comments. When used in the render process
// the functions of this structure may only be called on the main thread.
//
#[repr(C)]
pub struct _cef_frame_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// True if this object is currently attached to a valid frame.
//
pub is_valid: Option<extern "C" fn(this: *mut cef_frame_t) -> libc::c_int>,
//
// Execute undo in this frame.
//
pub undo: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>,
//
// Execute redo in this frame.
//
pub redo: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>,
//
// Execute cut in this frame.
//
pub cut: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>,
//
// Execute copy in this frame.
//
pub copy: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>,
//
// Execute paste in this frame.
//
pub paste: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>,
//
// Execute delete in this frame.
//
pub del: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>,
//
// Execute select all in this frame.
//
pub select_all: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>,
//
// Save this frame's HTML source to a temporary file and open it in the
// default text viewing application. This function can only be called from the
// browser process.
//
pub view_source: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>,
//
// Retrieve this frame's HTML source as a string sent to the specified
// visitor.
//
pub get_source: Option<extern "C" fn(this: *mut cef_frame_t,
visitor: *mut interfaces::cef_string_visitor_t) -> ()>,
//
// Retrieve this frame's display text as a string sent to the specified
// visitor.
//
pub get_text: Option<extern "C" fn(this: *mut cef_frame_t,
visitor: *mut interfaces::cef_string_visitor_t) -> ()>,
//
// Load the request represented by the |request| object.
//
pub load_request: Option<extern "C" fn(this: *mut cef_frame_t,
request: *mut interfaces::cef_request_t) -> ()>,
//
// Load the specified |url|.
//
pub load_url: Option<extern "C" fn(this: *mut cef_frame_t,
url: *const types::cef_string_t) -> ()>,
//
// Load the contents of |string_val| with the specified dummy |url|. |url|
// should have a standard scheme (for example, http scheme) or behaviors like
// link clicks and web security restrictions may not behave as expected.
//
pub load_string: Option<extern "C" fn(this: *mut cef_frame_t,
string_val: *const types::cef_string_t,
url: *const types::cef_string_t) -> ()>,
//
// Execute a string of JavaScript code in this frame. The |script_url|
// parameter is the URL where the script in question can be found, if any. The
// renderer may request this URL to show the developer the source of the
// error. The |start_line| parameter is the base line number to use for error
// reporting.
//
pub execute_java_script: Option<extern "C" fn(this: *mut cef_frame_t,
code: *const types::cef_string_t, script_url: *const types::cef_string_t,
start_line: libc::c_int) -> ()>,
//
// Returns true (1) if this is the main (top-level) frame.
//
pub is_main: Option<extern "C" fn(this: *mut cef_frame_t) -> libc::c_int>,
//
// Returns true (1) if this is the focused frame.
//
pub is_focused: Option<extern "C" fn(this: *mut cef_frame_t) -> libc::c_int>,
//
// Returns the name for this frame. If the frame has an assigned name (for
// example, set via the iframe "name" attribute) then that value will be
// returned. Otherwise a unique name will be constructed based on the frame
// parent hierarchy. The main (top-level) frame will always have an NULL name
// value.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_name: Option<extern "C" fn(
this: *mut cef_frame_t) -> types::cef_string_userfree_t>,
//
// Returns the globally unique identifier for this frame.
//
pub get_identifier: Option<extern "C" fn(this: *mut cef_frame_t) -> i64>,
//
// Returns the parent of this frame or NULL if this is the main (top-level)
// frame.
//
pub get_parent: Option<extern "C" fn(
this: *mut cef_frame_t) -> *mut interfaces::cef_frame_t>,
//
// Returns the URL currently loaded in this frame.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_url: Option<extern "C" fn(
this: *mut cef_frame_t) -> types::cef_string_userfree_t>,
//
// Returns the browser that this frame belongs to.
//
pub get_browser: Option<extern "C" fn(
this: *mut cef_frame_t) -> *mut interfaces::cef_browser_t>,
//
// Get the V8 context associated with the frame. This function can only be
// called from the render process.
//
pub get_v8context: Option<extern "C" fn(
this: *mut cef_frame_t) -> *mut interfaces::cef_v8context_t>,
//
// Visit the DOM document. This function can only be called from the render
// process.
//
pub visit_dom: Option<extern "C" fn(this: *mut cef_frame_t,
visitor: *mut interfaces::cef_domvisitor_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_frame_t = _cef_frame_t;
//
// Structure used to represent a frame in the browser window. When used in the
// browser process the functions of this structure may be called on any thread
// unless otherwise indicated in the comments. When used in the render process
// the functions of this structure may only be called on the main thread.
//
pub struct CefFrame {
c_object: *mut cef_frame_t,
}
impl Clone for CefFrame {
fn clone(&self) -> CefFrame{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefFrame {
c_object: self.c_object,
}
}
}
}
impl Drop for CefFrame {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefFrame {
pub unsafe fn from_c_object(c_object: *mut cef_frame_t) -> CefFrame {
CefFrame {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_frame_t) -> CefFrame {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefFrame {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_frame_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_frame_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// True if this object is currently attached to a valid frame.
//
pub fn is_valid(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_valid.unwrap())(
self.c_object))
}
}
//
// Execute undo in this frame.
//
pub fn undo(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).undo.unwrap())(
self.c_object))
}
}
//
// Execute redo in this frame.
//
pub fn redo(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).redo.unwrap())(
self.c_object))
}
}
//
// Execute cut in this frame.
//
pub fn cut(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cut.unwrap())(
self.c_object))
}
}
//
// Execute copy in this frame.
//
pub fn copy(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).copy.unwrap())(
self.c_object))
}
}
//
// Execute paste in this frame.
//
pub fn paste(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).paste.unwrap())(
self.c_object))
}
}
//
// Execute delete in this frame.
//
pub fn del(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).del.unwrap())(
self.c_object))
}
}
//
// Execute select all in this frame.
//
pub fn select_all(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).select_all.unwrap())(
self.c_object))
}
}
//
// Save this frame's HTML source to a temporary file and open it in the
// default text viewing application. This function can only be called from the
// browser process.
//
pub fn view_source(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).view_source.unwrap())(
self.c_object))
}
}
//
// Retrieve this frame's HTML source as a string sent to the specified
// visitor.
//
pub fn get_source(&self, visitor: interfaces::CefStringVisitor) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_source.unwrap())(
self.c_object,
CefWrap::to_c(visitor)))
}
}
//
// Retrieve this frame's display text as a string sent to the specified
// visitor.
//
pub fn get_text(&self, visitor: interfaces::CefStringVisitor) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_text.unwrap())(
self.c_object,
CefWrap::to_c(visitor)))
}
}
//
// Load the request represented by the |request| object.
//
pub fn load_request(&self, request: interfaces::CefRequest) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).load_request.unwrap())(
self.c_object,
CefWrap::to_c(request)))
}
}
//
// Load the specified |url|.
//
pub fn load_url(&self, url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).load_url.unwrap())(
self.c_object,
CefWrap::to_c(url)))
}
}
//
// Load the contents of |string_val| with the specified dummy |url|. |url|
// should have a standard scheme (for example, http scheme) or behaviors like
// link clicks and web security restrictions may not behave as expected.
//
pub fn load_string(&self, string_val: &[u16], url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).load_string.unwrap())(
self.c_object,
CefWrap::to_c(string_val),
CefWrap::to_c(url)))
}
}
//
// Execute a string of JavaScript code in this frame. The |script_url|
// parameter is the URL where the script in question can be found, if any. The
// renderer may request this URL to show the developer the source of the
// error. The |start_line| parameter is the base line number to use for error
// reporting.
//
pub fn execute_java_script(&self, code: &[u16], script_url: &[u16],
start_line: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).execute_java_script.unwrap())(
self.c_object,
CefWrap::to_c(code),
CefWrap::to_c(script_url),
CefWrap::to_c(start_line)))
}
}
//
// Returns true (1) if this is the main (top-level) frame.
//
pub fn is_main(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_main.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if this is the focused frame.
//
pub fn is_focused(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_focused.unwrap())(
self.c_object))
}
}
//
// Returns the name for this frame. If the frame has an assigned name (for
// example, set via the iframe "name" attribute) then that value will be
// returned. Otherwise a unique name will be constructed based on the frame
// parent hierarchy. The main (top-level) frame will always have an NULL name
// value.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_name(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_name.unwrap())(
self.c_object))
}
}
//
// Returns the globally unique identifier for this frame.
//
pub fn get_identifier(&self) -> i64 {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_identifier.unwrap())(
self.c_object))
}
}
//
// Returns the parent of this frame or NULL if this is the main (top-level)
// frame.
//
pub fn get_parent(&self) -> interfaces::CefFrame {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_parent.unwrap())(
self.c_object))
}
}
//
// Returns the URL currently loaded in this frame.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_url(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_url.unwrap())(
self.c_object))
}
}
//
// Returns the browser that this frame belongs to.
//
pub fn get_browser(&self) -> interfaces::CefBrowser {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_browser.unwrap())(
self.c_object))
}
}
//
// Get the V8 context associated with the frame. This function can only be
// called from the render process.
//
pub fn get_v8context(&self) -> interfaces::CefV8Context {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_v8context.unwrap())(
self.c_object))
}
}
//
// Visit the DOM document. This function can only be called from the render
// process.
//
pub fn visit_dom(&self, visitor: interfaces::CefDOMVisitor) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).visit_dom.unwrap())(
self.c_object,
CefWrap::to_c(visitor)))
}
}
}
impl CefWrap<*mut cef_frame_t> for CefFrame {
fn to_c(rust_object: CefFrame) -> *mut cef_frame_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_frame_t) -> CefFrame {
CefFrame::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_frame_t> for Option<CefFrame> {
fn to_c(rust_object: Option<CefFrame>) -> *mut cef_frame_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_frame_t) -> Option<CefFrame> {
if c_object.is_null() {
None
} else {
Some(CefFrame::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,189 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to receive geolocation updates. The functions of
// this structure will be called on the browser process UI thread.
//
#[repr(C)]
pub struct _cef_get_geolocation_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called with the 'best available' location information or, if the location
// update failed, with error information.
//
pub on_location_update: Option<extern "C" fn(
this: *mut cef_get_geolocation_callback_t,
position: *const interfaces::cef_geoposition_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_get_geolocation_callback_t = _cef_get_geolocation_callback_t;
//
// Implement this structure to receive geolocation updates. The functions of
// this structure will be called on the browser process UI thread.
//
pub struct CefGetGeolocationCallback {
c_object: *mut cef_get_geolocation_callback_t,
}
impl Clone for CefGetGeolocationCallback {
fn clone(&self) -> CefGetGeolocationCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefGetGeolocationCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefGetGeolocationCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefGetGeolocationCallback {
pub unsafe fn from_c_object(c_object: *mut cef_get_geolocation_callback_t) -> CefGetGeolocationCallback {
CefGetGeolocationCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_get_geolocation_callback_t) -> CefGetGeolocationCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefGetGeolocationCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_get_geolocation_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_get_geolocation_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called with the 'best available' location information or, if the location
// update failed, with error information.
//
pub fn on_location_update(&self, position: &interfaces::CefGeoposition) -> (
) {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_location_update.unwrap())(
self.c_object,
CefWrap::to_c(position)))
}
}
}
impl CefWrap<*mut cef_get_geolocation_callback_t> for CefGetGeolocationCallback {
fn to_c(rust_object: CefGetGeolocationCallback) -> *mut cef_get_geolocation_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_get_geolocation_callback_t) -> CefGetGeolocationCallback {
CefGetGeolocationCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_get_geolocation_callback_t> for Option<CefGetGeolocationCallback> {
fn to_c(rust_object: Option<CefGetGeolocationCallback>) -> *mut cef_get_geolocation_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_get_geolocation_callback_t) -> Option<CefGetGeolocationCallback> {
if c_object.is_null() {
None
} else {
Some(CefGetGeolocationCallback::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,377 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Callback structure used for asynchronous continuation of geolocation
// permission requests.
//
#[repr(C)]
pub struct _cef_geolocation_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Call to allow or deny geolocation access.
//
pub cont: Option<extern "C" fn(this: *mut cef_geolocation_callback_t,
allow: libc::c_int) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_geolocation_callback_t = _cef_geolocation_callback_t;
//
// Callback structure used for asynchronous continuation of geolocation
// permission requests.
//
pub struct CefGeolocationCallback {
c_object: *mut cef_geolocation_callback_t,
}
impl Clone for CefGeolocationCallback {
fn clone(&self) -> CefGeolocationCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefGeolocationCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefGeolocationCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefGeolocationCallback {
pub unsafe fn from_c_object(c_object: *mut cef_geolocation_callback_t) -> CefGeolocationCallback {
CefGeolocationCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_geolocation_callback_t) -> CefGeolocationCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefGeolocationCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_geolocation_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_geolocation_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Call to allow or deny geolocation access.
//
pub fn cont(&self, allow: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cont.unwrap())(
self.c_object,
CefWrap::to_c(allow)))
}
}
}
impl CefWrap<*mut cef_geolocation_callback_t> for CefGeolocationCallback {
fn to_c(rust_object: CefGeolocationCallback) -> *mut cef_geolocation_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_geolocation_callback_t) -> CefGeolocationCallback {
CefGeolocationCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_geolocation_callback_t> for Option<CefGeolocationCallback> {
fn to_c(rust_object: Option<CefGeolocationCallback>) -> *mut cef_geolocation_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_geolocation_callback_t) -> Option<CefGeolocationCallback> {
if c_object.is_null() {
None
} else {
Some(CefGeolocationCallback::from_c_object_addref(c_object))
}
}
}
//
// Implement this structure to handle events related to geolocation permission
// requests. The functions of this structure will be called on the browser
// process UI thread.
//
#[repr(C)]
pub struct _cef_geolocation_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called when a page requests permission to access geolocation information.
// |requesting_url| is the URL requesting permission and |request_id| is the
// unique ID for the permission request. Return true (1) and call
// cef_geolocation_callback_t::cont() either in this function or at a later
// time to continue or cancel the request. Return false (0) to cancel the
// request immediately.
//
pub on_request_geolocation_permission: Option<extern "C" fn(
this: *mut cef_geolocation_handler_t,
browser: *mut interfaces::cef_browser_t,
requesting_url: *const types::cef_string_t, request_id: libc::c_int,
callback: *mut interfaces::cef_geolocation_callback_t) -> libc::c_int>,
//
// Called when a geolocation access request is canceled. |requesting_url| is
// the URL that originally requested permission and |request_id| is the unique
// ID for the permission request.
//
pub on_cancel_geolocation_permission: Option<extern "C" fn(
this: *mut cef_geolocation_handler_t,
browser: *mut interfaces::cef_browser_t,
requesting_url: *const types::cef_string_t, request_id: libc::c_int) -> (
)>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_geolocation_handler_t = _cef_geolocation_handler_t;
//
// Implement this structure to handle events related to geolocation permission
// requests. The functions of this structure will be called on the browser
// process UI thread.
//
pub struct CefGeolocationHandler {
c_object: *mut cef_geolocation_handler_t,
}
impl Clone for CefGeolocationHandler {
fn clone(&self) -> CefGeolocationHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefGeolocationHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefGeolocationHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefGeolocationHandler {
pub unsafe fn from_c_object(c_object: *mut cef_geolocation_handler_t) -> CefGeolocationHandler {
CefGeolocationHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_geolocation_handler_t) -> CefGeolocationHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefGeolocationHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_geolocation_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_geolocation_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called when a page requests permission to access geolocation information.
// |requesting_url| is the URL requesting permission and |request_id| is the
// unique ID for the permission request. Return true (1) and call
// cef_geolocation_callback_t::cont() either in this function or at a later
// time to continue or cancel the request. Return false (0) to cancel the
// request immediately.
//
pub fn on_request_geolocation_permission(&self,
browser: interfaces::CefBrowser, requesting_url: &[u16],
request_id: libc::c_int,
callback: interfaces::CefGeolocationCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_request_geolocation_permission.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(requesting_url),
CefWrap::to_c(request_id),
CefWrap::to_c(callback)))
}
}
//
// Called when a geolocation access request is canceled. |requesting_url| is
// the URL that originally requested permission and |request_id| is the unique
// ID for the permission request.
//
pub fn on_cancel_geolocation_permission(&self,
browser: interfaces::CefBrowser, requesting_url: &[u16],
request_id: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_cancel_geolocation_permission.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(requesting_url),
CefWrap::to_c(request_id)))
}
}
}
impl CefWrap<*mut cef_geolocation_handler_t> for CefGeolocationHandler {
fn to_c(rust_object: CefGeolocationHandler) -> *mut cef_geolocation_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_geolocation_handler_t) -> CefGeolocationHandler {
CefGeolocationHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_geolocation_handler_t> for Option<CefGeolocationHandler> {
fn to_c(rust_object: Option<CefGeolocationHandler>) -> *mut cef_geolocation_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_geolocation_handler_t) -> Option<CefGeolocationHandler> {
if c_object.is_null() {
None
} else {
Some(CefGeolocationHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,455 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Callback structure used for asynchronous continuation of JavaScript dialog
// requests.
//
#[repr(C)]
pub struct _cef_jsdialog_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Continue the JS dialog request. Set |success| to true (1) if the OK button
// was pressed. The |user_input| value should be specified for prompt dialogs.
//
pub cont: Option<extern "C" fn(this: *mut cef_jsdialog_callback_t,
success: libc::c_int, user_input: *const types::cef_string_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_jsdialog_callback_t = _cef_jsdialog_callback_t;
//
// Callback structure used for asynchronous continuation of JavaScript dialog
// requests.
//
pub struct CefJSDialogCallback {
c_object: *mut cef_jsdialog_callback_t,
}
impl Clone for CefJSDialogCallback {
fn clone(&self) -> CefJSDialogCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefJSDialogCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefJSDialogCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefJSDialogCallback {
pub unsafe fn from_c_object(c_object: *mut cef_jsdialog_callback_t) -> CefJSDialogCallback {
CefJSDialogCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_jsdialog_callback_t) -> CefJSDialogCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefJSDialogCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_jsdialog_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_jsdialog_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Continue the JS dialog request. Set |success| to true (1) if the OK button
// was pressed. The |user_input| value should be specified for prompt dialogs.
//
pub fn cont(&self, success: libc::c_int, user_input: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cont.unwrap())(
self.c_object,
CefWrap::to_c(success),
CefWrap::to_c(user_input)))
}
}
}
impl CefWrap<*mut cef_jsdialog_callback_t> for CefJSDialogCallback {
fn to_c(rust_object: CefJSDialogCallback) -> *mut cef_jsdialog_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_jsdialog_callback_t) -> CefJSDialogCallback {
CefJSDialogCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_jsdialog_callback_t> for Option<CefJSDialogCallback> {
fn to_c(rust_object: Option<CefJSDialogCallback>) -> *mut cef_jsdialog_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_jsdialog_callback_t) -> Option<CefJSDialogCallback> {
if c_object.is_null() {
None
} else {
Some(CefJSDialogCallback::from_c_object_addref(c_object))
}
}
}
//
// Implement this structure to handle events related to JavaScript dialogs. The
// functions of this structure will be called on the UI thread.
//
#[repr(C)]
pub struct _cef_jsdialog_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called to run a JavaScript dialog. The |default_prompt_text| value will be
// specified for prompt dialogs only. Set |suppress_message| to true (1) and
// return false (0) to suppress the message (suppressing messages is
// preferable to immediately executing the callback as this is used to detect
// presumably malicious behavior like spamming alert messages in
// onbeforeunload). Set |suppress_message| to false (0) and return false (0)
// to use the default implementation (the default implementation will show one
// modal dialog at a time and suppress any additional dialog requests until
// the displayed dialog is dismissed). Return true (1) if the application will
// use a custom dialog or if the callback has been executed immediately.
// Custom dialogs may be either modal or modeless. If a custom dialog is used
// the application must execute |callback| once the custom dialog is
// dismissed.
//
pub on_jsdialog: Option<extern "C" fn(this: *mut cef_jsdialog_handler_t,
browser: *mut interfaces::cef_browser_t,
origin_url: *const types::cef_string_t,
accept_lang: *const types::cef_string_t,
dialog_type: types::cef_jsdialog_type_t,
message_text: *const types::cef_string_t,
default_prompt_text: *const types::cef_string_t,
callback: *mut interfaces::cef_jsdialog_callback_t,
suppress_message: *mut libc::c_int) -> libc::c_int>,
//
// Called to run a dialog asking the user if they want to leave a page. Return
// false (0) to use the default dialog implementation. Return true (1) if the
// application will use a custom dialog or if the callback has been executed
// immediately. Custom dialogs may be either modal or modeless. If a custom
// dialog is used the application must execute |callback| once the custom
// dialog is dismissed.
//
pub on_before_unload_dialog: Option<extern "C" fn(
this: *mut cef_jsdialog_handler_t,
browser: *mut interfaces::cef_browser_t,
message_text: *const types::cef_string_t, is_reload: libc::c_int,
callback: *mut interfaces::cef_jsdialog_callback_t) -> libc::c_int>,
//
// Called to cancel any pending dialogs and reset any saved dialog state. Will
// be called due to events like page navigation irregardless of whether any
// dialogs are currently pending.
//
pub on_reset_dialog_state: Option<extern "C" fn(
this: *mut cef_jsdialog_handler_t,
browser: *mut interfaces::cef_browser_t) -> ()>,
//
// Called when the default implementation dialog is closed.
//
pub on_dialog_closed: Option<extern "C" fn(this: *mut cef_jsdialog_handler_t,
browser: *mut interfaces::cef_browser_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_jsdialog_handler_t = _cef_jsdialog_handler_t;
//
// Implement this structure to handle events related to JavaScript dialogs. The
// functions of this structure will be called on the UI thread.
//
pub struct CefJSDialogHandler {
c_object: *mut cef_jsdialog_handler_t,
}
impl Clone for CefJSDialogHandler {
fn clone(&self) -> CefJSDialogHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefJSDialogHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefJSDialogHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefJSDialogHandler {
pub unsafe fn from_c_object(c_object: *mut cef_jsdialog_handler_t) -> CefJSDialogHandler {
CefJSDialogHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_jsdialog_handler_t) -> CefJSDialogHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefJSDialogHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_jsdialog_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_jsdialog_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called to run a JavaScript dialog. The |default_prompt_text| value will be
// specified for prompt dialogs only. Set |suppress_message| to true (1) and
// return false (0) to suppress the message (suppressing messages is
// preferable to immediately executing the callback as this is used to detect
// presumably malicious behavior like spamming alert messages in
// onbeforeunload). Set |suppress_message| to false (0) and return false (0)
// to use the default implementation (the default implementation will show one
// modal dialog at a time and suppress any additional dialog requests until
// the displayed dialog is dismissed). Return true (1) if the application will
// use a custom dialog or if the callback has been executed immediately.
// Custom dialogs may be either modal or modeless. If a custom dialog is used
// the application must execute |callback| once the custom dialog is
// dismissed.
//
pub fn on_jsdialog(&self, browser: interfaces::CefBrowser, origin_url: &[u16],
accept_lang: &[u16], dialog_type: types::cef_jsdialog_type_t,
message_text: &[u16], default_prompt_text: &[u16],
callback: interfaces::CefJSDialogCallback,
suppress_message: &mut libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_jsdialog.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(origin_url),
CefWrap::to_c(accept_lang),
CefWrap::to_c(dialog_type),
CefWrap::to_c(message_text),
CefWrap::to_c(default_prompt_text),
CefWrap::to_c(callback),
CefWrap::to_c(suppress_message)))
}
}
//
// Called to run a dialog asking the user if they want to leave a page. Return
// false (0) to use the default dialog implementation. Return true (1) if the
// application will use a custom dialog or if the callback has been executed
// immediately. Custom dialogs may be either modal or modeless. If a custom
// dialog is used the application must execute |callback| once the custom
// dialog is dismissed.
//
pub fn on_before_unload_dialog(&self, browser: interfaces::CefBrowser,
message_text: &[u16], is_reload: libc::c_int,
callback: interfaces::CefJSDialogCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_before_unload_dialog.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(message_text),
CefWrap::to_c(is_reload),
CefWrap::to_c(callback)))
}
}
//
// Called to cancel any pending dialogs and reset any saved dialog state. Will
// be called due to events like page navigation irregardless of whether any
// dialogs are currently pending.
//
pub fn on_reset_dialog_state(&self, browser: interfaces::CefBrowser) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_reset_dialog_state.unwrap())(
self.c_object,
CefWrap::to_c(browser)))
}
}
//
// Called when the default implementation dialog is closed.
//
pub fn on_dialog_closed(&self, browser: interfaces::CefBrowser) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_dialog_closed.unwrap())(
self.c_object,
CefWrap::to_c(browser)))
}
}
}
impl CefWrap<*mut cef_jsdialog_handler_t> for CefJSDialogHandler {
fn to_c(rust_object: CefJSDialogHandler) -> *mut cef_jsdialog_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_jsdialog_handler_t) -> CefJSDialogHandler {
CefJSDialogHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_jsdialog_handler_t> for Option<CefJSDialogHandler> {
fn to_c(rust_object: Option<CefJSDialogHandler>) -> *mut cef_jsdialog_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_jsdialog_handler_t) -> Option<CefJSDialogHandler> {
if c_object.is_null() {
None
} else {
Some(CefJSDialogHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,230 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to handle events related to keyboard input. The
// functions of this structure will be called on the UI thread.
//
#[repr(C)]
pub struct _cef_keyboard_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
// Called before a keyboard event is sent to the renderer. |event| contains
// information about the keyboard event. |os_event| is the operating system
// event message, if any. Return true (1) if the event was handled or false
// (0) otherwise. If the event will be handled in on_key_event() as a keyboard
// shortcut set |is_keyboard_shortcut| to true (1) and return false (0).
pub on_pre_key_event: Option<extern "C" fn(this: *mut cef_keyboard_handler_t,
browser: *mut interfaces::cef_browser_t,
event: *const interfaces::cef_key_event_t,
os_event: types::cef_event_handle_t,
is_keyboard_shortcut: *mut libc::c_int) -> libc::c_int>,
//
// Called after the renderer and JavaScript in the page has had a chance to
// handle the event. |event| contains information about the keyboard event.
// |os_event| is the operating system event message, if any. Return true (1)
// if the keyboard event was handled or false (0) otherwise.
//
pub on_key_event: Option<extern "C" fn(this: *mut cef_keyboard_handler_t,
browser: *mut interfaces::cef_browser_t,
event: *const interfaces::cef_key_event_t,
os_event: types::cef_event_handle_t) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_keyboard_handler_t = _cef_keyboard_handler_t;
//
// Implement this structure to handle events related to keyboard input. The
// functions of this structure will be called on the UI thread.
//
pub struct CefKeyboardHandler {
c_object: *mut cef_keyboard_handler_t,
}
impl Clone for CefKeyboardHandler {
fn clone(&self) -> CefKeyboardHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefKeyboardHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefKeyboardHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefKeyboardHandler {
pub unsafe fn from_c_object(c_object: *mut cef_keyboard_handler_t) -> CefKeyboardHandler {
CefKeyboardHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_keyboard_handler_t) -> CefKeyboardHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefKeyboardHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_keyboard_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_keyboard_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
// Called before a keyboard event is sent to the renderer. |event| contains
// information about the keyboard event. |os_event| is the operating system
// event message, if any. Return true (1) if the event was handled or false
// (0) otherwise. If the event will be handled in on_key_event() as a keyboard
// shortcut set |is_keyboard_shortcut| to true (1) and return false (0).
pub fn on_pre_key_event(&self, browser: interfaces::CefBrowser,
event: &interfaces::CefKeyEvent, os_event: types::cef_event_handle_t,
is_keyboard_shortcut: &mut libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_pre_key_event.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(event),
CefWrap::to_c(os_event),
CefWrap::to_c(is_keyboard_shortcut)))
}
}
//
// Called after the renderer and JavaScript in the page has had a chance to
// handle the event. |event| contains information about the keyboard event.
// |os_event| is the operating system event message, if any. Return true (1)
// if the keyboard event was handled or false (0) otherwise.
//
pub fn on_key_event(&self, browser: interfaces::CefBrowser,
event: &interfaces::CefKeyEvent,
os_event: types::cef_event_handle_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_key_event.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(event),
CefWrap::to_c(os_event)))
}
}
}
impl CefWrap<*mut cef_keyboard_handler_t> for CefKeyboardHandler {
fn to_c(rust_object: CefKeyboardHandler) -> *mut cef_keyboard_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_keyboard_handler_t) -> CefKeyboardHandler {
CefKeyboardHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_keyboard_handler_t> for Option<CefKeyboardHandler> {
fn to_c(rust_object: Option<CefKeyboardHandler>) -> *mut cef_keyboard_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_keyboard_handler_t) -> Option<CefKeyboardHandler> {
if c_object.is_null() {
None
} else {
Some(CefKeyboardHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,433 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to handle events related to browser life span. The
// functions of this structure will be called on the UI thread unless otherwise
// indicated.
//
#[repr(C)]
pub struct _cef_life_span_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called on the IO thread before a new popup window is created. The |browser|
// and |frame| parameters represent the source of the popup request. The
// |target_url| and |target_frame_name| values may be NULL if none were
// specified with the request. The |popupFeatures| structure contains
// information about the requested popup window. To allow creation of the
// popup window optionally modify |windowInfo|, |client|, |settings| and
// |no_javascript_access| and return false (0). To cancel creation of the
// popup window return true (1). The |client| and |settings| values will
// default to the source browser's values. The |no_javascript_access| value
// indicates whether the new browser window should be scriptable and in the
// same process as the source browser.
pub on_before_popup: Option<extern "C" fn(this: *mut cef_life_span_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
target_url: *const types::cef_string_t,
target_frame_name: *const types::cef_string_t,
popupFeatures: *const interfaces::cef_popup_features_t,
windowInfo: *mut interfaces::cef_window_info_t,
client: *mut interfaces::cef_client_t,
settings: *mut interfaces::cef_browser_settings_t,
no_javascript_access: *mut libc::c_int) -> libc::c_int>,
//
// Called after a new browser is created.
//
pub on_after_created: Option<extern "C" fn(this: *mut cef_life_span_handler_t,
browser: *mut interfaces::cef_browser_t) -> ()>,
//
// Called when a modal window is about to display and the modal loop should
// begin running. Return false (0) to use the default modal loop
// implementation or true (1) to use a custom implementation.
//
pub run_modal: Option<extern "C" fn(this: *mut cef_life_span_handler_t,
browser: *mut interfaces::cef_browser_t) -> libc::c_int>,
//
// Called when a browser has recieved a request to close. This may result
// directly from a call to cef_browser_host_t::close_browser() or indirectly
// if the browser is a top-level OS window created by CEF and the user
// attempts to close the window. This function will be called after the
// JavaScript 'onunload' event has been fired. It will not be called for
// browsers after the associated OS window has been destroyed (for those
// browsers it is no longer possible to cancel the close).
//
// If CEF created an OS window for the browser returning false (0) will send
// an OS close notification to the browser window's top-level owner (e.g.
// WM_CLOSE on Windows, performClose: on OS-X and "delete_event" on Linux). If
// no OS window exists (window rendering disabled) returning false (0) will
// cause the browser object to be destroyed immediately. Return true (1) if
// the browser is parented to another window and that other window needs to
// receive close notification via some non-standard technique.
//
// If an application provides its own top-level window it should handle OS
// close notifications by calling cef_browser_host_t::CloseBrowser(false (0))
// instead of immediately closing (see the example below). This gives CEF an
// opportunity to process the 'onbeforeunload' event and optionally cancel the
// close before do_close() is called.
//
// The cef_life_span_handler_t::on_before_close() function will be called
// immediately before the browser object is destroyed. The application should
// only exit after on_before_close() has been called for all existing
// browsers.
//
// If the browser represents a modal window and a custom modal loop
// implementation was provided in cef_life_span_handler_t::run_modal() this
// callback should be used to restore the opener window to a usable state.
//
// By way of example consider what should happen during window close when the
// browser is parented to an application-provided top-level OS window. 1.
// User clicks the window close button which sends an OS close
// notification (e.g. WM_CLOSE on Windows, performClose: on OS-X and
// "delete_event" on Linux).
// 2. Application's top-level window receives the close notification and:
// A. Calls CefBrowserHost::CloseBrowser(false).
// B. Cancels the window close.
// 3. JavaScript 'onbeforeunload' handler executes and shows the close
// confirmation dialog (which can be overridden via
// CefJSDialogHandler::OnBeforeUnloadDialog()).
// 4. User approves the close. 5. JavaScript 'onunload' handler executes. 6.
// Application's do_close() handler is called. Application will:
// A. Set a flag to indicate that the next close attempt will be allowed.
// B. Return false.
// 7. CEF sends an OS close notification. 8. Application's top-level window
// receives the OS close notification and
// allows the window to close based on the flag from #6B.
// 9. Browser OS window is destroyed. 10. Application's
// cef_life_span_handler_t::on_before_close() handler is called and
// the browser object is destroyed.
// 11. Application exits by calling cef_quit_message_loop() if no other
// browsers
// exist.
//
pub do_close: Option<extern "C" fn(this: *mut cef_life_span_handler_t,
browser: *mut interfaces::cef_browser_t) -> libc::c_int>,
//
// Called just before a browser is destroyed. Release all references to the
// browser object and do not attempt to execute any functions on the browser
// object after this callback returns. If this is a modal window and a custom
// modal loop implementation was provided in run_modal() this callback should
// be used to exit the custom modal loop. See do_close() documentation for
// additional usage information.
//
pub on_before_close: Option<extern "C" fn(this: *mut cef_life_span_handler_t,
browser: *mut interfaces::cef_browser_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_life_span_handler_t = _cef_life_span_handler_t;
//
// Implement this structure to handle events related to browser life span. The
// functions of this structure will be called on the UI thread unless otherwise
// indicated.
//
pub struct CefLifeSpanHandler {
c_object: *mut cef_life_span_handler_t,
}
impl Clone for CefLifeSpanHandler {
fn clone(&self) -> CefLifeSpanHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefLifeSpanHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefLifeSpanHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefLifeSpanHandler {
pub unsafe fn from_c_object(c_object: *mut cef_life_span_handler_t) -> CefLifeSpanHandler {
CefLifeSpanHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_life_span_handler_t) -> CefLifeSpanHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefLifeSpanHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_life_span_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_life_span_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called on the IO thread before a new popup window is created. The |browser|
// and |frame| parameters represent the source of the popup request. The
// |target_url| and |target_frame_name| values may be NULL if none were
// specified with the request. The |popupFeatures| structure contains
// information about the requested popup window. To allow creation of the
// popup window optionally modify |windowInfo|, |client|, |settings| and
// |no_javascript_access| and return false (0). To cancel creation of the
// popup window return true (1). The |client| and |settings| values will
// default to the source browser's values. The |no_javascript_access| value
// indicates whether the new browser window should be scriptable and in the
// same process as the source browser.
pub fn on_before_popup(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, target_url: &[u16],
target_frame_name: &[u16], popupFeatures: &interfaces::CefPopupFeatures,
windowInfo: &mut interfaces::CefWindowInfo,
client: interfaces::CefClient,
settings: &mut interfaces::CefBrowserSettings,
no_javascript_access: &mut libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_before_popup.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(target_url),
CefWrap::to_c(target_frame_name),
CefWrap::to_c(popupFeatures),
CefWrap::to_c(windowInfo),
CefWrap::to_c(client),
CefWrap::to_c(settings),
CefWrap::to_c(no_javascript_access)))
}
}
//
// Called after a new browser is created.
//
pub fn on_after_created(&self, browser: interfaces::CefBrowser) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_after_created.unwrap())(
self.c_object,
CefWrap::to_c(browser)))
}
}
//
// Called when a modal window is about to display and the modal loop should
// begin running. Return false (0) to use the default modal loop
// implementation or true (1) to use a custom implementation.
//
pub fn run_modal(&self, browser: interfaces::CefBrowser) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).run_modal.unwrap())(
self.c_object,
CefWrap::to_c(browser)))
}
}
//
// Called when a browser has recieved a request to close. This may result
// directly from a call to cef_browser_host_t::close_browser() or indirectly
// if the browser is a top-level OS window created by CEF and the user
// attempts to close the window. This function will be called after the
// JavaScript 'onunload' event has been fired. It will not be called for
// browsers after the associated OS window has been destroyed (for those
// browsers it is no longer possible to cancel the close).
//
// If CEF created an OS window for the browser returning false (0) will send
// an OS close notification to the browser window's top-level owner (e.g.
// WM_CLOSE on Windows, performClose: on OS-X and "delete_event" on Linux). If
// no OS window exists (window rendering disabled) returning false (0) will
// cause the browser object to be destroyed immediately. Return true (1) if
// the browser is parented to another window and that other window needs to
// receive close notification via some non-standard technique.
//
// If an application provides its own top-level window it should handle OS
// close notifications by calling cef_browser_host_t::CloseBrowser(false (0))
// instead of immediately closing (see the example below). This gives CEF an
// opportunity to process the 'onbeforeunload' event and optionally cancel the
// close before do_close() is called.
//
// The cef_life_span_handler_t::on_before_close() function will be called
// immediately before the browser object is destroyed. The application should
// only exit after on_before_close() has been called for all existing
// browsers.
//
// If the browser represents a modal window and a custom modal loop
// implementation was provided in cef_life_span_handler_t::run_modal() this
// callback should be used to restore the opener window to a usable state.
//
// By way of example consider what should happen during window close when the
// browser is parented to an application-provided top-level OS window. 1.
// User clicks the window close button which sends an OS close
// notification (e.g. WM_CLOSE on Windows, performClose: on OS-X and
// "delete_event" on Linux).
// 2. Application's top-level window receives the close notification and:
// A. Calls CefBrowserHost::CloseBrowser(false).
// B. Cancels the window close.
// 3. JavaScript 'onbeforeunload' handler executes and shows the close
// confirmation dialog (which can be overridden via
// CefJSDialogHandler::OnBeforeUnloadDialog()).
// 4. User approves the close. 5. JavaScript 'onunload' handler executes. 6.
// Application's do_close() handler is called. Application will:
// A. Set a flag to indicate that the next close attempt will be allowed.
// B. Return false.
// 7. CEF sends an OS close notification. 8. Application's top-level window
// receives the OS close notification and
// allows the window to close based on the flag from #6B.
// 9. Browser OS window is destroyed. 10. Application's
// cef_life_span_handler_t::on_before_close() handler is called and
// the browser object is destroyed.
// 11. Application exits by calling cef_quit_message_loop() if no other
// browsers
// exist.
//
pub fn do_close(&self, browser: interfaces::CefBrowser) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).do_close.unwrap())(
self.c_object,
CefWrap::to_c(browser)))
}
}
//
// Called just before a browser is destroyed. Release all references to the
// browser object and do not attempt to execute any functions on the browser
// object after this callback returns. If this is a modal window and a custom
// modal loop implementation was provided in run_modal() this callback should
// be used to exit the custom modal loop. See do_close() documentation for
// additional usage information.
//
pub fn on_before_close(&self, browser: interfaces::CefBrowser) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_before_close.unwrap())(
self.c_object,
CefWrap::to_c(browser)))
}
}
}
impl CefWrap<*mut cef_life_span_handler_t> for CefLifeSpanHandler {
fn to_c(rust_object: CefLifeSpanHandler) -> *mut cef_life_span_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_life_span_handler_t) -> CefLifeSpanHandler {
CefLifeSpanHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_life_span_handler_t> for Option<CefLifeSpanHandler> {
fn to_c(rust_object: Option<CefLifeSpanHandler>) -> *mut cef_life_span_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_life_span_handler_t) -> Option<CefLifeSpanHandler> {
if c_object.is_null() {
None
} else {
Some(CefLifeSpanHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,307 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to handle events related to browser load status. The
// functions of this structure will be called on the browser process UI thread
// or render process main thread (TID_RENDERER).
//
#[repr(C)]
pub struct _cef_load_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called when the loading state has changed. This callback will be executed
// twice -- once when loading is initiated either programmatically or by user
// action, and once when loading is terminated due to completion, cancellation
// of failure.
//
pub on_loading_state_change: Option<extern "C" fn(
this: *mut cef_load_handler_t, browser: *mut interfaces::cef_browser_t,
isLoading: libc::c_int, canGoBack: libc::c_int,
canGoForward: libc::c_int) -> ()>,
//
// Called when the browser begins loading a frame. The |frame| value will
// never be NULL -- call the is_main() function to check if this frame is the
// main frame. Multiple frames may be loading at the same time. Sub-frames may
// start or continue loading after the main frame load has ended. This
// function may not be called for a particular frame if the load request for
// that frame fails. For notification of overall browser load status use
// OnLoadingStateChange instead.
//
pub on_load_start: Option<extern "C" fn(this: *mut cef_load_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t) -> ()>,
//
// Called when the browser is done loading a frame. The |frame| value will
// never be NULL -- call the is_main() function to check if this frame is the
// main frame. Multiple frames may be loading at the same time. Sub-frames may
// start or continue loading after the main frame load has ended. This
// function will always be called for all frames irrespective of whether the
// request completes successfully.
//
pub on_load_end: Option<extern "C" fn(this: *mut cef_load_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t, httpStatusCode: libc::c_int) -> ()>,
//
// Called when the resource load for a navigation fails or is canceled.
// |errorCode| is the error code number, |errorText| is the error text and
// |failedUrl| is the URL that failed to load. See net\base\net_error_list.h
// for complete descriptions of the error codes.
//
pub on_load_error: Option<extern "C" fn(this: *mut cef_load_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t, errorCode: types::cef_errorcode_t,
errorText: *const types::cef_string_t,
failedUrl: *const types::cef_string_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_load_handler_t = _cef_load_handler_t;
//
// Implement this structure to handle events related to browser load status. The
// functions of this structure will be called on the browser process UI thread
// or render process main thread (TID_RENDERER).
//
pub struct CefLoadHandler {
c_object: *mut cef_load_handler_t,
}
impl Clone for CefLoadHandler {
fn clone(&self) -> CefLoadHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefLoadHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefLoadHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefLoadHandler {
pub unsafe fn from_c_object(c_object: *mut cef_load_handler_t) -> CefLoadHandler {
CefLoadHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_load_handler_t) -> CefLoadHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefLoadHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_load_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_load_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called when the loading state has changed. This callback will be executed
// twice -- once when loading is initiated either programmatically or by user
// action, and once when loading is terminated due to completion, cancellation
// of failure.
//
pub fn on_loading_state_change(&self, browser: interfaces::CefBrowser,
isLoading: libc::c_int, canGoBack: libc::c_int,
canGoForward: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_loading_state_change.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(isLoading),
CefWrap::to_c(canGoBack),
CefWrap::to_c(canGoForward)))
}
}
//
// Called when the browser begins loading a frame. The |frame| value will
// never be NULL -- call the is_main() function to check if this frame is the
// main frame. Multiple frames may be loading at the same time. Sub-frames may
// start or continue loading after the main frame load has ended. This
// function may not be called for a particular frame if the load request for
// that frame fails. For notification of overall browser load status use
// OnLoadingStateChange instead.
//
pub fn on_load_start(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_load_start.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame)))
}
}
//
// Called when the browser is done loading a frame. The |frame| value will
// never be NULL -- call the is_main() function to check if this frame is the
// main frame. Multiple frames may be loading at the same time. Sub-frames may
// start or continue loading after the main frame load has ended. This
// function will always be called for all frames irrespective of whether the
// request completes successfully.
//
pub fn on_load_end(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, httpStatusCode: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_load_end.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(httpStatusCode)))
}
}
//
// Called when the resource load for a navigation fails or is canceled.
// |errorCode| is the error code number, |errorText| is the error text and
// |failedUrl| is the URL that failed to load. See net\base\net_error_list.h
// for complete descriptions of the error codes.
//
pub fn on_load_error(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, errorCode: types::cef_errorcode_t,
errorText: &[u16], failedUrl: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_load_error.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(errorCode),
CefWrap::to_c(errorText),
CefWrap::to_c(failedUrl)))
}
}
}
impl CefWrap<*mut cef_load_handler_t> for CefLoadHandler {
fn to_c(rust_object: CefLoadHandler) -> *mut cef_load_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_load_handler_t) -> CefLoadHandler {
CefLoadHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_load_handler_t> for Option<CefLoadHandler> {
fn to_c(rust_object: Option<CefLoadHandler>) -> *mut cef_load_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_load_handler_t) -> Option<CefLoadHandler> {
if c_object.is_null() {
None
} else {
Some(CefLoadHandler::from_c_object_addref(c_object))
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,46 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;

Просмотреть файл

@ -0,0 +1,46 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;

Просмотреть файл

@ -0,0 +1,562 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Callback structure for asynchronous continuation of print dialog requests.
//
#[repr(C)]
pub struct _cef_print_dialog_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Continue printing with the specified |settings|.
//
pub cont: Option<extern "C" fn(this: *mut cef_print_dialog_callback_t,
settings: *mut interfaces::cef_print_settings_t) -> ()>,
//
// Cancel the printing.
//
pub cancel: Option<extern "C" fn(this: *mut cef_print_dialog_callback_t) -> (
)>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_print_dialog_callback_t = _cef_print_dialog_callback_t;
//
// Callback structure for asynchronous continuation of print dialog requests.
//
pub struct CefPrintDialogCallback {
c_object: *mut cef_print_dialog_callback_t,
}
impl Clone for CefPrintDialogCallback {
fn clone(&self) -> CefPrintDialogCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefPrintDialogCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefPrintDialogCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefPrintDialogCallback {
pub unsafe fn from_c_object(c_object: *mut cef_print_dialog_callback_t) -> CefPrintDialogCallback {
CefPrintDialogCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_print_dialog_callback_t) -> CefPrintDialogCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefPrintDialogCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_print_dialog_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_print_dialog_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Continue printing with the specified |settings|.
//
pub fn cont(&self, settings: interfaces::CefPrintSettings) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cont.unwrap())(
self.c_object,
CefWrap::to_c(settings)))
}
}
//
// Cancel the printing.
//
pub fn cancel(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cancel.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_print_dialog_callback_t> for CefPrintDialogCallback {
fn to_c(rust_object: CefPrintDialogCallback) -> *mut cef_print_dialog_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_print_dialog_callback_t) -> CefPrintDialogCallback {
CefPrintDialogCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_print_dialog_callback_t> for Option<CefPrintDialogCallback> {
fn to_c(rust_object: Option<CefPrintDialogCallback>) -> *mut cef_print_dialog_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_print_dialog_callback_t) -> Option<CefPrintDialogCallback> {
if c_object.is_null() {
None
} else {
Some(CefPrintDialogCallback::from_c_object_addref(c_object))
}
}
}
//
// Callback structure for asynchronous continuation of print job requests.
//
#[repr(C)]
pub struct _cef_print_job_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Indicate completion of the print job.
//
pub cont: Option<extern "C" fn(this: *mut cef_print_job_callback_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_print_job_callback_t = _cef_print_job_callback_t;
//
// Callback structure for asynchronous continuation of print job requests.
//
pub struct CefPrintJobCallback {
c_object: *mut cef_print_job_callback_t,
}
impl Clone for CefPrintJobCallback {
fn clone(&self) -> CefPrintJobCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefPrintJobCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefPrintJobCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefPrintJobCallback {
pub unsafe fn from_c_object(c_object: *mut cef_print_job_callback_t) -> CefPrintJobCallback {
CefPrintJobCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_print_job_callback_t) -> CefPrintJobCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefPrintJobCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_print_job_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_print_job_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Indicate completion of the print job.
//
pub fn cont(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cont.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_print_job_callback_t> for CefPrintJobCallback {
fn to_c(rust_object: CefPrintJobCallback) -> *mut cef_print_job_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_print_job_callback_t) -> CefPrintJobCallback {
CefPrintJobCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_print_job_callback_t> for Option<CefPrintJobCallback> {
fn to_c(rust_object: Option<CefPrintJobCallback>) -> *mut cef_print_job_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_print_job_callback_t) -> Option<CefPrintJobCallback> {
if c_object.is_null() {
None
} else {
Some(CefPrintJobCallback::from_c_object_addref(c_object))
}
}
}
//
// Implement this structure to handle printing on Linux. The functions of this
// structure will be called on the browser process UI thread.
//
#[repr(C)]
pub struct _cef_print_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Synchronize |settings| with client state. If |get_defaults| is true (1)
// then populate |settings| with the default print settings. Do not keep a
// reference to |settings| outside of this callback.
//
pub on_print_settings: Option<extern "C" fn(this: *mut cef_print_handler_t,
settings: *mut interfaces::cef_print_settings_t,
get_defaults: libc::c_int) -> ()>,
//
// Show the print dialog. Execute |callback| once the dialog is dismissed.
// Return true (1) if the dialog will be displayed or false (0) to cancel the
// printing immediately.
//
pub on_print_dialog: Option<extern "C" fn(this: *mut cef_print_handler_t,
has_selection: libc::c_int,
callback: *mut interfaces::cef_print_dialog_callback_t) -> libc::c_int>,
//
// Send the print job to the printer. Execute |callback| once the job is
// completed. Return true (1) if the job will proceed or false (0) to cancel
// the job immediately.
//
pub on_print_job: Option<extern "C" fn(this: *mut cef_print_handler_t,
document_name: *const types::cef_string_t,
pdf_file_path: *const types::cef_string_t,
callback: *mut interfaces::cef_print_job_callback_t) -> libc::c_int>,
//
// Reset client state related to printing.
//
pub on_print_reset: Option<extern "C" fn(this: *mut cef_print_handler_t) -> (
)>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_print_handler_t = _cef_print_handler_t;
//
// Implement this structure to handle printing on Linux. The functions of this
// structure will be called on the browser process UI thread.
//
pub struct CefPrintHandler {
c_object: *mut cef_print_handler_t,
}
impl Clone for CefPrintHandler {
fn clone(&self) -> CefPrintHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefPrintHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefPrintHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefPrintHandler {
pub unsafe fn from_c_object(c_object: *mut cef_print_handler_t) -> CefPrintHandler {
CefPrintHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_print_handler_t) -> CefPrintHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefPrintHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_print_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_print_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Synchronize |settings| with client state. If |get_defaults| is true (1)
// then populate |settings| with the default print settings. Do not keep a
// reference to |settings| outside of this callback.
//
pub fn on_print_settings(&self, settings: interfaces::CefPrintSettings,
get_defaults: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_print_settings.unwrap())(
self.c_object,
CefWrap::to_c(settings),
CefWrap::to_c(get_defaults)))
}
}
//
// Show the print dialog. Execute |callback| once the dialog is dismissed.
// Return true (1) if the dialog will be displayed or false (0) to cancel the
// printing immediately.
//
pub fn on_print_dialog(&self, has_selection: libc::c_int,
callback: interfaces::CefPrintDialogCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_print_dialog.unwrap())(
self.c_object,
CefWrap::to_c(has_selection),
CefWrap::to_c(callback)))
}
}
//
// Send the print job to the printer. Execute |callback| once the job is
// completed. Return true (1) if the job will proceed or false (0) to cancel
// the job immediately.
//
pub fn on_print_job(&self, document_name: &[u16], pdf_file_path: &[u16],
callback: interfaces::CefPrintJobCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_print_job.unwrap())(
self.c_object,
CefWrap::to_c(document_name),
CefWrap::to_c(pdf_file_path),
CefWrap::to_c(callback)))
}
}
//
// Reset client state related to printing.
//
pub fn on_print_reset(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_print_reset.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_print_handler_t> for CefPrintHandler {
fn to_c(rust_object: CefPrintHandler) -> *mut cef_print_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_print_handler_t) -> CefPrintHandler {
CefPrintHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_print_handler_t> for Option<CefPrintHandler> {
fn to_c(rust_object: Option<CefPrintHandler>) -> *mut cef_print_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_print_handler_t) -> Option<CefPrintHandler> {
if c_object.is_null() {
None
} else {
Some(CefPrintHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,668 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure representing print settings.
//
#[repr(C)]
pub struct _cef_print_settings_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
//
pub is_valid: Option<extern "C" fn(
this: *mut cef_print_settings_t) -> libc::c_int>,
//
// Returns true (1) if the values of this object are read-only. Some APIs may
// expose read-only objects.
//
pub is_read_only: Option<extern "C" fn(
this: *mut cef_print_settings_t) -> libc::c_int>,
//
// Returns a writable copy of this object.
//
pub copy: Option<extern "C" fn(
this: *mut cef_print_settings_t) -> *mut interfaces::cef_print_settings_t>,
//
// Set the page orientation.
//
pub set_orientation: Option<extern "C" fn(this: *mut cef_print_settings_t,
landscape: libc::c_int) -> ()>,
//
// Returns true (1) if the orientation is landscape.
//
pub is_landscape: Option<extern "C" fn(
this: *mut cef_print_settings_t) -> libc::c_int>,
//
// Set the printer printable area in device units. Some platforms already
// provide flipped area. Set |landscape_needs_flip| to false (0) on those
// platforms to avoid double flipping.
//
pub set_printer_printable_area: Option<extern "C" fn(
this: *mut cef_print_settings_t,
physical_size_device_units: *const types::cef_size_t,
printable_area_device_units: *const types::cef_rect_t,
landscape_needs_flip: libc::c_int) -> ()>,
//
// Set the device name.
//
pub set_device_name: Option<extern "C" fn(this: *mut cef_print_settings_t,
name: *const types::cef_string_t) -> ()>,
//
// Get the device name.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_device_name: Option<extern "C" fn(
this: *mut cef_print_settings_t) -> types::cef_string_userfree_t>,
//
// Set the DPI (dots per inch).
//
pub set_dpi: Option<extern "C" fn(this: *mut cef_print_settings_t,
dpi: libc::c_int) -> ()>,
//
// Get the DPI (dots per inch).
//
pub get_dpi: Option<extern "C" fn(
this: *mut cef_print_settings_t) -> libc::c_int>,
//
// Set the page ranges.
//
pub set_page_ranges: Option<extern "C" fn(this: *mut cef_print_settings_t,
ranges_count: libc::size_t, ranges: *const types::cef_page_range_t) -> (
)>,
//
// Returns the number of page ranges that currently exist.
//
pub get_page_ranges_count: Option<extern "C" fn(
this: *mut cef_print_settings_t) -> libc::size_t>,
//
// Retrieve the page ranges.
//
pub get_page_ranges: Option<extern "C" fn(this: *mut cef_print_settings_t,
ranges_count: *mut libc::size_t,
ranges: *mut types::cef_page_range_t) -> ()>,
//
// Set whether only the selection will be printed.
//
pub set_selection_only: Option<extern "C" fn(this: *mut cef_print_settings_t,
selection_only: libc::c_int) -> ()>,
//
// Returns true (1) if only the selection will be printed.
//
pub is_selection_only: Option<extern "C" fn(
this: *mut cef_print_settings_t) -> libc::c_int>,
//
// Set whether pages will be collated.
//
pub set_collate: Option<extern "C" fn(this: *mut cef_print_settings_t,
collate: libc::c_int) -> ()>,
//
// Returns true (1) if pages will be collated.
//
pub will_collate: Option<extern "C" fn(
this: *mut cef_print_settings_t) -> libc::c_int>,
//
// Set the color model.
//
pub set_color_model: Option<extern "C" fn(this: *mut cef_print_settings_t,
model: types::cef_color_model_t) -> ()>,
//
// Get the color model.
//
pub get_color_model: Option<extern "C" fn(
this: *mut cef_print_settings_t) -> types::cef_color_model_t>,
//
// Set the number of copies.
//
pub set_copies: Option<extern "C" fn(this: *mut cef_print_settings_t,
copies: libc::c_int) -> ()>,
//
// Get the number of copies.
//
pub get_copies: Option<extern "C" fn(
this: *mut cef_print_settings_t) -> libc::c_int>,
//
// Set the duplex mode.
//
pub set_duplex_mode: Option<extern "C" fn(this: *mut cef_print_settings_t,
mode: types::cef_duplex_mode_t) -> ()>,
//
// Get the duplex mode.
//
pub get_duplex_mode: Option<extern "C" fn(
this: *mut cef_print_settings_t) -> types::cef_duplex_mode_t>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_print_settings_t = _cef_print_settings_t;
//
// Structure representing print settings.
//
pub struct CefPrintSettings {
c_object: *mut cef_print_settings_t,
}
impl Clone for CefPrintSettings {
fn clone(&self) -> CefPrintSettings{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefPrintSettings {
c_object: self.c_object,
}
}
}
}
impl Drop for CefPrintSettings {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefPrintSettings {
pub unsafe fn from_c_object(c_object: *mut cef_print_settings_t) -> CefPrintSettings {
CefPrintSettings {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_print_settings_t) -> CefPrintSettings {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefPrintSettings {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_print_settings_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_print_settings_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
//
pub fn is_valid(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_valid.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the values of this object are read-only. Some APIs may
// expose read-only objects.
//
pub fn is_read_only(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_read_only.unwrap())(
self.c_object))
}
}
//
// Returns a writable copy of this object.
//
pub fn copy(&self) -> interfaces::CefPrintSettings {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).copy.unwrap())(
self.c_object))
}
}
//
// Set the page orientation.
//
pub fn set_orientation(&self, landscape: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_orientation.unwrap())(
self.c_object,
CefWrap::to_c(landscape)))
}
}
//
// Returns true (1) if the orientation is landscape.
//
pub fn is_landscape(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_landscape.unwrap())(
self.c_object))
}
}
//
// Set the printer printable area in device units. Some platforms already
// provide flipped area. Set |landscape_needs_flip| to false (0) on those
// platforms to avoid double flipping.
//
pub fn set_printer_printable_area(&self,
physical_size_device_units: &types::cef_size_t,
printable_area_device_units: &types::cef_rect_t,
landscape_needs_flip: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_printer_printable_area.unwrap())(
self.c_object,
CefWrap::to_c(physical_size_device_units),
CefWrap::to_c(printable_area_device_units),
CefWrap::to_c(landscape_needs_flip)))
}
}
//
// Set the device name.
//
pub fn set_device_name(&self, name: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_device_name.unwrap())(
self.c_object,
CefWrap::to_c(name)))
}
}
//
// Get the device name.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_device_name(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_device_name.unwrap())(
self.c_object))
}
}
//
// Set the DPI (dots per inch).
//
pub fn set_dpi(&self, dpi: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_dpi.unwrap())(
self.c_object,
CefWrap::to_c(dpi)))
}
}
//
// Get the DPI (dots per inch).
//
pub fn get_dpi(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_dpi.unwrap())(
self.c_object))
}
}
//
// Set the page ranges.
//
pub fn set_page_ranges(&self, ranges_count: libc::size_t,
ranges: *const types::cef_page_range_t) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_page_ranges.unwrap())(
self.c_object,
CefWrap::to_c(ranges_count),
CefWrap::to_c(ranges)))
}
}
//
// Returns the number of page ranges that currently exist.
//
pub fn get_page_ranges_count(&self) -> libc::size_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_page_ranges_count.unwrap())(
self.c_object))
}
}
//
// Retrieve the page ranges.
//
pub fn get_page_ranges(&self, ranges_count: *mut libc::size_t,
ranges: *mut types::cef_page_range_t) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_page_ranges.unwrap())(
self.c_object,
CefWrap::to_c(ranges_count),
CefWrap::to_c(ranges)))
}
}
//
// Set whether only the selection will be printed.
//
pub fn set_selection_only(&self, selection_only: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_selection_only.unwrap())(
self.c_object,
CefWrap::to_c(selection_only)))
}
}
//
// Returns true (1) if only the selection will be printed.
//
pub fn is_selection_only(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_selection_only.unwrap())(
self.c_object))
}
}
//
// Set whether pages will be collated.
//
pub fn set_collate(&self, collate: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_collate.unwrap())(
self.c_object,
CefWrap::to_c(collate)))
}
}
//
// Returns true (1) if pages will be collated.
//
pub fn will_collate(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).will_collate.unwrap())(
self.c_object))
}
}
//
// Set the color model.
//
pub fn set_color_model(&self, model: types::cef_color_model_t) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_color_model.unwrap())(
self.c_object,
CefWrap::to_c(model)))
}
}
//
// Get the color model.
//
pub fn get_color_model(&self) -> types::cef_color_model_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_color_model.unwrap())(
self.c_object))
}
}
//
// Set the number of copies.
//
pub fn set_copies(&self, copies: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_copies.unwrap())(
self.c_object,
CefWrap::to_c(copies)))
}
}
//
// Get the number of copies.
//
pub fn get_copies(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_copies.unwrap())(
self.c_object))
}
}
//
// Set the duplex mode.
//
pub fn set_duplex_mode(&self, mode: types::cef_duplex_mode_t) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_duplex_mode.unwrap())(
self.c_object,
CefWrap::to_c(mode)))
}
}
//
// Get the duplex mode.
//
pub fn get_duplex_mode(&self) -> types::cef_duplex_mode_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_duplex_mode.unwrap())(
self.c_object))
}
}
//
// Create a new cef_print_settings_t object.
//
pub fn create() -> interfaces::CefPrintSettings {
unsafe {
CefWrap::to_rust(
::print_settings::cef_print_settings_create(
))
}
}
}
impl CefWrap<*mut cef_print_settings_t> for CefPrintSettings {
fn to_c(rust_object: CefPrintSettings) -> *mut cef_print_settings_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_print_settings_t) -> CefPrintSettings {
CefPrintSettings::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_print_settings_t> for Option<CefPrintSettings> {
fn to_c(rust_object: Option<CefPrintSettings>) -> *mut cef_print_settings_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_print_settings_t) -> Option<CefPrintSettings> {
if c_object.is_null() {
None
} else {
Some(CefPrintSettings::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,279 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure representing a message. Can be used on any process and thread.
//
#[repr(C)]
pub struct _cef_process_message_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
//
pub is_valid: Option<extern "C" fn(
this: *mut cef_process_message_t) -> libc::c_int>,
//
// Returns true (1) if the values of this object are read-only. Some APIs may
// expose read-only objects.
//
pub is_read_only: Option<extern "C" fn(
this: *mut cef_process_message_t) -> libc::c_int>,
//
// Returns a writable copy of this object.
//
pub copy: Option<extern "C" fn(
this: *mut cef_process_message_t) -> *mut interfaces::cef_process_message_t>,
//
// Returns the message name.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_name: Option<extern "C" fn(
this: *mut cef_process_message_t) -> types::cef_string_userfree_t>,
//
// Returns the list of arguments.
//
pub get_argument_list: Option<extern "C" fn(
this: *mut cef_process_message_t) -> *mut interfaces::cef_list_value_t>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_process_message_t = _cef_process_message_t;
//
// Structure representing a message. Can be used on any process and thread.
//
pub struct CefProcessMessage {
c_object: *mut cef_process_message_t,
}
impl Clone for CefProcessMessage {
fn clone(&self) -> CefProcessMessage{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefProcessMessage {
c_object: self.c_object,
}
}
}
}
impl Drop for CefProcessMessage {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefProcessMessage {
pub unsafe fn from_c_object(c_object: *mut cef_process_message_t) -> CefProcessMessage {
CefProcessMessage {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_process_message_t) -> CefProcessMessage {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefProcessMessage {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_process_message_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_process_message_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
//
pub fn is_valid(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_valid.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the values of this object are read-only. Some APIs may
// expose read-only objects.
//
pub fn is_read_only(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_read_only.unwrap())(
self.c_object))
}
}
//
// Returns a writable copy of this object.
//
pub fn copy(&self) -> interfaces::CefProcessMessage {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).copy.unwrap())(
self.c_object))
}
}
//
// Returns the message name.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_name(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_name.unwrap())(
self.c_object))
}
}
//
// Returns the list of arguments.
//
pub fn get_argument_list(&self) -> interfaces::CefListValue {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_argument_list.unwrap())(
self.c_object))
}
}
//
// Create a new cef_process_message_t object with the specified name.
//
pub fn create(name: &[u16]) -> interfaces::CefProcessMessage {
unsafe {
CefWrap::to_rust(
::process_message::cef_process_message_create(
CefWrap::to_c(name)))
}
}
}
impl CefWrap<*mut cef_process_message_t> for CefProcessMessage {
fn to_c(rust_object: CefProcessMessage) -> *mut cef_process_message_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_process_message_t) -> CefProcessMessage {
CefProcessMessage::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_process_message_t> for Option<CefProcessMessage> {
fn to_c(rust_object: Option<CefProcessMessage>) -> *mut cef_process_message_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_process_message_t) -> Option<CefProcessMessage> {
if c_object.is_null() {
None
} else {
Some(CefProcessMessage::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,46 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;

Просмотреть файл

@ -0,0 +1,554 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to handle events when window rendering is disabled.
// The functions of this structure will be called on the UI thread.
//
#[repr(C)]
pub struct _cef_render_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called to retrieve the root window rectangle in screen coordinates. Return
// true (1) if the rectangle was provided.
//
pub get_root_screen_rect: Option<extern "C" fn(
this: *mut cef_render_handler_t, browser: *mut interfaces::cef_browser_t,
rect: *mut types::cef_rect_t) -> libc::c_int>,
//
// Called to retrieve the view rectangle which is relative to screen
// coordinates. Return true (1) if the rectangle was provided.
//
pub get_view_rect: Option<extern "C" fn(this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t,
rect: *mut types::cef_rect_t) -> libc::c_int>,
//
// Called to retrieve the translation from view coordinates to actual screen
// coordinates. Return true (1) if the screen coordinates were provided.
//
pub get_screen_point: Option<extern "C" fn(this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t, viewX: libc::c_int,
viewY: libc::c_int, screenX: *mut libc::c_int,
screenY: *mut libc::c_int) -> libc::c_int>,
//
// Called to allow the client to fill in the CefScreenInfo object with
// appropriate values. Return true (1) if the |screen_info| structure has been
// modified.
//
// If the screen info rectangle is left NULL the rectangle from GetViewRect
// will be used. If the rectangle is still NULL or invalid popups may not be
// drawn correctly.
//
pub get_screen_info: Option<extern "C" fn(this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t,
screen_info: *mut interfaces::cef_screen_info_t) -> libc::c_int>,
//
// Called when the browser wants to show or hide the popup widget. The popup
// should be shown if |show| is true (1) and hidden if |show| is false (0).
//
pub on_popup_show: Option<extern "C" fn(this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t, show: libc::c_int) -> ()>,
//
// Called when the browser wants to move or resize the popup widget. |rect|
// contains the new location and size.
//
pub on_popup_size: Option<extern "C" fn(this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t,
rect: *const types::cef_rect_t) -> ()>,
//
// Called when an element should be painted. |type| indicates whether the
// element is the view or the popup widget. |buffer| contains the pixel data
// for the whole image. |dirtyRects| contains the set of rectangles that need
// to be repainted. On Windows |buffer| will be |width|*|height|*4 bytes in
// size and represents a BGRA image with an upper-left origin.
//
pub on_paint: Option<extern "C" fn(this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t,
ty: types::cef_paint_element_type_t, dirtyRects_count: libc::size_t,
dirtyRects: *const types::cef_rect_t, buffer: *const (),
width: libc::c_int, height: libc::c_int) -> ()>,
//
// Called when the browser window's cursor has changed.
//
pub on_cursor_change: Option<extern "C" fn(this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t,
cursor: types::cef_cursor_handle_t) -> ()>,
//
// Called when the user starts dragging content in the web view. Contextual
// information about the dragged content is supplied by |drag_data|. OS APIs
// that run a system message loop may be used within the StartDragging call.
//
// Return false (0) to abort the drag operation. Don't call any of
// cef_browser_host_t::DragSource*Ended* functions after returning false (0).
//
// Return true (1) to handle the drag operation. Call
// cef_browser_host_t::DragSourceEndedAt and DragSourceSystemDragEnded either
// synchronously or asynchronously to inform the web view that the drag
// operation has ended.
//
pub start_dragging: Option<extern "C" fn(this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t,
drag_data: *mut interfaces::cef_drag_data_t,
allowed_ops: types::cef_drag_operations_mask_t, x: libc::c_int,
y: libc::c_int) -> libc::c_int>,
//
// Called when the web view wants to update the mouse cursor during a drag &
// drop operation. |operation| describes the allowed operation (none, move,
// copy, link).
//
pub update_drag_cursor: Option<extern "C" fn(this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t,
operation: types::cef_drag_operations_mask_t) -> ()>,
//
// Called when the scroll offset has changed.
//
pub on_scroll_offset_changed: Option<extern "C" fn(
this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t) -> ()>,
//
// Called to retrieve the backing size of the view rectangle which is relative
// to screen coordinates. On HiDPI displays, the backing size can differ from
// the view size as returned by |GetViewRect|. Return true (1) if the
// rectangle was provided.
//
pub get_backing_rect: Option<extern "C" fn(this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t,
rect: *mut types::cef_rect_t) -> libc::c_int>,
//
// Called when an element should be presented (e.g. double buffers should page
// flip). This is called only during accelerated compositing.
//
pub on_present: Option<extern "C" fn(this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_render_handler_t = _cef_render_handler_t;
//
// Implement this structure to handle events when window rendering is disabled.
// The functions of this structure will be called on the UI thread.
//
pub struct CefRenderHandler {
c_object: *mut cef_render_handler_t,
}
impl Clone for CefRenderHandler {
fn clone(&self) -> CefRenderHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefRenderHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefRenderHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefRenderHandler {
pub unsafe fn from_c_object(c_object: *mut cef_render_handler_t) -> CefRenderHandler {
CefRenderHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_render_handler_t) -> CefRenderHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefRenderHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_render_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_render_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called to retrieve the root window rectangle in screen coordinates. Return
// true (1) if the rectangle was provided.
//
pub fn get_root_screen_rect(&self, browser: interfaces::CefBrowser,
rect: &mut types::cef_rect_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_root_screen_rect.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(rect)))
}
}
//
// Called to retrieve the view rectangle which is relative to screen
// coordinates. Return true (1) if the rectangle was provided.
//
pub fn get_view_rect(&self, browser: interfaces::CefBrowser,
rect: &mut types::cef_rect_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_view_rect.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(rect)))
}
}
//
// Called to retrieve the translation from view coordinates to actual screen
// coordinates. Return true (1) if the screen coordinates were provided.
//
pub fn get_screen_point(&self, browser: interfaces::CefBrowser,
viewX: libc::c_int, viewY: libc::c_int, screenX: &mut libc::c_int,
screenY: &mut libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_screen_point.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(viewX),
CefWrap::to_c(viewY),
CefWrap::to_c(screenX),
CefWrap::to_c(screenY)))
}
}
//
// Called to allow the client to fill in the CefScreenInfo object with
// appropriate values. Return true (1) if the |screen_info| structure has been
// modified.
//
// If the screen info rectangle is left NULL the rectangle from GetViewRect
// will be used. If the rectangle is still NULL or invalid popups may not be
// drawn correctly.
//
pub fn get_screen_info(&self, browser: interfaces::CefBrowser,
screen_info: &mut interfaces::CefScreenInfo) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_screen_info.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(screen_info)))
}
}
//
// Called when the browser wants to show or hide the popup widget. The popup
// should be shown if |show| is true (1) and hidden if |show| is false (0).
//
pub fn on_popup_show(&self, browser: interfaces::CefBrowser,
show: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_popup_show.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(show)))
}
}
//
// Called when the browser wants to move or resize the popup widget. |rect|
// contains the new location and size.
//
pub fn on_popup_size(&self, browser: interfaces::CefBrowser,
rect: &types::cef_rect_t) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_popup_size.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(rect)))
}
}
//
// Called when an element should be painted. |type| indicates whether the
// element is the view or the popup widget. |buffer| contains the pixel data
// for the whole image. |dirtyRects| contains the set of rectangles that need
// to be repainted. On Windows |buffer| will be |width|*|height|*4 bytes in
// size and represents a BGRA image with an upper-left origin.
//
pub fn on_paint(&self, browser: interfaces::CefBrowser,
ty: types::cef_paint_element_type_t, dirtyRects_count: libc::size_t,
dirtyRects: *const types::cef_rect_t, buffer: &(), width: libc::c_int,
height: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_paint.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(ty),
CefWrap::to_c(dirtyRects_count),
CefWrap::to_c(dirtyRects),
CefWrap::to_c(buffer),
CefWrap::to_c(width),
CefWrap::to_c(height)))
}
}
//
// Called when the browser window's cursor has changed.
//
pub fn on_cursor_change(&self, browser: interfaces::CefBrowser,
cursor: types::cef_cursor_handle_t) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_cursor_change.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(cursor)))
}
}
//
// Called when the user starts dragging content in the web view. Contextual
// information about the dragged content is supplied by |drag_data|. OS APIs
// that run a system message loop may be used within the StartDragging call.
//
// Return false (0) to abort the drag operation. Don't call any of
// cef_browser_host_t::DragSource*Ended* functions after returning false (0).
//
// Return true (1) to handle the drag operation. Call
// cef_browser_host_t::DragSourceEndedAt and DragSourceSystemDragEnded either
// synchronously or asynchronously to inform the web view that the drag
// operation has ended.
//
pub fn start_dragging(&self, browser: interfaces::CefBrowser,
drag_data: interfaces::CefDragData,
allowed_ops: types::cef_drag_operations_mask_t, x: libc::c_int,
y: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).start_dragging.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(drag_data),
CefWrap::to_c(allowed_ops),
CefWrap::to_c(x),
CefWrap::to_c(y)))
}
}
//
// Called when the web view wants to update the mouse cursor during a drag &
// drop operation. |operation| describes the allowed operation (none, move,
// copy, link).
//
pub fn update_drag_cursor(&self, browser: interfaces::CefBrowser,
operation: types::cef_drag_operations_mask_t) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).update_drag_cursor.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(operation)))
}
}
//
// Called when the scroll offset has changed.
//
pub fn on_scroll_offset_changed(&self, browser: interfaces::CefBrowser) -> (
) {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_scroll_offset_changed.unwrap())(
self.c_object,
CefWrap::to_c(browser)))
}
}
//
// Called to retrieve the backing size of the view rectangle which is relative
// to screen coordinates. On HiDPI displays, the backing size can differ from
// the view size as returned by |GetViewRect|. Return true (1) if the
// rectangle was provided.
//
pub fn get_backing_rect(&self, browser: interfaces::CefBrowser,
rect: &mut types::cef_rect_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_backing_rect.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(rect)))
}
}
//
// Called when an element should be presented (e.g. double buffers should page
// flip). This is called only during accelerated compositing.
//
pub fn on_present(&self, browser: interfaces::CefBrowser) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_present.unwrap())(
self.c_object,
CefWrap::to_c(browser)))
}
}
}
impl CefWrap<*mut cef_render_handler_t> for CefRenderHandler {
fn to_c(rust_object: CefRenderHandler) -> *mut cef_render_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_render_handler_t) -> CefRenderHandler {
CefRenderHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_render_handler_t> for Option<CefRenderHandler> {
fn to_c(rust_object: Option<CefRenderHandler>) -> *mut cef_render_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_render_handler_t) -> Option<CefRenderHandler> {
if c_object.is_null() {
None
} else {
Some(CefRenderHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,492 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure used to implement render process callbacks. The functions of this
// structure will be called on the render process main thread (TID_RENDERER)
// unless otherwise indicated.
//
#[repr(C)]
pub struct _cef_render_process_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called after the render process main thread has been created. |extra_info|
// is a read-only value originating from
// cef_browser_process_handler_t::on_render_process_thread_created(). Do not
// keep a reference to |extra_info| outside of this function.
//
pub on_render_thread_created: Option<extern "C" fn(
this: *mut cef_render_process_handler_t,
extra_info: *mut interfaces::cef_list_value_t) -> ()>,
//
// Called after WebKit has been initialized.
//
pub on_web_kit_initialized: Option<extern "C" fn(
this: *mut cef_render_process_handler_t) -> ()>,
//
// Called after a browser has been created. When browsing cross-origin a new
// browser will be created before the old browser with the same identifier is
// destroyed.
//
pub on_browser_created: Option<extern "C" fn(
this: *mut cef_render_process_handler_t,
browser: *mut interfaces::cef_browser_t) -> ()>,
//
// Called before a browser is destroyed.
//
pub on_browser_destroyed: Option<extern "C" fn(
this: *mut cef_render_process_handler_t,
browser: *mut interfaces::cef_browser_t) -> ()>,
//
// Return the handler for browser load status events.
//
pub get_load_handler: Option<extern "C" fn(
this: *mut cef_render_process_handler_t) -> *mut interfaces::cef_load_handler_t>,
//
// Called before browser navigation. Return true (1) to cancel the navigation
// or false (0) to allow the navigation to proceed. The |request| object
// cannot be modified in this callback.
//
pub on_before_navigation: Option<extern "C" fn(
this: *mut cef_render_process_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
request: *mut interfaces::cef_request_t,
navigation_type: types::cef_navigation_type_t,
is_redirect: libc::c_int) -> libc::c_int>,
//
// Called immediately after the V8 context for a frame has been created. To
// retrieve the JavaScript 'window' object use the
// cef_v8context_t::get_global() function. V8 handles can only be accessed
// from the thread on which they are created. A task runner for posting tasks
// on the associated thread can be retrieved via the
// cef_v8context_t::get_task_runner() function.
//
pub on_context_created: Option<extern "C" fn(
this: *mut cef_render_process_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
context: *mut interfaces::cef_v8context_t) -> ()>,
//
// Called immediately before the V8 context for a frame is released. No
// references to the context should be kept after this function is called.
//
pub on_context_released: Option<extern "C" fn(
this: *mut cef_render_process_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
context: *mut interfaces::cef_v8context_t) -> ()>,
//
// Called for global uncaught exceptions in a frame. Execution of this
// callback is disabled by default. To enable set
// CefSettings.uncaught_exception_stack_size > 0.
//
pub on_uncaught_exception: Option<extern "C" fn(
this: *mut cef_render_process_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
context: *mut interfaces::cef_v8context_t,
exception: *mut interfaces::cef_v8exception_t,
stackTrace: *mut interfaces::cef_v8stack_trace_t) -> ()>,
//
// Called when a new node in the the browser gets focus. The |node| value may
// be NULL if no specific node has gained focus. The node object passed to
// this function represents a snapshot of the DOM at the time this function is
// executed. DOM objects are only valid for the scope of this function. Do not
// keep references to or attempt to access any DOM objects outside the scope
// of this function.
//
pub on_focused_node_changed: Option<extern "C" fn(
this: *mut cef_render_process_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
node: *mut interfaces::cef_domnode_t) -> ()>,
//
// Called when a new message is received from a different process. Return true
// (1) if the message was handled or false (0) otherwise. Do not keep a
// reference to or attempt to access the message outside of this callback.
//
pub on_process_message_received: Option<extern "C" fn(
this: *mut cef_render_process_handler_t,
browser: *mut interfaces::cef_browser_t,
source_process: interfaces::cef_process_id_t,
message: *mut interfaces::cef_process_message_t) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_render_process_handler_t = _cef_render_process_handler_t;
//
// Structure used to implement render process callbacks. The functions of this
// structure will be called on the render process main thread (TID_RENDERER)
// unless otherwise indicated.
//
pub struct CefRenderProcessHandler {
c_object: *mut cef_render_process_handler_t,
}
impl Clone for CefRenderProcessHandler {
fn clone(&self) -> CefRenderProcessHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefRenderProcessHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefRenderProcessHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefRenderProcessHandler {
pub unsafe fn from_c_object(c_object: *mut cef_render_process_handler_t) -> CefRenderProcessHandler {
CefRenderProcessHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_render_process_handler_t) -> CefRenderProcessHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefRenderProcessHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_render_process_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_render_process_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called after the render process main thread has been created. |extra_info|
// is a read-only value originating from
// cef_browser_process_handler_t::on_render_process_thread_created(). Do not
// keep a reference to |extra_info| outside of this function.
//
pub fn on_render_thread_created(&self,
extra_info: interfaces::CefListValue) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_render_thread_created.unwrap())(
self.c_object,
CefWrap::to_c(extra_info)))
}
}
//
// Called after WebKit has been initialized.
//
pub fn on_web_kit_initialized(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_web_kit_initialized.unwrap())(
self.c_object))
}
}
//
// Called after a browser has been created. When browsing cross-origin a new
// browser will be created before the old browser with the same identifier is
// destroyed.
//
pub fn on_browser_created(&self, browser: interfaces::CefBrowser) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_browser_created.unwrap())(
self.c_object,
CefWrap::to_c(browser)))
}
}
//
// Called before a browser is destroyed.
//
pub fn on_browser_destroyed(&self, browser: interfaces::CefBrowser) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_browser_destroyed.unwrap())(
self.c_object,
CefWrap::to_c(browser)))
}
}
//
// Return the handler for browser load status events.
//
pub fn get_load_handler(&self) -> interfaces::CefLoadHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_load_handler.unwrap())(
self.c_object))
}
}
//
// Called before browser navigation. Return true (1) to cancel the navigation
// or false (0) to allow the navigation to proceed. The |request| object
// cannot be modified in this callback.
//
pub fn on_before_navigation(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, request: interfaces::CefRequest,
navigation_type: types::cef_navigation_type_t,
is_redirect: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_before_navigation.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(request),
CefWrap::to_c(navigation_type),
CefWrap::to_c(is_redirect)))
}
}
//
// Called immediately after the V8 context for a frame has been created. To
// retrieve the JavaScript 'window' object use the
// cef_v8context_t::get_global() function. V8 handles can only be accessed
// from the thread on which they are created. A task runner for posting tasks
// on the associated thread can be retrieved via the
// cef_v8context_t::get_task_runner() function.
//
pub fn on_context_created(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, context: interfaces::CefV8Context) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_context_created.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(context)))
}
}
//
// Called immediately before the V8 context for a frame is released. No
// references to the context should be kept after this function is called.
//
pub fn on_context_released(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, context: interfaces::CefV8Context) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_context_released.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(context)))
}
}
//
// Called for global uncaught exceptions in a frame. Execution of this
// callback is disabled by default. To enable set
// CefSettings.uncaught_exception_stack_size > 0.
//
pub fn on_uncaught_exception(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, context: interfaces::CefV8Context,
exception: interfaces::CefV8Exception,
stackTrace: interfaces::CefV8StackTrace) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_uncaught_exception.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(context),
CefWrap::to_c(exception),
CefWrap::to_c(stackTrace)))
}
}
//
// Called when a new node in the the browser gets focus. The |node| value may
// be NULL if no specific node has gained focus. The node object passed to
// this function represents a snapshot of the DOM at the time this function is
// executed. DOM objects are only valid for the scope of this function. Do not
// keep references to or attempt to access any DOM objects outside the scope
// of this function.
//
pub fn on_focused_node_changed(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, node: interfaces::CefDOMNode) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_focused_node_changed.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(node)))
}
}
//
// Called when a new message is received from a different process. Return true
// (1) if the message was handled or false (0) otherwise. Do not keep a
// reference to or attempt to access the message outside of this callback.
//
pub fn on_process_message_received(&self, browser: interfaces::CefBrowser,
source_process: interfaces::CefProcessId,
message: interfaces::CefProcessMessage) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_process_message_received.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(source_process),
CefWrap::to_c(message)))
}
}
}
impl CefWrap<*mut cef_render_process_handler_t> for CefRenderProcessHandler {
fn to_c(rust_object: CefRenderProcessHandler) -> *mut cef_render_process_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_render_process_handler_t) -> CefRenderProcessHandler {
CefRenderProcessHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_render_process_handler_t> for Option<CefRenderProcessHandler> {
fn to_c(rust_object: Option<CefRenderProcessHandler>) -> *mut cef_render_process_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_render_process_handler_t) -> Option<CefRenderProcessHandler> {
if c_object.is_null() {
None
} else {
Some(CefRenderProcessHandler::from_c_object_addref(c_object))
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,272 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// A request context provides request handling for a set of related browser
// objects. A request context is specified when creating a new browser object
// via the cef_browser_host_t static factory functions. Browser objects with
// different request contexts will never be hosted in the same render process.
// Browser objects with the same request context may or may not be hosted in the
// same render process depending on the process model. Browser objects created
// indirectly via the JavaScript window.open function or targeted links will
// share the same render process and the same request context as the source
// browser. When running in single-process mode there is only a single render
// process (the main process) and so all browsers created in single-process mode
// will share the same request context. This will be the first request context
// passed into a cef_browser_host_t static factory function and all other
// request context objects will be ignored.
//
#[repr(C)]
pub struct _cef_request_context_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Returns true (1) if this object is pointing to the same context as |that|
// object.
//
pub is_same: Option<extern "C" fn(this: *mut cef_request_context_t,
other: *mut interfaces::cef_request_context_t) -> libc::c_int>,
//
// Returns true (1) if this object is the global context.
//
pub is_global: Option<extern "C" fn(
this: *mut cef_request_context_t) -> libc::c_int>,
//
// Returns the handler for this context if any.
//
pub get_handler: Option<extern "C" fn(
this: *mut cef_request_context_t) -> *mut interfaces::cef_request_context_handler_t>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_request_context_t = _cef_request_context_t;
//
// A request context provides request handling for a set of related browser
// objects. A request context is specified when creating a new browser object
// via the cef_browser_host_t static factory functions. Browser objects with
// different request contexts will never be hosted in the same render process.
// Browser objects with the same request context may or may not be hosted in the
// same render process depending on the process model. Browser objects created
// indirectly via the JavaScript window.open function or targeted links will
// share the same render process and the same request context as the source
// browser. When running in single-process mode there is only a single render
// process (the main process) and so all browsers created in single-process mode
// will share the same request context. This will be the first request context
// passed into a cef_browser_host_t static factory function and all other
// request context objects will be ignored.
//
pub struct CefRequestContext {
c_object: *mut cef_request_context_t,
}
impl Clone for CefRequestContext {
fn clone(&self) -> CefRequestContext{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefRequestContext {
c_object: self.c_object,
}
}
}
}
impl Drop for CefRequestContext {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefRequestContext {
pub unsafe fn from_c_object(c_object: *mut cef_request_context_t) -> CefRequestContext {
CefRequestContext {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_request_context_t) -> CefRequestContext {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefRequestContext {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_request_context_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_request_context_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Returns true (1) if this object is pointing to the same context as |that|
// object.
//
pub fn is_same(&self, other: interfaces::CefRequestContext) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_same.unwrap())(
self.c_object,
CefWrap::to_c(other)))
}
}
//
// Returns true (1) if this object is the global context.
//
pub fn is_global(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_global.unwrap())(
self.c_object))
}
}
//
// Returns the handler for this context if any.
//
pub fn get_handler(&self) -> interfaces::CefRequestContextHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_handler.unwrap())(
self.c_object))
}
}
//
// Returns the global context object.
//
pub fn get_global_context() -> interfaces::CefRequestContext {
unsafe {
CefWrap::to_rust(
::request_context::cef_request_context_get_global_context(
))
}
}
//
// Creates a new context object with the specified handler.
//
pub fn create_context(
handler: interfaces::CefRequestContextHandler) -> interfaces::CefRequestContext {
unsafe {
CefWrap::to_rust(
::request_context::cef_request_context_create_context(
CefWrap::to_c(handler)))
}
}
}
impl CefWrap<*mut cef_request_context_t> for CefRequestContext {
fn to_c(rust_object: CefRequestContext) -> *mut cef_request_context_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_request_context_t) -> CefRequestContext {
CefRequestContext::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_request_context_t> for Option<CefRequestContext> {
fn to_c(rust_object: Option<CefRequestContext>) -> *mut cef_request_context_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_request_context_t) -> Option<CefRequestContext> {
if c_object.is_null() {
None
} else {
Some(CefRequestContext::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,184 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to provide handler implementations.
//
#[repr(C)]
pub struct _cef_request_context_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called on the IO thread to retrieve the cookie manager. The global cookie
// manager will be used if this function returns NULL.
//
pub get_cookie_manager: Option<extern "C" fn(
this: *mut cef_request_context_handler_t) -> *mut interfaces::cef_cookie_manager_t>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_request_context_handler_t = _cef_request_context_handler_t;
//
// Implement this structure to provide handler implementations.
//
pub struct CefRequestContextHandler {
c_object: *mut cef_request_context_handler_t,
}
impl Clone for CefRequestContextHandler {
fn clone(&self) -> CefRequestContextHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefRequestContextHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefRequestContextHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefRequestContextHandler {
pub unsafe fn from_c_object(c_object: *mut cef_request_context_handler_t) -> CefRequestContextHandler {
CefRequestContextHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_request_context_handler_t) -> CefRequestContextHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefRequestContextHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_request_context_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_request_context_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called on the IO thread to retrieve the cookie manager. The global cookie
// manager will be used if this function returns NULL.
//
pub fn get_cookie_manager(&self) -> interfaces::CefCookieManager {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_cookie_manager.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_request_context_handler_t> for CefRequestContextHandler {
fn to_c(rust_object: CefRequestContextHandler) -> *mut cef_request_context_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_request_context_handler_t) -> CefRequestContextHandler {
CefRequestContextHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_request_context_handler_t> for Option<CefRequestContextHandler> {
fn to_c(rust_object: Option<CefRequestContextHandler>) -> *mut cef_request_context_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_request_context_handler_t) -> Option<CefRequestContextHandler> {
if c_object.is_null() {
None
} else {
Some(CefRequestContextHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,841 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Callback structure used for asynchronous continuation of quota requests.
//
#[repr(C)]
pub struct _cef_quota_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Continue the quota request. If |allow| is true (1) the request will be
// allowed. Otherwise, the request will be denied.
//
pub cont: Option<extern "C" fn(this: *mut cef_quota_callback_t,
allow: libc::c_int) -> ()>,
//
// Cancel the quota request.
//
pub cancel: Option<extern "C" fn(this: *mut cef_quota_callback_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_quota_callback_t = _cef_quota_callback_t;
//
// Callback structure used for asynchronous continuation of quota requests.
//
pub struct CefQuotaCallback {
c_object: *mut cef_quota_callback_t,
}
impl Clone for CefQuotaCallback {
fn clone(&self) -> CefQuotaCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefQuotaCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefQuotaCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefQuotaCallback {
pub unsafe fn from_c_object(c_object: *mut cef_quota_callback_t) -> CefQuotaCallback {
CefQuotaCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_quota_callback_t) -> CefQuotaCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefQuotaCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_quota_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_quota_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Continue the quota request. If |allow| is true (1) the request will be
// allowed. Otherwise, the request will be denied.
//
pub fn cont(&self, allow: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cont.unwrap())(
self.c_object,
CefWrap::to_c(allow)))
}
}
//
// Cancel the quota request.
//
pub fn cancel(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cancel.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_quota_callback_t> for CefQuotaCallback {
fn to_c(rust_object: CefQuotaCallback) -> *mut cef_quota_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_quota_callback_t) -> CefQuotaCallback {
CefQuotaCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_quota_callback_t> for Option<CefQuotaCallback> {
fn to_c(rust_object: Option<CefQuotaCallback>) -> *mut cef_quota_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_quota_callback_t) -> Option<CefQuotaCallback> {
if c_object.is_null() {
None
} else {
Some(CefQuotaCallback::from_c_object_addref(c_object))
}
}
}
//
// Callback structure used for asynchronous continuation of url requests when
// invalid SSL certificates are encountered.
//
#[repr(C)]
pub struct _cef_allow_certificate_error_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Continue the url request. If |allow| is true (1) the request will be
// continued. Otherwise, the request will be canceled.
//
pub cont: Option<extern "C" fn(
this: *mut cef_allow_certificate_error_callback_t,
allow: libc::c_int) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_allow_certificate_error_callback_t = _cef_allow_certificate_error_callback_t;
//
// Callback structure used for asynchronous continuation of url requests when
// invalid SSL certificates are encountered.
//
pub struct CefAllowCertificateErrorCallback {
c_object: *mut cef_allow_certificate_error_callback_t,
}
impl Clone for CefAllowCertificateErrorCallback {
fn clone(&self) -> CefAllowCertificateErrorCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefAllowCertificateErrorCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefAllowCertificateErrorCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefAllowCertificateErrorCallback {
pub unsafe fn from_c_object(c_object: *mut cef_allow_certificate_error_callback_t) -> CefAllowCertificateErrorCallback {
CefAllowCertificateErrorCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_allow_certificate_error_callback_t) -> CefAllowCertificateErrorCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefAllowCertificateErrorCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_allow_certificate_error_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_allow_certificate_error_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Continue the url request. If |allow| is true (1) the request will be
// continued. Otherwise, the request will be canceled.
//
pub fn cont(&self, allow: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cont.unwrap())(
self.c_object,
CefWrap::to_c(allow)))
}
}
}
impl CefWrap<*mut cef_allow_certificate_error_callback_t> for CefAllowCertificateErrorCallback {
fn to_c(rust_object: CefAllowCertificateErrorCallback) -> *mut cef_allow_certificate_error_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_allow_certificate_error_callback_t) -> CefAllowCertificateErrorCallback {
CefAllowCertificateErrorCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_allow_certificate_error_callback_t> for Option<CefAllowCertificateErrorCallback> {
fn to_c(rust_object: Option<CefAllowCertificateErrorCallback>) -> *mut cef_allow_certificate_error_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_allow_certificate_error_callback_t) -> Option<CefAllowCertificateErrorCallback> {
if c_object.is_null() {
None
} else {
Some(CefAllowCertificateErrorCallback::from_c_object_addref(c_object))
}
}
}
//
// Implement this structure to handle events related to browser requests. The
// functions of this structure will be called on the thread indicated.
//
#[repr(C)]
pub struct _cef_request_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called on the UI thread before browser navigation. Return true (1) to
// cancel the navigation or false (0) to allow the navigation to proceed. The
// |request| object cannot be modified in this callback.
// cef_load_handler_t::OnLoadingStateChange will be called twice in all cases.
// If the navigation is allowed cef_load_handler_t::OnLoadStart and
// cef_load_handler_t::OnLoadEnd will be called. If the navigation is canceled
// cef_load_handler_t::OnLoadError will be called with an |errorCode| value of
// ERR_ABORTED.
//
pub on_before_browse: Option<extern "C" fn(this: *mut cef_request_handler_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
request: *mut interfaces::cef_request_t,
is_redirect: libc::c_int) -> libc::c_int>,
//
// Called on the IO thread before a resource request is loaded. The |request|
// object may be modified. To cancel the request return true (1) otherwise
// return false (0).
//
pub on_before_resource_load: Option<extern "C" fn(
this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
request: *mut interfaces::cef_request_t) -> libc::c_int>,
//
// Called on the IO thread before a resource is loaded. To allow the resource
// to load normally return NULL. To specify a handler for the resource return
// a cef_resource_handler_t object. The |request| object should not be
// modified in this callback.
//
pub get_resource_handler: Option<extern "C" fn(
this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
request: *mut interfaces::cef_request_t) -> *mut interfaces::cef_resource_handler_t>,
//
// Called on the IO thread when a resource load is redirected. The |old_url|
// parameter will contain the old URL. The |new_url| parameter will contain
// the new URL and can be changed if desired.
//
pub on_resource_redirect: Option<extern "C" fn(
this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t, old_url: *const types::cef_string_t,
new_url: *mut types::cef_string_t) -> ()>,
//
// Called on the IO thread when the browser needs credentials from the user.
// |isProxy| indicates whether the host is a proxy server. |host| contains the
// hostname and |port| contains the port number. Return true (1) to continue
// the request and call cef_auth_callback_t::cont() when the authentication
// information is available. Return false (0) to cancel the request.
//
pub get_auth_credentials: Option<extern "C" fn(
this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t, isProxy: libc::c_int,
host: *const types::cef_string_t, port: libc::c_int,
realm: *const types::cef_string_t, scheme: *const types::cef_string_t,
callback: *mut interfaces::cef_auth_callback_t) -> libc::c_int>,
//
// Called on the IO thread when JavaScript requests a specific storage quota
// size via the webkitStorageInfo.requestQuota function. |origin_url| is the
// origin of the page making the request. |new_size| is the requested quota
// size in bytes. Return true (1) and call cef_quota_callback_t::cont() either
// in this function or at a later time to grant or deny the request. Return
// false (0) to cancel the request.
//
pub on_quota_request: Option<extern "C" fn(this: *mut cef_request_handler_t,
browser: *mut interfaces::cef_browser_t,
origin_url: *const types::cef_string_t, new_size: i64,
callback: *mut interfaces::cef_quota_callback_t) -> libc::c_int>,
//
// Called on the UI thread to handle requests for URLs with an unknown
// protocol component. Set |allow_os_execution| to true (1) to attempt
// execution via the registered OS protocol handler, if any. SECURITY WARNING:
// YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR
// OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
//
pub on_protocol_execution: Option<extern "C" fn(
this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t,
url: *const types::cef_string_t,
allow_os_execution: *mut libc::c_int) -> ()>,
//
// Called on the UI thread to handle requests for URLs with an invalid SSL
// certificate. Return true (1) and call
// cef_allow_certificate_error_callback_t:: cont() either in this function or
// at a later time to continue or cancel the request. Return false (0) to
// cancel the request immediately. If |callback| is NULL the error cannot be
// recovered from and the request will be canceled automatically. If
// CefSettings.ignore_certificate_errors is set all invalid certificates will
// be accepted without calling this function.
//
pub on_certificate_error: Option<extern "C" fn(
this: *mut cef_request_handler_t, cert_error: types::cef_errorcode_t,
request_url: *const types::cef_string_t,
callback: *mut interfaces::cef_allow_certificate_error_callback_t) -> libc::c_int>,
//
// Called on the browser process IO thread before a plugin is loaded. Return
// true (1) to block loading of the plugin.
//
pub on_before_plugin_load: Option<extern "C" fn(
this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t,
url: *const types::cef_string_t, policy_url: *const types::cef_string_t,
info: *mut interfaces::cef_web_plugin_info_t) -> libc::c_int>,
//
// Called on the browser process UI thread when a plugin has crashed.
// |plugin_path| is the path of the plugin that crashed.
//
pub on_plugin_crashed: Option<extern "C" fn(this: *mut cef_request_handler_t,
browser: *mut interfaces::cef_browser_t,
plugin_path: *const types::cef_string_t) -> ()>,
//
// Called on the browser process UI thread when the render process terminates
// unexpectedly. |status| indicates how the process terminated.
//
pub on_render_process_terminated: Option<extern "C" fn(
this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t,
status: types::cef_termination_status_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_request_handler_t = _cef_request_handler_t;
//
// Implement this structure to handle events related to browser requests. The
// functions of this structure will be called on the thread indicated.
//
pub struct CefRequestHandler {
c_object: *mut cef_request_handler_t,
}
impl Clone for CefRequestHandler {
fn clone(&self) -> CefRequestHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefRequestHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefRequestHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefRequestHandler {
pub unsafe fn from_c_object(c_object: *mut cef_request_handler_t) -> CefRequestHandler {
CefRequestHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_request_handler_t) -> CefRequestHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefRequestHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_request_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_request_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called on the UI thread before browser navigation. Return true (1) to
// cancel the navigation or false (0) to allow the navigation to proceed. The
// |request| object cannot be modified in this callback.
// cef_load_handler_t::OnLoadingStateChange will be called twice in all cases.
// If the navigation is allowed cef_load_handler_t::OnLoadStart and
// cef_load_handler_t::OnLoadEnd will be called. If the navigation is canceled
// cef_load_handler_t::OnLoadError will be called with an |errorCode| value of
// ERR_ABORTED.
//
pub fn on_before_browse(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, request: interfaces::CefRequest,
is_redirect: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_before_browse.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(request),
CefWrap::to_c(is_redirect)))
}
}
//
// Called on the IO thread before a resource request is loaded. The |request|
// object may be modified. To cancel the request return true (1) otherwise
// return false (0).
//
pub fn on_before_resource_load(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame,
request: interfaces::CefRequest) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_before_resource_load.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(request)))
}
}
//
// Called on the IO thread before a resource is loaded. To allow the resource
// to load normally return NULL. To specify a handler for the resource return
// a cef_resource_handler_t object. The |request| object should not be
// modified in this callback.
//
pub fn get_resource_handler(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame,
request: interfaces::CefRequest) -> interfaces::CefResourceHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_resource_handler.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(request)))
}
}
//
// Called on the IO thread when a resource load is redirected. The |old_url|
// parameter will contain the old URL. The |new_url| parameter will contain
// the new URL and can be changed if desired.
//
pub fn on_resource_redirect(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, old_url: &[u16],
new_url: *mut types::cef_string_t) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_resource_redirect.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(old_url),
CefWrap::to_c(new_url)))
}
}
//
// Called on the IO thread when the browser needs credentials from the user.
// |isProxy| indicates whether the host is a proxy server. |host| contains the
// hostname and |port| contains the port number. Return true (1) to continue
// the request and call cef_auth_callback_t::cont() when the authentication
// information is available. Return false (0) to cancel the request.
//
pub fn get_auth_credentials(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, isProxy: libc::c_int, host: &[u16],
port: libc::c_int, realm: &[u16], scheme: &[u16],
callback: interfaces::CefAuthCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_auth_credentials.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(isProxy),
CefWrap::to_c(host),
CefWrap::to_c(port),
CefWrap::to_c(realm),
CefWrap::to_c(scheme),
CefWrap::to_c(callback)))
}
}
//
// Called on the IO thread when JavaScript requests a specific storage quota
// size via the webkitStorageInfo.requestQuota function. |origin_url| is the
// origin of the page making the request. |new_size| is the requested quota
// size in bytes. Return true (1) and call cef_quota_callback_t::cont() either
// in this function or at a later time to grant or deny the request. Return
// false (0) to cancel the request.
//
pub fn on_quota_request(&self, browser: interfaces::CefBrowser,
origin_url: &[u16], new_size: i64,
callback: interfaces::CefQuotaCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_quota_request.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(origin_url),
CefWrap::to_c(new_size),
CefWrap::to_c(callback)))
}
}
//
// Called on the UI thread to handle requests for URLs with an unknown
// protocol component. Set |allow_os_execution| to true (1) to attempt
// execution via the registered OS protocol handler, if any. SECURITY WARNING:
// YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR
// OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
//
pub fn on_protocol_execution(&self, browser: interfaces::CefBrowser,
url: &[u16], allow_os_execution: &mut libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_protocol_execution.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(url),
CefWrap::to_c(allow_os_execution)))
}
}
//
// Called on the UI thread to handle requests for URLs with an invalid SSL
// certificate. Return true (1) and call
// cef_allow_certificate_error_callback_t:: cont() either in this function or
// at a later time to continue or cancel the request. Return false (0) to
// cancel the request immediately. If |callback| is NULL the error cannot be
// recovered from and the request will be canceled automatically. If
// CefSettings.ignore_certificate_errors is set all invalid certificates will
// be accepted without calling this function.
//
pub fn on_certificate_error(&self, cert_error: types::cef_errorcode_t,
request_url: &[u16],
callback: interfaces::CefAllowCertificateErrorCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_certificate_error.unwrap())(
self.c_object,
CefWrap::to_c(cert_error),
CefWrap::to_c(request_url),
CefWrap::to_c(callback)))
}
}
//
// Called on the browser process IO thread before a plugin is loaded. Return
// true (1) to block loading of the plugin.
//
pub fn on_before_plugin_load(&self, browser: interfaces::CefBrowser,
url: &[u16], policy_url: &[u16],
info: interfaces::CefWebPluginInfo) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_before_plugin_load.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(url),
CefWrap::to_c(policy_url),
CefWrap::to_c(info)))
}
}
//
// Called on the browser process UI thread when a plugin has crashed.
// |plugin_path| is the path of the plugin that crashed.
//
pub fn on_plugin_crashed(&self, browser: interfaces::CefBrowser,
plugin_path: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_plugin_crashed.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(plugin_path)))
}
}
//
// Called on the browser process UI thread when the render process terminates
// unexpectedly. |status| indicates how the process terminated.
//
pub fn on_render_process_terminated(&self, browser: interfaces::CefBrowser,
status: types::cef_termination_status_t) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_render_process_terminated.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(status)))
}
}
}
impl CefWrap<*mut cef_request_handler_t> for CefRequestHandler {
fn to_c(rust_object: CefRequestHandler) -> *mut cef_request_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_request_handler_t) -> CefRequestHandler {
CefRequestHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_request_handler_t> for Option<CefRequestHandler> {
fn to_c(rust_object: Option<CefRequestHandler>) -> *mut cef_request_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_request_handler_t) -> Option<CefRequestHandler> {
if c_object.is_null() {
None
} else {
Some(CefRequestHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,231 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure used to implement a custom resource bundle structure. The functions
// of this structure may be called on multiple threads.
//
#[repr(C)]
pub struct _cef_resource_bundle_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called to retrieve a localized translation for the string specified by
// |message_id|. To provide the translation set |string| to the translation
// string and return true (1). To use the default translation return false
// (0). Supported message IDs are listed in cef_pack_strings.h.
//
pub get_localized_string: Option<extern "C" fn(
this: *mut cef_resource_bundle_handler_t, message_id: libc::c_int,
string: *mut types::cef_string_t) -> libc::c_int>,
//
// Called to retrieve data for the resource specified by |resource_id|. To
// provide the resource data set |data| and |data_size| to the data pointer
// and size respectively and return true (1). To use the default resource data
// return false (0). The resource data will not be copied and must remain
// resident in memory. Supported resource IDs are listed in
// cef_pack_resources.h.
//
pub get_data_resource: Option<extern "C" fn(
this: *mut cef_resource_bundle_handler_t, resource_id: libc::c_int,
data: *mut *mut libc::c_void,
data_size: *mut libc::size_t) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_resource_bundle_handler_t = _cef_resource_bundle_handler_t;
//
// Structure used to implement a custom resource bundle structure. The functions
// of this structure may be called on multiple threads.
//
pub struct CefResourceBundleHandler {
c_object: *mut cef_resource_bundle_handler_t,
}
impl Clone for CefResourceBundleHandler {
fn clone(&self) -> CefResourceBundleHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefResourceBundleHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefResourceBundleHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefResourceBundleHandler {
pub unsafe fn from_c_object(c_object: *mut cef_resource_bundle_handler_t) -> CefResourceBundleHandler {
CefResourceBundleHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_resource_bundle_handler_t) -> CefResourceBundleHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefResourceBundleHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_resource_bundle_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_resource_bundle_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called to retrieve a localized translation for the string specified by
// |message_id|. To provide the translation set |string| to the translation
// string and return true (1). To use the default translation return false
// (0). Supported message IDs are listed in cef_pack_strings.h.
//
pub fn get_localized_string(&self, message_id: libc::c_int,
string: *mut types::cef_string_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_localized_string.unwrap())(
self.c_object,
CefWrap::to_c(message_id),
CefWrap::to_c(string)))
}
}
//
// Called to retrieve data for the resource specified by |resource_id|. To
// provide the resource data set |data| and |data_size| to the data pointer
// and size respectively and return true (1). To use the default resource data
// return false (0). The resource data will not be copied and must remain
// resident in memory. Supported resource IDs are listed in
// cef_pack_resources.h.
//
pub fn get_data_resource(&self, resource_id: libc::c_int,
data: &mut *mut libc::c_void,
data_size: &mut libc::size_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_data_resource.unwrap())(
self.c_object,
CefWrap::to_c(resource_id),
CefWrap::to_c(data),
CefWrap::to_c(data_size)))
}
}
}
impl CefWrap<*mut cef_resource_bundle_handler_t> for CefResourceBundleHandler {
fn to_c(rust_object: CefResourceBundleHandler) -> *mut cef_resource_bundle_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_resource_bundle_handler_t) -> CefResourceBundleHandler {
CefResourceBundleHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_resource_bundle_handler_t> for Option<CefResourceBundleHandler> {
fn to_c(rust_object: Option<CefResourceBundleHandler>) -> *mut cef_resource_bundle_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_resource_bundle_handler_t) -> Option<CefResourceBundleHandler> {
if c_object.is_null() {
None
} else {
Some(CefResourceBundleHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,340 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure used to implement a custom request handler structure. The functions
// of this structure will always be called on the IO thread.
//
#[repr(C)]
pub struct _cef_resource_handler_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Begin processing the request. To handle the request return true (1) and
// call cef_callback_t::cont() once the response header information is
// available (cef_callback_t::cont() can also be called from inside this
// function if header information is available immediately). To cancel the
// request return false (0).
//
pub process_request: Option<extern "C" fn(this: *mut cef_resource_handler_t,
request: *mut interfaces::cef_request_t,
callback: *mut interfaces::cef_callback_t) -> libc::c_int>,
//
// Retrieve response header information. If the response length is not known
// set |response_length| to -1 and read_response() will be called until it
// returns false (0). If the response length is known set |response_length| to
// a positive value and read_response() will be called until it returns false
// (0) or the specified number of bytes have been read. Use the |response|
// object to set the mime type, http status code and other optional header
// values. To redirect the request to a new URL set |redirectUrl| to the new
// URL.
//
pub get_response_headers: Option<extern "C" fn(
this: *mut cef_resource_handler_t,
response: *mut interfaces::cef_response_t, response_length: *mut i64,
redirectUrl: *mut types::cef_string_t) -> ()>,
//
// Read response data. If data is available immediately copy up to
// |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of
// bytes copied, and return true (1). To read the data at a later time set
// |bytes_read| to 0, return true (1) and call cef_callback_t::cont() when the
// data is available. To indicate response completion return false (0).
//
pub read_response: Option<extern "C" fn(this: *mut cef_resource_handler_t,
data_out: *mut (), bytes_to_read: libc::c_int,
bytes_read: *mut libc::c_int,
callback: *mut interfaces::cef_callback_t) -> libc::c_int>,
//
// Return true (1) if the specified cookie can be sent with the request or
// false (0) otherwise. If false (0) is returned for any cookie then no
// cookies will be sent with the request.
//
pub can_get_cookie: Option<extern "C" fn(this: *mut cef_resource_handler_t,
cookie: *const interfaces::cef_cookie_t) -> libc::c_int>,
//
// Return true (1) if the specified cookie returned with the response can be
// set or false (0) otherwise.
//
pub can_set_cookie: Option<extern "C" fn(this: *mut cef_resource_handler_t,
cookie: *const interfaces::cef_cookie_t) -> libc::c_int>,
//
// Request processing has been canceled.
//
pub cancel: Option<extern "C" fn(this: *mut cef_resource_handler_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_resource_handler_t = _cef_resource_handler_t;
//
// Structure used to implement a custom request handler structure. The functions
// of this structure will always be called on the IO thread.
//
pub struct CefResourceHandler {
c_object: *mut cef_resource_handler_t,
}
impl Clone for CefResourceHandler {
fn clone(&self) -> CefResourceHandler{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefResourceHandler {
c_object: self.c_object,
}
}
}
}
impl Drop for CefResourceHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefResourceHandler {
pub unsafe fn from_c_object(c_object: *mut cef_resource_handler_t) -> CefResourceHandler {
CefResourceHandler {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_resource_handler_t) -> CefResourceHandler {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefResourceHandler {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_resource_handler_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_resource_handler_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Begin processing the request. To handle the request return true (1) and
// call cef_callback_t::cont() once the response header information is
// available (cef_callback_t::cont() can also be called from inside this
// function if header information is available immediately). To cancel the
// request return false (0).
//
pub fn process_request(&self, request: interfaces::CefRequest,
callback: interfaces::CefCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).process_request.unwrap())(
self.c_object,
CefWrap::to_c(request),
CefWrap::to_c(callback)))
}
}
//
// Retrieve response header information. If the response length is not known
// set |response_length| to -1 and read_response() will be called until it
// returns false (0). If the response length is known set |response_length| to
// a positive value and read_response() will be called until it returns false
// (0) or the specified number of bytes have been read. Use the |response|
// object to set the mime type, http status code and other optional header
// values. To redirect the request to a new URL set |redirectUrl| to the new
// URL.
//
pub fn get_response_headers(&self, response: interfaces::CefResponse,
response_length: &mut i64, redirectUrl: *mut types::cef_string_t) -> (
) {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_response_headers.unwrap())(
self.c_object,
CefWrap::to_c(response),
CefWrap::to_c(response_length),
CefWrap::to_c(redirectUrl)))
}
}
//
// Read response data. If data is available immediately copy up to
// |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of
// bytes copied, and return true (1). To read the data at a later time set
// |bytes_read| to 0, return true (1) and call cef_callback_t::cont() when the
// data is available. To indicate response completion return false (0).
//
pub fn read_response(&self, data_out: &mut (), bytes_to_read: libc::c_int,
bytes_read: &mut libc::c_int,
callback: interfaces::CefCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).read_response.unwrap())(
self.c_object,
CefWrap::to_c(data_out),
CefWrap::to_c(bytes_to_read),
CefWrap::to_c(bytes_read),
CefWrap::to_c(callback)))
}
}
//
// Return true (1) if the specified cookie can be sent with the request or
// false (0) otherwise. If false (0) is returned for any cookie then no
// cookies will be sent with the request.
//
pub fn can_get_cookie(&self, cookie: &interfaces::CefCookie) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).can_get_cookie.unwrap())(
self.c_object,
CefWrap::to_c(cookie)))
}
}
//
// Return true (1) if the specified cookie returned with the response can be
// set or false (0) otherwise.
//
pub fn can_set_cookie(&self, cookie: &interfaces::CefCookie) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).can_set_cookie.unwrap())(
self.c_object,
CefWrap::to_c(cookie)))
}
}
//
// Request processing has been canceled.
//
pub fn cancel(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cancel.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_resource_handler_t> for CefResourceHandler {
fn to_c(rust_object: CefResourceHandler) -> *mut cef_resource_handler_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_resource_handler_t) -> CefResourceHandler {
CefResourceHandler::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_resource_handler_t> for Option<CefResourceHandler> {
fn to_c(rust_object: Option<CefResourceHandler>) -> *mut cef_resource_handler_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_resource_handler_t) -> Option<CefResourceHandler> {
if c_object.is_null() {
None
} else {
Some(CefResourceHandler::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,387 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure used to represent a web response. The functions of this structure
// may be called on any thread.
//
#[repr(C)]
pub struct _cef_response_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Returns true (1) if this object is read-only.
//
pub is_read_only: Option<extern "C" fn(
this: *mut cef_response_t) -> libc::c_int>,
//
// Get the response status code.
//
pub get_status: Option<extern "C" fn(
this: *mut cef_response_t) -> libc::c_int>,
//
// Set the response status code.
//
pub set_status: Option<extern "C" fn(this: *mut cef_response_t,
status: libc::c_int) -> ()>,
//
// Get the response status text.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_status_text: Option<extern "C" fn(
this: *mut cef_response_t) -> types::cef_string_userfree_t>,
//
// Set the response status text.
//
pub set_status_text: Option<extern "C" fn(this: *mut cef_response_t,
statusText: *const types::cef_string_t) -> ()>,
//
// Get the response mime type.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_mime_type: Option<extern "C" fn(
this: *mut cef_response_t) -> types::cef_string_userfree_t>,
//
// Set the response mime type.
//
pub set_mime_type: Option<extern "C" fn(this: *mut cef_response_t,
mimeType: *const types::cef_string_t) -> ()>,
//
// Get the value for the specified response header field.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_header: Option<extern "C" fn(this: *mut cef_response_t,
name: *const types::cef_string_t) -> types::cef_string_userfree_t>,
//
// Get all response header fields.
//
pub get_header_map: Option<extern "C" fn(this: *mut cef_response_t,
headerMap: types::cef_string_multimap_t) -> ()>,
//
// Set all response header fields.
//
pub set_header_map: Option<extern "C" fn(this: *mut cef_response_t,
headerMap: types::cef_string_multimap_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_response_t = _cef_response_t;
//
// Structure used to represent a web response. The functions of this structure
// may be called on any thread.
//
pub struct CefResponse {
c_object: *mut cef_response_t,
}
impl Clone for CefResponse {
fn clone(&self) -> CefResponse{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefResponse {
c_object: self.c_object,
}
}
}
}
impl Drop for CefResponse {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefResponse {
pub unsafe fn from_c_object(c_object: *mut cef_response_t) -> CefResponse {
CefResponse {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_response_t) -> CefResponse {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefResponse {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_response_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_response_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Returns true (1) if this object is read-only.
//
pub fn is_read_only(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_read_only.unwrap())(
self.c_object))
}
}
//
// Get the response status code.
//
pub fn get_status(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_status.unwrap())(
self.c_object))
}
}
//
// Set the response status code.
//
pub fn set_status(&self, status: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_status.unwrap())(
self.c_object,
CefWrap::to_c(status)))
}
}
//
// Get the response status text.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_status_text(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_status_text.unwrap())(
self.c_object))
}
}
//
// Set the response status text.
//
pub fn set_status_text(&self, statusText: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_status_text.unwrap())(
self.c_object,
CefWrap::to_c(statusText)))
}
}
//
// Get the response mime type.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_mime_type(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_mime_type.unwrap())(
self.c_object))
}
}
//
// Set the response mime type.
//
pub fn set_mime_type(&self, mimeType: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_mime_type.unwrap())(
self.c_object,
CefWrap::to_c(mimeType)))
}
}
//
// Get the value for the specified response header field.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_header(&self, name: &[u16]) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_header.unwrap())(
self.c_object,
CefWrap::to_c(name)))
}
}
//
// Get all response header fields.
//
pub fn get_header_map(&self, headerMap: HashMap<String,Vec<String>>) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_header_map.unwrap())(
self.c_object,
CefWrap::to_c(headerMap)))
}
}
//
// Set all response header fields.
//
pub fn set_header_map(&self, headerMap: HashMap<String,Vec<String>>) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).set_header_map.unwrap())(
self.c_object,
CefWrap::to_c(headerMap)))
}
}
//
// Create a new cef_response_t object.
//
pub fn create() -> interfaces::CefResponse {
unsafe {
CefWrap::to_rust(
::response::cef_response_create(
))
}
}
}
impl CefWrap<*mut cef_response_t> for CefResponse {
fn to_c(rust_object: CefResponse) -> *mut cef_response_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_response_t) -> CefResponse {
CefResponse::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_response_t> for Option<CefResponse> {
fn to_c(rust_object: Option<CefResponse>) -> *mut cef_response_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_response_t) -> Option<CefResponse> {
if c_object.is_null() {
None
} else {
Some(CefResponse::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,434 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure that manages custom scheme registrations.
//
#[repr(C)]
pub struct _cef_scheme_registrar_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Register a custom scheme. This function should not be called for the built-
// in HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes.
//
// If |is_standard| is true (1) the scheme will be treated as a standard
// scheme. Standard schemes are subject to URL canonicalization and parsing
// rules as defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1
// available at http://www.ietf.org/rfc/rfc1738.txt
//
// In particular, the syntax for standard scheme URLs must be of the form:
// <pre>
// [scheme]://[username]:[password]@[host]:[port]/[url-path]
// </pre> Standard scheme URLs must have a host component that is a fully
// qualified domain name as defined in Section 3.5 of RFC 1034 [13] and
// Section 2.1 of RFC 1123. These URLs will be canonicalized to
// "scheme://host/path" in the simplest case and
// "scheme://username:password@host:port/path" in the most explicit case. For
// example, "scheme:host/path" and "scheme:///host/path" will both be
// canonicalized to "scheme://host/path". The origin of a standard scheme URL
// is the combination of scheme, host and port (i.e., "scheme://host:port" in
// the most explicit case).
//
// For non-standard scheme URLs only the "scheme:" component is parsed and
// canonicalized. The remainder of the URL will be passed to the handler as-
// is. For example, "scheme:///some%20text" will remain the same. Non-standard
// scheme URLs cannot be used as a target for form submission.
//
// If |is_local| is true (1) the scheme will be treated as local (i.e., with
// the same security rules as those applied to "file" URLs). Normal pages
// cannot link to or access local URLs. Also, by default, local URLs can only
// perform XMLHttpRequest calls to the same URL (origin + path) that
// originated the request. To allow XMLHttpRequest calls from a local URL to
// other URLs with the same origin set the
// CefSettings.file_access_from_file_urls_allowed value to true (1). To allow
// XMLHttpRequest calls from a local URL to all origins set the
// CefSettings.universal_access_from_file_urls_allowed value to true (1).
//
// If |is_display_isolated| is true (1) the scheme will be treated as display-
// isolated. This means that pages cannot display these URLs unless they are
// from the same scheme. For example, pages in another origin cannot create
// iframes or hyperlinks to URLs with this scheme.
//
// This function may be called on any thread. It should only be called once
// per unique |scheme_name| value. If |scheme_name| is already registered or
// if an error occurs this function will return false (0).
//
pub add_custom_scheme: Option<extern "C" fn(this: *mut cef_scheme_registrar_t,
scheme_name: *const types::cef_string_t, is_standard: libc::c_int,
is_local: libc::c_int, is_display_isolated: libc::c_int) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_scheme_registrar_t = _cef_scheme_registrar_t;
//
// Structure that manages custom scheme registrations.
//
pub struct CefSchemeRegistrar {
c_object: *mut cef_scheme_registrar_t,
}
impl Clone for CefSchemeRegistrar {
fn clone(&self) -> CefSchemeRegistrar{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefSchemeRegistrar {
c_object: self.c_object,
}
}
}
}
impl Drop for CefSchemeRegistrar {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefSchemeRegistrar {
pub unsafe fn from_c_object(c_object: *mut cef_scheme_registrar_t) -> CefSchemeRegistrar {
CefSchemeRegistrar {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_scheme_registrar_t) -> CefSchemeRegistrar {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefSchemeRegistrar {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_scheme_registrar_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_scheme_registrar_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Register a custom scheme. This function should not be called for the built-
// in HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes.
//
// If |is_standard| is true (1) the scheme will be treated as a standard
// scheme. Standard schemes are subject to URL canonicalization and parsing
// rules as defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1
// available at http://www.ietf.org/rfc/rfc1738.txt
//
// In particular, the syntax for standard scheme URLs must be of the form:
// <pre>
// [scheme]://[username]:[password]@[host]:[port]/[url-path]
// </pre> Standard scheme URLs must have a host component that is a fully
// qualified domain name as defined in Section 3.5 of RFC 1034 [13] and
// Section 2.1 of RFC 1123. These URLs will be canonicalized to
// "scheme://host/path" in the simplest case and
// "scheme://username:password@host:port/path" in the most explicit case. For
// example, "scheme:host/path" and "scheme:///host/path" will both be
// canonicalized to "scheme://host/path". The origin of a standard scheme URL
// is the combination of scheme, host and port (i.e., "scheme://host:port" in
// the most explicit case).
//
// For non-standard scheme URLs only the "scheme:" component is parsed and
// canonicalized. The remainder of the URL will be passed to the handler as-
// is. For example, "scheme:///some%20text" will remain the same. Non-standard
// scheme URLs cannot be used as a target for form submission.
//
// If |is_local| is true (1) the scheme will be treated as local (i.e., with
// the same security rules as those applied to "file" URLs). Normal pages
// cannot link to or access local URLs. Also, by default, local URLs can only
// perform XMLHttpRequest calls to the same URL (origin + path) that
// originated the request. To allow XMLHttpRequest calls from a local URL to
// other URLs with the same origin set the
// CefSettings.file_access_from_file_urls_allowed value to true (1). To allow
// XMLHttpRequest calls from a local URL to all origins set the
// CefSettings.universal_access_from_file_urls_allowed value to true (1).
//
// If |is_display_isolated| is true (1) the scheme will be treated as display-
// isolated. This means that pages cannot display these URLs unless they are
// from the same scheme. For example, pages in another origin cannot create
// iframes or hyperlinks to URLs with this scheme.
//
// This function may be called on any thread. It should only be called once
// per unique |scheme_name| value. If |scheme_name| is already registered or
// if an error occurs this function will return false (0).
//
pub fn add_custom_scheme(&self, scheme_name: &[u16], is_standard: libc::c_int,
is_local: libc::c_int,
is_display_isolated: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).add_custom_scheme.unwrap())(
self.c_object,
CefWrap::to_c(scheme_name),
CefWrap::to_c(is_standard),
CefWrap::to_c(is_local),
CefWrap::to_c(is_display_isolated)))
}
}
}
impl CefWrap<*mut cef_scheme_registrar_t> for CefSchemeRegistrar {
fn to_c(rust_object: CefSchemeRegistrar) -> *mut cef_scheme_registrar_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_scheme_registrar_t) -> CefSchemeRegistrar {
CefSchemeRegistrar::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_scheme_registrar_t> for Option<CefSchemeRegistrar> {
fn to_c(rust_object: Option<CefSchemeRegistrar>) -> *mut cef_scheme_registrar_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_scheme_registrar_t) -> Option<CefSchemeRegistrar> {
if c_object.is_null() {
None
} else {
Some(CefSchemeRegistrar::from_c_object_addref(c_object))
}
}
}
//
// Structure that creates cef_resource_handler_t instances for handling scheme
// requests. The functions of this structure will always be called on the IO
// thread.
//
#[repr(C)]
pub struct _cef_scheme_handler_factory_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Return a new resource handler instance to handle the request or an NULL
// reference to allow default handling of the request. |browser| and |frame|
// will be the browser window and frame respectively that originated the
// request or NULL if the request did not originate from a browser window (for
// example, if the request came from cef_urlrequest_t). The |request| object
// passed to this function will not contain cookie data.
//
pub create: Option<extern "C" fn(this: *mut cef_scheme_handler_factory_t,
browser: *mut interfaces::cef_browser_t,
frame: *mut interfaces::cef_frame_t,
scheme_name: *const types::cef_string_t,
request: *mut interfaces::cef_request_t) -> *mut interfaces::cef_resource_handler_t>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_scheme_handler_factory_t = _cef_scheme_handler_factory_t;
//
// Structure that creates cef_resource_handler_t instances for handling scheme
// requests. The functions of this structure will always be called on the IO
// thread.
//
pub struct CefSchemeHandlerFactory {
c_object: *mut cef_scheme_handler_factory_t,
}
impl Clone for CefSchemeHandlerFactory {
fn clone(&self) -> CefSchemeHandlerFactory{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefSchemeHandlerFactory {
c_object: self.c_object,
}
}
}
}
impl Drop for CefSchemeHandlerFactory {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefSchemeHandlerFactory {
pub unsafe fn from_c_object(c_object: *mut cef_scheme_handler_factory_t) -> CefSchemeHandlerFactory {
CefSchemeHandlerFactory {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_scheme_handler_factory_t) -> CefSchemeHandlerFactory {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefSchemeHandlerFactory {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_scheme_handler_factory_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_scheme_handler_factory_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Return a new resource handler instance to handle the request or an NULL
// reference to allow default handling of the request. |browser| and |frame|
// will be the browser window and frame respectively that originated the
// request or NULL if the request did not originate from a browser window (for
// example, if the request came from cef_urlrequest_t). The |request| object
// passed to this function will not contain cookie data.
//
pub fn create(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, scheme_name: &[u16],
request: interfaces::CefRequest) -> interfaces::CefResourceHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).create.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(frame),
CefWrap::to_c(scheme_name),
CefWrap::to_c(request)))
}
}
}
impl CefWrap<*mut cef_scheme_handler_factory_t> for CefSchemeHandlerFactory {
fn to_c(rust_object: CefSchemeHandlerFactory) -> *mut cef_scheme_handler_factory_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_scheme_handler_factory_t) -> CefSchemeHandlerFactory {
CefSchemeHandlerFactory::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_scheme_handler_factory_t> for Option<CefSchemeHandlerFactory> {
fn to_c(rust_object: Option<CefSchemeHandlerFactory>) -> *mut cef_scheme_handler_factory_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_scheme_handler_factory_t) -> Option<CefSchemeHandlerFactory> {
if c_object.is_null() {
None
} else {
Some(CefSchemeHandlerFactory::from_c_object_addref(c_object))
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,183 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to receive string values asynchronously.
//
#[repr(C)]
pub struct _cef_string_visitor_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Method that will be executed.
//
pub visit: Option<extern "C" fn(this: *mut cef_string_visitor_t,
string: *const types::cef_string_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_string_visitor_t = _cef_string_visitor_t;
//
// Implement this structure to receive string values asynchronously.
//
pub struct CefStringVisitor {
c_object: *mut cef_string_visitor_t,
}
impl Clone for CefStringVisitor {
fn clone(&self) -> CefStringVisitor{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefStringVisitor {
c_object: self.c_object,
}
}
}
}
impl Drop for CefStringVisitor {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefStringVisitor {
pub unsafe fn from_c_object(c_object: *mut cef_string_visitor_t) -> CefStringVisitor {
CefStringVisitor {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_string_visitor_t) -> CefStringVisitor {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefStringVisitor {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_string_visitor_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_string_visitor_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Method that will be executed.
//
pub fn visit(&self, string: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).visit.unwrap())(
self.c_object,
CefWrap::to_c(string)))
}
}
}
impl CefWrap<*mut cef_string_visitor_t> for CefStringVisitor {
fn to_c(rust_object: CefStringVisitor) -> *mut cef_string_visitor_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_string_visitor_t) -> CefStringVisitor {
CefStringVisitor::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_string_visitor_t> for Option<CefStringVisitor> {
fn to_c(rust_object: Option<CefStringVisitor>) -> *mut cef_string_visitor_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_string_visitor_t) -> Option<CefStringVisitor> {
if c_object.is_null() {
None
} else {
Some(CefStringVisitor::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,461 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure for asynchronous task execution. If the task is
// posted successfully and if the associated message loop is still running then
// the execute() function will be called on the target thread. If the task fails
// to post then the task object may be destroyed on the source thread instead of
// the target thread. For this reason be cautious when performing work in the
// task object destructor.
//
#[repr(C)]
pub struct _cef_task_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Method that will be executed on the target thread.
//
pub execute: Option<extern "C" fn(this: *mut cef_task_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_task_t = _cef_task_t;
//
// Implement this structure for asynchronous task execution. If the task is
// posted successfully and if the associated message loop is still running then
// the execute() function will be called on the target thread. If the task fails
// to post then the task object may be destroyed on the source thread instead of
// the target thread. For this reason be cautious when performing work in the
// task object destructor.
//
pub struct CefTask {
c_object: *mut cef_task_t,
}
impl Clone for CefTask {
fn clone(&self) -> CefTask{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefTask {
c_object: self.c_object,
}
}
}
}
impl Drop for CefTask {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefTask {
pub unsafe fn from_c_object(c_object: *mut cef_task_t) -> CefTask {
CefTask {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_task_t) -> CefTask {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefTask {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_task_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_task_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Method that will be executed on the target thread.
//
pub fn execute(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).execute.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_task_t> for CefTask {
fn to_c(rust_object: CefTask) -> *mut cef_task_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_task_t) -> CefTask {
CefTask::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_task_t> for Option<CefTask> {
fn to_c(rust_object: Option<CefTask>) -> *mut cef_task_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_task_t) -> Option<CefTask> {
if c_object.is_null() {
None
} else {
Some(CefTask::from_c_object_addref(c_object))
}
}
}
//
// Structure that asynchronously executes tasks on the associated thread. It is
// safe to call the functions of this structure on any thread.
//
// CEF maintains multiple internal threads that are used for handling different
// types of tasks in different processes. The cef_thread_id_t definitions in
// cef_types.h list the common CEF threads. Task runners are also available for
// other CEF threads as appropriate (for example, V8 WebWorker threads).
//
#[repr(C)]
pub struct _cef_task_runner_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Returns true (1) if this object is pointing to the same task runner as
// |that| object.
//
pub is_same: Option<extern "C" fn(this: *mut cef_task_runner_t,
that: *mut interfaces::cef_task_runner_t) -> libc::c_int>,
//
// Returns true (1) if this task runner belongs to the current thread.
//
pub belongs_to_current_thread: Option<extern "C" fn(
this: *mut cef_task_runner_t) -> libc::c_int>,
//
// Returns true (1) if this task runner is for the specified CEF thread.
//
pub belongs_to_thread: Option<extern "C" fn(this: *mut cef_task_runner_t,
threadId: types::cef_thread_id_t) -> libc::c_int>,
//
// Post a task for execution on the thread associated with this task runner.
// Execution will occur asynchronously.
//
pub post_task: Option<extern "C" fn(this: *mut cef_task_runner_t,
task: *mut interfaces::cef_task_t) -> libc::c_int>,
//
// Post a task for delayed execution on the thread associated with this task
// runner. Execution will occur asynchronously. Delayed tasks are not
// supported on V8 WebWorker threads and will be executed without the
// specified delay.
//
pub post_delayed_task: Option<extern "C" fn(this: *mut cef_task_runner_t,
task: *mut interfaces::cef_task_t, delay_ms: i64) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_task_runner_t = _cef_task_runner_t;
//
// Structure that asynchronously executes tasks on the associated thread. It is
// safe to call the functions of this structure on any thread.
//
// CEF maintains multiple internal threads that are used for handling different
// types of tasks in different processes. The cef_thread_id_t definitions in
// cef_types.h list the common CEF threads. Task runners are also available for
// other CEF threads as appropriate (for example, V8 WebWorker threads).
//
pub struct CefTaskRunner {
c_object: *mut cef_task_runner_t,
}
impl Clone for CefTaskRunner {
fn clone(&self) -> CefTaskRunner{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefTaskRunner {
c_object: self.c_object,
}
}
}
}
impl Drop for CefTaskRunner {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefTaskRunner {
pub unsafe fn from_c_object(c_object: *mut cef_task_runner_t) -> CefTaskRunner {
CefTaskRunner {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_task_runner_t) -> CefTaskRunner {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefTaskRunner {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_task_runner_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_task_runner_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Returns true (1) if this object is pointing to the same task runner as
// |that| object.
//
pub fn is_same(&self, that: interfaces::CefTaskRunner) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_same.unwrap())(
self.c_object,
CefWrap::to_c(that)))
}
}
//
// Returns true (1) if this task runner belongs to the current thread.
//
pub fn belongs_to_current_thread(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).belongs_to_current_thread.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if this task runner is for the specified CEF thread.
//
pub fn belongs_to_thread(&self,
threadId: types::cef_thread_id_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).belongs_to_thread.unwrap())(
self.c_object,
CefWrap::to_c(threadId)))
}
}
//
// Post a task for execution on the thread associated with this task runner.
// Execution will occur asynchronously.
//
pub fn post_task(&self, task: interfaces::CefTask) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).post_task.unwrap())(
self.c_object,
CefWrap::to_c(task)))
}
}
//
// Post a task for delayed execution on the thread associated with this task
// runner. Execution will occur asynchronously. Delayed tasks are not
// supported on V8 WebWorker threads and will be executed without the
// specified delay.
//
pub fn post_delayed_task(&self, task: interfaces::CefTask,
delay_ms: i64) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).post_delayed_task.unwrap())(
self.c_object,
CefWrap::to_c(task),
CefWrap::to_c(delay_ms)))
}
}
//
// Returns the task runner for the current thread. Only CEF threads will have
// task runners. An NULL reference will be returned if this function is called
// on an invalid thread.
//
pub fn get_for_current_thread() -> interfaces::CefTaskRunner {
unsafe {
CefWrap::to_rust(
::task::cef_task_runner_get_for_current_thread(
))
}
}
//
// Returns the task runner for the specified CEF thread.
//
pub fn get_for_thread(
threadId: types::cef_thread_id_t) -> interfaces::CefTaskRunner {
unsafe {
CefWrap::to_rust(
::task::cef_task_runner_get_for_thread(
CefWrap::to_c(threadId)))
}
}
}
impl CefWrap<*mut cef_task_runner_t> for CefTaskRunner {
fn to_c(rust_object: CefTaskRunner) -> *mut cef_task_runner_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_task_runner_t) -> CefTaskRunner {
CefTaskRunner::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_task_runner_t> for Option<CefTaskRunner> {
fn to_c(rust_object: Option<CefTaskRunner>) -> *mut cef_task_runner_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_task_runner_t) -> Option<CefTaskRunner> {
if c_object.is_null() {
None
} else {
Some(CefTaskRunner::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,192 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Implement this structure to receive notification when tracing has completed.
// The functions of this structure will be called on the browser process UI
// thread.
//
#[repr(C)]
pub struct _cef_end_tracing_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Called after all processes have sent their trace data. |tracing_file| is
// the path at which tracing data was written. The client is responsible for
// deleting |tracing_file|.
//
pub on_end_tracing_complete: Option<extern "C" fn(
this: *mut cef_end_tracing_callback_t,
tracing_file: *const types::cef_string_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_end_tracing_callback_t = _cef_end_tracing_callback_t;
//
// Implement this structure to receive notification when tracing has completed.
// The functions of this structure will be called on the browser process UI
// thread.
//
pub struct CefEndTracingCallback {
c_object: *mut cef_end_tracing_callback_t,
}
impl Clone for CefEndTracingCallback {
fn clone(&self) -> CefEndTracingCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefEndTracingCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefEndTracingCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefEndTracingCallback {
pub unsafe fn from_c_object(c_object: *mut cef_end_tracing_callback_t) -> CefEndTracingCallback {
CefEndTracingCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_end_tracing_callback_t) -> CefEndTracingCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefEndTracingCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_end_tracing_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_end_tracing_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Called after all processes have sent their trace data. |tracing_file| is
// the path at which tracing data was written. The client is responsible for
// deleting |tracing_file|.
//
pub fn on_end_tracing_complete(&self, tracing_file: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_end_tracing_complete.unwrap())(
self.c_object,
CefWrap::to_c(tracing_file)))
}
}
}
impl CefWrap<*mut cef_end_tracing_callback_t> for CefEndTracingCallback {
fn to_c(rust_object: CefEndTracingCallback) -> *mut cef_end_tracing_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_end_tracing_callback_t) -> CefEndTracingCallback {
CefEndTracingCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_end_tracing_callback_t> for Option<CefEndTracingCallback> {
fn to_c(rust_object: Option<CefEndTracingCallback>) -> *mut cef_end_tracing_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_end_tracing_callback_t) -> Option<CefEndTracingCallback> {
if c_object.is_null() {
None
} else {
Some(CefEndTracingCallback::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,46 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;

Просмотреть файл

@ -0,0 +1,599 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure used to make a URL request. URL requests are not associated with a
// browser instance so no cef_client_t callbacks will be executed. URL requests
// can be created on any valid CEF thread in either the browser or render
// process. Once created the functions of the URL request object must be
// accessed on the same thread that created it.
//
#[repr(C)]
pub struct _cef_urlrequest_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Returns the request object used to create this URL request. The returned
// object is read-only and should not be modified.
//
pub get_request: Option<extern "C" fn(
this: *mut cef_urlrequest_t) -> *mut interfaces::cef_request_t>,
//
// Returns the client.
//
pub get_client: Option<extern "C" fn(
this: *mut cef_urlrequest_t) -> *mut interfaces::cef_urlrequest_client_t>,
//
// Returns the request status.
//
pub get_request_status: Option<extern "C" fn(
this: *mut cef_urlrequest_t) -> types::cef_urlrequest_status_t>,
//
// Returns the request error if status is UR_CANCELED or UR_FAILED, or 0
// otherwise.
//
pub get_request_error: Option<extern "C" fn(
this: *mut cef_urlrequest_t) -> types::cef_errorcode_t>,
//
// Returns the response, or NULL if no response information is available.
// Response information will only be available after the upload has completed.
// The returned object is read-only and should not be modified.
//
pub get_response: Option<extern "C" fn(
this: *mut cef_urlrequest_t) -> *mut interfaces::cef_response_t>,
//
// Cancel the request.
//
pub cancel: Option<extern "C" fn(this: *mut cef_urlrequest_t) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_urlrequest_t = _cef_urlrequest_t;
//
// Structure used to make a URL request. URL requests are not associated with a
// browser instance so no cef_client_t callbacks will be executed. URL requests
// can be created on any valid CEF thread in either the browser or render
// process. Once created the functions of the URL request object must be
// accessed on the same thread that created it.
//
pub struct CefURLRequest {
c_object: *mut cef_urlrequest_t,
}
impl Clone for CefURLRequest {
fn clone(&self) -> CefURLRequest{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefURLRequest {
c_object: self.c_object,
}
}
}
}
impl Drop for CefURLRequest {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefURLRequest {
pub unsafe fn from_c_object(c_object: *mut cef_urlrequest_t) -> CefURLRequest {
CefURLRequest {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_urlrequest_t) -> CefURLRequest {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefURLRequest {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_urlrequest_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_urlrequest_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Returns the request object used to create this URL request. The returned
// object is read-only and should not be modified.
//
pub fn get_request(&self) -> interfaces::CefRequest {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_request.unwrap())(
self.c_object))
}
}
//
// Returns the client.
//
pub fn get_client(&self) -> interfaces::CefURLRequestClient {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_client.unwrap())(
self.c_object))
}
}
//
// Returns the request status.
//
pub fn get_request_status(&self) -> types::cef_urlrequest_status_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_request_status.unwrap())(
self.c_object))
}
}
//
// Returns the request error if status is UR_CANCELED or UR_FAILED, or 0
// otherwise.
//
pub fn get_request_error(&self) -> types::cef_errorcode_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_request_error.unwrap())(
self.c_object))
}
}
//
// Returns the response, or NULL if no response information is available.
// Response information will only be available after the upload has completed.
// The returned object is read-only and should not be modified.
//
pub fn get_response(&self) -> interfaces::CefResponse {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_response.unwrap())(
self.c_object))
}
}
//
// Cancel the request.
//
pub fn cancel(&self) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).cancel.unwrap())(
self.c_object))
}
}
//
// Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request
// functions are supported. Multiple post data elements are not supported and
// elements of type PDE_TYPE_FILE are only supported for requests originating
// from the browser process. Requests originating from the render process will
// receive the same handling as requests originating from Web content -- if
// the response contains Content-Disposition or Mime-Type header values that
// would not normally be rendered then the response may receive special
// handling inside the browser (for example, via the file download code path
// instead of the URL request code path). The |request| object will be marked
// as read-only after calling this function.
//
pub fn create(request: interfaces::CefRequest,
client: interfaces::CefURLRequestClient) -> interfaces::CefURLRequest {
unsafe {
CefWrap::to_rust(
::urlrequest::cef_urlrequest_create(
CefWrap::to_c(request),
CefWrap::to_c(client)))
}
}
}
impl CefWrap<*mut cef_urlrequest_t> for CefURLRequest {
fn to_c(rust_object: CefURLRequest) -> *mut cef_urlrequest_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_urlrequest_t) -> CefURLRequest {
CefURLRequest::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_urlrequest_t> for Option<CefURLRequest> {
fn to_c(rust_object: Option<CefURLRequest>) -> *mut cef_urlrequest_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_urlrequest_t) -> Option<CefURLRequest> {
if c_object.is_null() {
None
} else {
Some(CefURLRequest::from_c_object_addref(c_object))
}
}
}
//
// Structure that should be implemented by the cef_urlrequest_t client. The
// functions of this structure will be called on the same thread that created
// the request unless otherwise documented.
//
#[repr(C)]
pub struct _cef_urlrequest_client_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Notifies the client that the request has completed. Use the
// cef_urlrequest_t::GetRequestStatus function to determine if the request was
// successful or not.
//
pub on_request_complete: Option<extern "C" fn(
this: *mut cef_urlrequest_client_t,
request: *mut interfaces::cef_urlrequest_t) -> ()>,
//
// Notifies the client of upload progress. |current| denotes the number of
// bytes sent so far and |total| is the total size of uploading data (or -1 if
// chunked upload is enabled). This function will only be called if the
// UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request.
//
pub on_upload_progress: Option<extern "C" fn(
this: *mut cef_urlrequest_client_t,
request: *mut interfaces::cef_urlrequest_t, current: u64,
total: u64) -> ()>,
//
// Notifies the client of download progress. |current| denotes the number of
// bytes received up to the call and |total| is the expected total size of the
// response (or -1 if not determined).
//
pub on_download_progress: Option<extern "C" fn(
this: *mut cef_urlrequest_client_t,
request: *mut interfaces::cef_urlrequest_t, current: u64,
total: u64) -> ()>,
//
// Called when some part of the response is read. |data| contains the current
// bytes received since the last call. This function will not be called if the
// UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request.
//
pub on_download_data: Option<extern "C" fn(this: *mut cef_urlrequest_client_t,
request: *mut interfaces::cef_urlrequest_t, data: *const (),
data_length: libc::size_t) -> ()>,
//
// Called on the IO thread when the browser needs credentials from the user.
// |isProxy| indicates whether the host is a proxy server. |host| contains the
// hostname and |port| contains the port number. Return true (1) to continue
// the request and call cef_auth_callback_t::cont() when the authentication
// information is available. Return false (0) to cancel the request. This
// function will only be called for requests initiated from the browser
// process.
//
pub get_auth_credentials: Option<extern "C" fn(
this: *mut cef_urlrequest_client_t, isProxy: libc::c_int,
host: *const types::cef_string_t, port: libc::c_int,
realm: *const types::cef_string_t, scheme: *const types::cef_string_t,
callback: *mut interfaces::cef_auth_callback_t) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_urlrequest_client_t = _cef_urlrequest_client_t;
//
// Structure that should be implemented by the cef_urlrequest_t client. The
// functions of this structure will be called on the same thread that created
// the request unless otherwise documented.
//
pub struct CefURLRequestClient {
c_object: *mut cef_urlrequest_client_t,
}
impl Clone for CefURLRequestClient {
fn clone(&self) -> CefURLRequestClient{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefURLRequestClient {
c_object: self.c_object,
}
}
}
}
impl Drop for CefURLRequestClient {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefURLRequestClient {
pub unsafe fn from_c_object(c_object: *mut cef_urlrequest_client_t) -> CefURLRequestClient {
CefURLRequestClient {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_urlrequest_client_t) -> CefURLRequestClient {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefURLRequestClient {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_urlrequest_client_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_urlrequest_client_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Notifies the client that the request has completed. Use the
// cef_urlrequest_t::GetRequestStatus function to determine if the request was
// successful or not.
//
pub fn on_request_complete(&self, request: interfaces::CefURLRequest) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_request_complete.unwrap())(
self.c_object,
CefWrap::to_c(request)))
}
}
//
// Notifies the client of upload progress. |current| denotes the number of
// bytes sent so far and |total| is the total size of uploading data (or -1 if
// chunked upload is enabled). This function will only be called if the
// UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request.
//
pub fn on_upload_progress(&self, request: interfaces::CefURLRequest,
current: u64, total: u64) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_upload_progress.unwrap())(
self.c_object,
CefWrap::to_c(request),
CefWrap::to_c(current),
CefWrap::to_c(total)))
}
}
//
// Notifies the client of download progress. |current| denotes the number of
// bytes received up to the call and |total| is the expected total size of the
// response (or -1 if not determined).
//
pub fn on_download_progress(&self, request: interfaces::CefURLRequest,
current: u64, total: u64) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_download_progress.unwrap())(
self.c_object,
CefWrap::to_c(request),
CefWrap::to_c(current),
CefWrap::to_c(total)))
}
}
//
// Called when some part of the response is read. |data| contains the current
// bytes received since the last call. This function will not be called if the
// UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request.
//
pub fn on_download_data(&self, request: interfaces::CefURLRequest, data: &(),
data_length: libc::size_t) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).on_download_data.unwrap())(
self.c_object,
CefWrap::to_c(request),
CefWrap::to_c(data),
CefWrap::to_c(data_length)))
}
}
//
// Called on the IO thread when the browser needs credentials from the user.
// |isProxy| indicates whether the host is a proxy server. |host| contains the
// hostname and |port| contains the port number. Return true (1) to continue
// the request and call cef_auth_callback_t::cont() when the authentication
// information is available. Return false (0) to cancel the request. This
// function will only be called for requests initiated from the browser
// process.
//
pub fn get_auth_credentials(&self, isProxy: libc::c_int, host: &[u16],
port: libc::c_int, realm: &[u16], scheme: &[u16],
callback: interfaces::CefAuthCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_auth_credentials.unwrap())(
self.c_object,
CefWrap::to_c(isProxy),
CefWrap::to_c(host),
CefWrap::to_c(port),
CefWrap::to_c(realm),
CefWrap::to_c(scheme),
CefWrap::to_c(callback)))
}
}
}
impl CefWrap<*mut cef_urlrequest_client_t> for CefURLRequestClient {
fn to_c(rust_object: CefURLRequestClient) -> *mut cef_urlrequest_client_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_urlrequest_client_t) -> CefURLRequestClient {
CefURLRequestClient::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_urlrequest_client_t> for Option<CefURLRequestClient> {
fn to_c(rust_object: Option<CefURLRequestClient>) -> *mut cef_urlrequest_client_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_urlrequest_client_t) -> Option<CefURLRequestClient> {
if c_object.is_null() {
None
} else {
Some(CefURLRequestClient::from_c_object_addref(c_object))
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,544 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Information about a specific web plugin.
//
#[repr(C)]
pub struct _cef_web_plugin_info_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Returns the plugin name (i.e. Flash).
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_name: Option<extern "C" fn(
this: *mut cef_web_plugin_info_t) -> types::cef_string_userfree_t>,
//
// Returns the plugin file path (DLL/bundle/library).
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_path: Option<extern "C" fn(
this: *mut cef_web_plugin_info_t) -> types::cef_string_userfree_t>,
//
// Returns the version of the plugin (may be OS-specific).
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_version: Option<extern "C" fn(
this: *mut cef_web_plugin_info_t) -> types::cef_string_userfree_t>,
//
// Returns a description of the plugin from the version information.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_description: Option<extern "C" fn(
this: *mut cef_web_plugin_info_t) -> types::cef_string_userfree_t>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_web_plugin_info_t = _cef_web_plugin_info_t;
//
// Information about a specific web plugin.
//
pub struct CefWebPluginInfo {
c_object: *mut cef_web_plugin_info_t,
}
impl Clone for CefWebPluginInfo {
fn clone(&self) -> CefWebPluginInfo{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefWebPluginInfo {
c_object: self.c_object,
}
}
}
}
impl Drop for CefWebPluginInfo {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefWebPluginInfo {
pub unsafe fn from_c_object(c_object: *mut cef_web_plugin_info_t) -> CefWebPluginInfo {
CefWebPluginInfo {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_web_plugin_info_t) -> CefWebPluginInfo {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefWebPluginInfo {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_web_plugin_info_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_web_plugin_info_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Returns the plugin name (i.e. Flash).
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_name(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_name.unwrap())(
self.c_object))
}
}
//
// Returns the plugin file path (DLL/bundle/library).
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_path(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_path.unwrap())(
self.c_object))
}
}
//
// Returns the version of the plugin (may be OS-specific).
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_version(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_version.unwrap())(
self.c_object))
}
}
//
// Returns a description of the plugin from the version information.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_description(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_description.unwrap())(
self.c_object))
}
}
}
impl CefWrap<*mut cef_web_plugin_info_t> for CefWebPluginInfo {
fn to_c(rust_object: CefWebPluginInfo) -> *mut cef_web_plugin_info_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_web_plugin_info_t) -> CefWebPluginInfo {
CefWebPluginInfo::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_web_plugin_info_t> for Option<CefWebPluginInfo> {
fn to_c(rust_object: Option<CefWebPluginInfo>) -> *mut cef_web_plugin_info_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_web_plugin_info_t) -> Option<CefWebPluginInfo> {
if c_object.is_null() {
None
} else {
Some(CefWebPluginInfo::from_c_object_addref(c_object))
}
}
}
//
// Structure to implement for visiting web plugin information. The functions of
// this structure will be called on the browser process UI thread.
//
#[repr(C)]
pub struct _cef_web_plugin_info_visitor_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Method that will be called once for each plugin. |count| is the 0-based
// index for the current plugin. |total| is the total number of plugins.
// Return false (0) to stop visiting plugins. This function may never be
// called if no plugins are found.
//
pub visit: Option<extern "C" fn(this: *mut cef_web_plugin_info_visitor_t,
info: *mut interfaces::cef_web_plugin_info_t, count: libc::c_int,
total: libc::c_int) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_web_plugin_info_visitor_t = _cef_web_plugin_info_visitor_t;
//
// Structure to implement for visiting web plugin information. The functions of
// this structure will be called on the browser process UI thread.
//
pub struct CefWebPluginInfoVisitor {
c_object: *mut cef_web_plugin_info_visitor_t,
}
impl Clone for CefWebPluginInfoVisitor {
fn clone(&self) -> CefWebPluginInfoVisitor{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefWebPluginInfoVisitor {
c_object: self.c_object,
}
}
}
}
impl Drop for CefWebPluginInfoVisitor {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefWebPluginInfoVisitor {
pub unsafe fn from_c_object(c_object: *mut cef_web_plugin_info_visitor_t) -> CefWebPluginInfoVisitor {
CefWebPluginInfoVisitor {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_web_plugin_info_visitor_t) -> CefWebPluginInfoVisitor {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefWebPluginInfoVisitor {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_web_plugin_info_visitor_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_web_plugin_info_visitor_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Method that will be called once for each plugin. |count| is the 0-based
// index for the current plugin. |total| is the total number of plugins.
// Return false (0) to stop visiting plugins. This function may never be
// called if no plugins are found.
//
pub fn visit(&self, info: interfaces::CefWebPluginInfo, count: libc::c_int,
total: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).visit.unwrap())(
self.c_object,
CefWrap::to_c(info),
CefWrap::to_c(count),
CefWrap::to_c(total)))
}
}
}
impl CefWrap<*mut cef_web_plugin_info_visitor_t> for CefWebPluginInfoVisitor {
fn to_c(rust_object: CefWebPluginInfoVisitor) -> *mut cef_web_plugin_info_visitor_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_web_plugin_info_visitor_t) -> CefWebPluginInfoVisitor {
CefWebPluginInfoVisitor::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_web_plugin_info_visitor_t> for Option<CefWebPluginInfoVisitor> {
fn to_c(rust_object: Option<CefWebPluginInfoVisitor>) -> *mut cef_web_plugin_info_visitor_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_web_plugin_info_visitor_t) -> Option<CefWebPluginInfoVisitor> {
if c_object.is_null() {
None
} else {
Some(CefWebPluginInfoVisitor::from_c_object_addref(c_object))
}
}
}
//
// Structure to implement for receiving unstable plugin information. The
// functions of this structure will be called on the browser process IO thread.
//
#[repr(C)]
pub struct _cef_web_plugin_unstable_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Method that will be called for the requested plugin. |unstable| will be
// true (1) if the plugin has reached the crash count threshold of 3 times in
// 120 seconds.
//
pub is_unstable: Option<extern "C" fn(
this: *mut cef_web_plugin_unstable_callback_t,
path: *const types::cef_string_t, unstable: libc::c_int) -> ()>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_web_plugin_unstable_callback_t = _cef_web_plugin_unstable_callback_t;
//
// Structure to implement for receiving unstable plugin information. The
// functions of this structure will be called on the browser process IO thread.
//
pub struct CefWebPluginUnstableCallback {
c_object: *mut cef_web_plugin_unstable_callback_t,
}
impl Clone for CefWebPluginUnstableCallback {
fn clone(&self) -> CefWebPluginUnstableCallback{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefWebPluginUnstableCallback {
c_object: self.c_object,
}
}
}
}
impl Drop for CefWebPluginUnstableCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefWebPluginUnstableCallback {
pub unsafe fn from_c_object(c_object: *mut cef_web_plugin_unstable_callback_t) -> CefWebPluginUnstableCallback {
CefWebPluginUnstableCallback {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_web_plugin_unstable_callback_t) -> CefWebPluginUnstableCallback {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefWebPluginUnstableCallback {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_web_plugin_unstable_callback_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_web_plugin_unstable_callback_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Method that will be called for the requested plugin. |unstable| will be
// true (1) if the plugin has reached the crash count threshold of 3 times in
// 120 seconds.
//
pub fn is_unstable(&self, path: &[u16], unstable: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_unstable.unwrap())(
self.c_object,
CefWrap::to_c(path),
CefWrap::to_c(unstable)))
}
}
}
impl CefWrap<*mut cef_web_plugin_unstable_callback_t> for CefWebPluginUnstableCallback {
fn to_c(rust_object: CefWebPluginUnstableCallback) -> *mut cef_web_plugin_unstable_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_web_plugin_unstable_callback_t) -> CefWebPluginUnstableCallback {
CefWebPluginUnstableCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_web_plugin_unstable_callback_t> for Option<CefWebPluginUnstableCallback> {
fn to_c(rust_object: Option<CefWebPluginUnstableCallback>) -> *mut cef_web_plugin_unstable_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_web_plugin_unstable_callback_t) -> Option<CefWebPluginUnstableCallback> {
if c_object.is_null() {
None
} else {
Some(CefWebPluginUnstableCallback::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,857 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure that supports the reading of XML data via the libxml streaming API.
// The functions of this structure should only be called on the thread that
// creates the object.
//
#[repr(C)]
pub struct _cef_xml_reader_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Moves the cursor to the next node in the document. This function must be
// called at least once to set the current cursor position. Returns true (1)
// if the cursor position was set successfully.
//
pub move_to_next_node: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> libc::c_int>,
//
// Close the document. This should be called directly to ensure that cleanup
// occurs on the correct thread.
//
pub close: Option<extern "C" fn(this: *mut cef_xml_reader_t) -> libc::c_int>,
//
// Returns true (1) if an error has been reported by the XML parser.
//
pub has_error: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> libc::c_int>,
//
// Returns the error string.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_error: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>,
// The below functions retrieve data for the node at the current cursor
// position.
//
// Returns the node type.
//
pub get_type: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> types::cef_xml_node_type_t>,
//
// Returns the node depth. Depth starts at 0 for the root node.
//
pub get_depth: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> libc::c_int>,
//
// Returns the local name. See http://www.w3.org/TR/REC-xml-names/#NT-
// LocalPart for additional details.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_local_name: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>,
//
// Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for
// additional details.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_prefix: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>,
//
// Returns the qualified name, equal to (Prefix:)LocalName. See
// http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_qualified_name: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>,
//
// Returns the URI defining the namespace associated with the node. See
// http://www.w3.org/TR/REC-xml-names/ for additional details.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_namespace_uri: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>,
//
// Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for
// additional details.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_base_uri: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>,
//
// Returns the xml:lang scope within which the node resides. See
// http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_xml_lang: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>,
//
// Returns true (1) if the node represents an NULL element. <a/> is considered
// NULL but <a></a> is not.
//
pub is_empty_element: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> libc::c_int>,
//
// Returns true (1) if the node has a text value.
//
pub has_value: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> libc::c_int>,
//
// Returns the text value.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_value: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>,
//
// Returns true (1) if the node has attributes.
//
pub has_attributes: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> libc::c_int>,
//
// Returns the number of attributes.
//
pub get_attribute_count: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> libc::size_t>,
//
// Returns the value of the attribute at the specified 0-based index.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_attribute_byindex: Option<extern "C" fn(this: *mut cef_xml_reader_t,
index: libc::c_int) -> types::cef_string_userfree_t>,
//
// Returns the value of the attribute with the specified qualified name.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_attribute_byqname: Option<extern "C" fn(this: *mut cef_xml_reader_t,
qualifiedName: *const types::cef_string_t) -> types::cef_string_userfree_t>,
//
// Returns the value of the attribute with the specified local name and
// namespace URI.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_attribute_bylname: Option<extern "C" fn(this: *mut cef_xml_reader_t,
localName: *const types::cef_string_t,
namespaceURI: *const types::cef_string_t) -> types::cef_string_userfree_t>,
//
// Returns an XML representation of the current node's children.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_inner_xml: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>,
//
// Returns an XML representation of the current node including its children.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_outer_xml: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>,
//
// Returns the line number for the current node.
//
pub get_line_number: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> libc::c_int>,
// Attribute nodes are not traversed by default. The below functions can be
// used to move the cursor to an attribute node. move_to_carrying_element()
// can be called afterwards to return the cursor to the carrying element. The
// depth of an attribute node will be 1 + the depth of the carrying element.
//
// Moves the cursor to the attribute at the specified 0-based index. Returns
// true (1) if the cursor position was set successfully.
//
pub move_to_attribute_byindex: Option<extern "C" fn(
this: *mut cef_xml_reader_t, index: libc::c_int) -> libc::c_int>,
//
// Moves the cursor to the attribute with the specified qualified name.
// Returns true (1) if the cursor position was set successfully.
//
pub move_to_attribute_byqname: Option<extern "C" fn(
this: *mut cef_xml_reader_t,
qualifiedName: *const types::cef_string_t) -> libc::c_int>,
//
// Moves the cursor to the attribute with the specified local name and
// namespace URI. Returns true (1) if the cursor position was set
// successfully.
//
pub move_to_attribute_bylname: Option<extern "C" fn(
this: *mut cef_xml_reader_t, localName: *const types::cef_string_t,
namespaceURI: *const types::cef_string_t) -> libc::c_int>,
//
// Moves the cursor to the first attribute in the current element. Returns
// true (1) if the cursor position was set successfully.
//
pub move_to_first_attribute: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> libc::c_int>,
//
// Moves the cursor to the next attribute in the current element. Returns true
// (1) if the cursor position was set successfully.
//
pub move_to_next_attribute: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> libc::c_int>,
//
// Moves the cursor back to the carrying element. Returns true (1) if the
// cursor position was set successfully.
//
pub move_to_carrying_element: Option<extern "C" fn(
this: *mut cef_xml_reader_t) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_xml_reader_t = _cef_xml_reader_t;
//
// Structure that supports the reading of XML data via the libxml streaming API.
// The functions of this structure should only be called on the thread that
// creates the object.
//
pub struct CefXmlReader {
c_object: *mut cef_xml_reader_t,
}
impl Clone for CefXmlReader {
fn clone(&self) -> CefXmlReader{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefXmlReader {
c_object: self.c_object,
}
}
}
}
impl Drop for CefXmlReader {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefXmlReader {
pub unsafe fn from_c_object(c_object: *mut cef_xml_reader_t) -> CefXmlReader {
CefXmlReader {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_xml_reader_t) -> CefXmlReader {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefXmlReader {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_xml_reader_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_xml_reader_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Moves the cursor to the next node in the document. This function must be
// called at least once to set the current cursor position. Returns true (1)
// if the cursor position was set successfully.
//
pub fn move_to_next_node(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).move_to_next_node.unwrap())(
self.c_object))
}
}
//
// Close the document. This should be called directly to ensure that cleanup
// occurs on the correct thread.
//
pub fn close(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).close.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if an error has been reported by the XML parser.
//
pub fn has_error(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).has_error.unwrap())(
self.c_object))
}
}
//
// Returns the error string.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_error(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_error.unwrap())(
self.c_object))
}
}
// The below functions retrieve data for the node at the current cursor
// position.
//
// Returns the node type.
//
pub fn get_type(&self) -> types::cef_xml_node_type_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_type.unwrap())(
self.c_object))
}
}
//
// Returns the node depth. Depth starts at 0 for the root node.
//
pub fn get_depth(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_depth.unwrap())(
self.c_object))
}
}
//
// Returns the local name. See http://www.w3.org/TR/REC-xml-names/#NT-
// LocalPart for additional details.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_local_name(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_local_name.unwrap())(
self.c_object))
}
}
//
// Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for
// additional details.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_prefix(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_prefix.unwrap())(
self.c_object))
}
}
//
// Returns the qualified name, equal to (Prefix:)LocalName. See
// http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_qualified_name(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_qualified_name.unwrap())(
self.c_object))
}
}
//
// Returns the URI defining the namespace associated with the node. See
// http://www.w3.org/TR/REC-xml-names/ for additional details.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_namespace_uri(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_namespace_uri.unwrap())(
self.c_object))
}
}
//
// Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for
// additional details.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_base_uri(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_base_uri.unwrap())(
self.c_object))
}
}
//
// Returns the xml:lang scope within which the node resides. See
// http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_xml_lang(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_xml_lang.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the node represents an NULL element. <a/> is considered
// NULL but <a></a> is not.
//
pub fn is_empty_element(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).is_empty_element.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the node has a text value.
//
pub fn has_value(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).has_value.unwrap())(
self.c_object))
}
}
//
// Returns the text value.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_value(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_value.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if the node has attributes.
//
pub fn has_attributes(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).has_attributes.unwrap())(
self.c_object))
}
}
//
// Returns the number of attributes.
//
pub fn get_attribute_count(&self) -> libc::size_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_attribute_count.unwrap())(
self.c_object))
}
}
//
// Returns the value of the attribute at the specified 0-based index.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_attribute_byindex(&self, index: libc::c_int) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_attribute_byindex.unwrap())(
self.c_object,
CefWrap::to_c(index)))
}
}
//
// Returns the value of the attribute with the specified qualified name.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_attribute_byqname(&self, qualifiedName: &[u16]) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_attribute_byqname.unwrap())(
self.c_object,
CefWrap::to_c(qualifiedName)))
}
}
//
// Returns the value of the attribute with the specified local name and
// namespace URI.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_attribute_bylname(&self, localName: &[u16],
namespaceURI: &[u16]) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_attribute_bylname.unwrap())(
self.c_object,
CefWrap::to_c(localName),
CefWrap::to_c(namespaceURI)))
}
}
//
// Returns an XML representation of the current node's children.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_inner_xml(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_inner_xml.unwrap())(
self.c_object))
}
}
//
// Returns an XML representation of the current node including its children.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_outer_xml(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_outer_xml.unwrap())(
self.c_object))
}
}
//
// Returns the line number for the current node.
//
pub fn get_line_number(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_line_number.unwrap())(
self.c_object))
}
}
// Attribute nodes are not traversed by default. The below functions can be
// used to move the cursor to an attribute node. move_to_carrying_element()
// can be called afterwards to return the cursor to the carrying element. The
// depth of an attribute node will be 1 + the depth of the carrying element.
//
// Moves the cursor to the attribute at the specified 0-based index. Returns
// true (1) if the cursor position was set successfully.
//
pub fn move_to_attribute_byindex(&self, index: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).move_to_attribute_byindex.unwrap())(
self.c_object,
CefWrap::to_c(index)))
}
}
//
// Moves the cursor to the attribute with the specified qualified name.
// Returns true (1) if the cursor position was set successfully.
//
pub fn move_to_attribute_byqname(&self,
qualifiedName: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).move_to_attribute_byqname.unwrap())(
self.c_object,
CefWrap::to_c(qualifiedName)))
}
}
//
// Moves the cursor to the attribute with the specified local name and
// namespace URI. Returns true (1) if the cursor position was set
// successfully.
//
pub fn move_to_attribute_bylname(&self, localName: &[u16],
namespaceURI: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).move_to_attribute_bylname.unwrap())(
self.c_object,
CefWrap::to_c(localName),
CefWrap::to_c(namespaceURI)))
}
}
//
// Moves the cursor to the first attribute in the current element. Returns
// true (1) if the cursor position was set successfully.
//
pub fn move_to_first_attribute(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).move_to_first_attribute.unwrap())(
self.c_object))
}
}
//
// Moves the cursor to the next attribute in the current element. Returns true
// (1) if the cursor position was set successfully.
//
pub fn move_to_next_attribute(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).move_to_next_attribute.unwrap())(
self.c_object))
}
}
//
// Moves the cursor back to the carrying element. Returns true (1) if the
// cursor position was set successfully.
//
pub fn move_to_carrying_element(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).move_to_carrying_element.unwrap())(
self.c_object))
}
}
//
// Create a new cef_xml_reader_t object. The returned object's functions can
// only be called from the thread that created the object.
//
pub fn create(stream: interfaces::CefStreamReader,
encodingType: types::cef_xml_encoding_type_t,
URI: &[u16]) -> interfaces::CefXmlReader {
unsafe {
CefWrap::to_rust(
::xml_reader::cef_xml_reader_create(
CefWrap::to_c(stream),
CefWrap::to_c(encodingType),
CefWrap::to_c(URI)))
}
}
}
impl CefWrap<*mut cef_xml_reader_t> for CefXmlReader {
fn to_c(rust_object: CefXmlReader) -> *mut cef_xml_reader_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_xml_reader_t) -> CefXmlReader {
CefXmlReader::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_xml_reader_t> for Option<CefXmlReader> {
fn to_c(rust_object: Option<CefXmlReader>) -> *mut cef_xml_reader_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_xml_reader_t) -> Option<CefXmlReader> {
if c_object.is_null() {
None
} else {
Some(CefXmlReader::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,445 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not be edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#![allow(non_snake_case, unused_imports)]
use eutil;
use interfaces;
use types;
use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::ptr;
//
// Structure that supports the reading of zip archives via the zlib unzip API.
// The functions of this structure should only be called on the thread that
// creates the object.
//
#[repr(C)]
pub struct _cef_zip_reader_t {
//
// Base structure.
//
pub base: types::cef_base_t,
//
// Moves the cursor to the first file in the archive. Returns true (1) if the
// cursor position was set successfully.
//
pub move_to_first_file: Option<extern "C" fn(
this: *mut cef_zip_reader_t) -> libc::c_int>,
//
// Moves the cursor to the next file in the archive. Returns true (1) if the
// cursor position was set successfully.
//
pub move_to_next_file: Option<extern "C" fn(
this: *mut cef_zip_reader_t) -> libc::c_int>,
//
// Moves the cursor to the specified file in the archive. If |caseSensitive|
// is true (1) then the search will be case sensitive. Returns true (1) if the
// cursor position was set successfully.
//
pub move_to_file: Option<extern "C" fn(this: *mut cef_zip_reader_t,
fileName: *const types::cef_string_t,
caseSensitive: libc::c_int) -> libc::c_int>,
//
// Closes the archive. This should be called directly to ensure that cleanup
// occurs on the correct thread.
//
pub close: Option<extern "C" fn(this: *mut cef_zip_reader_t) -> libc::c_int>,
// The below functions act on the file at the current cursor position.
//
// Returns the name of the file.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub get_file_name: Option<extern "C" fn(
this: *mut cef_zip_reader_t) -> types::cef_string_userfree_t>,
//
// Returns the uncompressed size of the file.
//
pub get_file_size: Option<extern "C" fn(this: *mut cef_zip_reader_t) -> i64>,
//
// Returns the last modified timestamp for the file.
//
pub get_file_last_modified: Option<extern "C" fn(
this: *mut cef_zip_reader_t) -> libc::time_t>,
//
// Opens the file for reading of uncompressed data. A read password may
// optionally be specified.
//
pub open_file: Option<extern "C" fn(this: *mut cef_zip_reader_t,
password: *const types::cef_string_t) -> libc::c_int>,
//
// Closes the file.
//
pub close_file: Option<extern "C" fn(
this: *mut cef_zip_reader_t) -> libc::c_int>,
//
// Read uncompressed file contents into the specified buffer. Returns < 0 if
// an error occurred, 0 if at the end of file, or the number of bytes read.
//
pub read_file: Option<extern "C" fn(this: *mut cef_zip_reader_t,
buffer: *mut (), bufferSize: libc::size_t) -> libc::c_int>,
//
// Returns the current offset in the uncompressed file contents.
//
pub tell: Option<extern "C" fn(this: *mut cef_zip_reader_t) -> i64>,
//
// Returns true (1) if at end of the file contents.
//
pub eof: Option<extern "C" fn(this: *mut cef_zip_reader_t) -> libc::c_int>,
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: uint,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
pub type cef_zip_reader_t = _cef_zip_reader_t;
//
// Structure that supports the reading of zip archives via the zlib unzip API.
// The functions of this structure should only be called on the thread that
// creates the object.
//
pub struct CefZipReader {
c_object: *mut cef_zip_reader_t,
}
impl Clone for CefZipReader {
fn clone(&self) -> CefZipReader{
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefZipReader {
c_object: self.c_object,
}
}
}
}
impl Drop for CefZipReader {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}
impl CefZipReader {
pub unsafe fn from_c_object(c_object: *mut cef_zip_reader_t) -> CefZipReader {
CefZipReader {
c_object: c_object,
}
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_zip_reader_t) -> CefZipReader {
if !c_object.is_null() {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefZipReader {
c_object: c_object,
}
}
pub fn c_object(&self) -> *mut cef_zip_reader_t {
self.c_object
}
pub fn c_object_addrefed(&self) -> *mut cef_zip_reader_t {
unsafe {
if !self.c_object.is_null() {
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()
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
}
//
// Moves the cursor to the first file in the archive. Returns true (1) if the
// cursor position was set successfully.
//
pub fn move_to_first_file(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).move_to_first_file.unwrap())(
self.c_object))
}
}
//
// Moves the cursor to the next file in the archive. Returns true (1) if the
// cursor position was set successfully.
//
pub fn move_to_next_file(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).move_to_next_file.unwrap())(
self.c_object))
}
}
//
// Moves the cursor to the specified file in the archive. If |caseSensitive|
// is true (1) then the search will be case sensitive. Returns true (1) if the
// cursor position was set successfully.
//
pub fn move_to_file(&self, fileName: &[u16],
caseSensitive: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).move_to_file.unwrap())(
self.c_object,
CefWrap::to_c(fileName),
CefWrap::to_c(caseSensitive)))
}
}
//
// Closes the archive. This should be called directly to ensure that cleanup
// occurs on the correct thread.
//
pub fn close(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).close.unwrap())(
self.c_object))
}
}
// The below functions act on the file at the current cursor position.
//
// Returns the name of the file.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_file_name(&self) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_file_name.unwrap())(
self.c_object))
}
}
//
// Returns the uncompressed size of the file.
//
pub fn get_file_size(&self) -> i64 {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_file_size.unwrap())(
self.c_object))
}
}
//
// Returns the last modified timestamp for the file.
//
pub fn get_file_last_modified(&self) -> libc::time_t {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).get_file_last_modified.unwrap())(
self.c_object))
}
}
//
// Opens the file for reading of uncompressed data. A read password may
// optionally be specified.
//
pub fn open_file(&self, password: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).open_file.unwrap())(
self.c_object,
CefWrap::to_c(password)))
}
}
//
// Closes the file.
//
pub fn close_file(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).close_file.unwrap())(
self.c_object))
}
}
//
// Read uncompressed file contents into the specified buffer. Returns < 0 if
// an error occurred, 0 if at the end of file, or the number of bytes read.
//
pub fn read_file(&self, buffer: &mut (),
bufferSize: libc::size_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).read_file.unwrap())(
self.c_object,
CefWrap::to_c(buffer),
CefWrap::to_c(bufferSize)))
}
}
//
// Returns the current offset in the uncompressed file contents.
//
pub fn tell(&self) -> i64 {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).tell.unwrap())(
self.c_object))
}
}
//
// Returns true (1) if at end of the file contents.
//
pub fn eof(&self) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
unsafe {
CefWrap::to_rust(
((*self.c_object).eof.unwrap())(
self.c_object))
}
}
//
// Create a new cef_zip_reader_t object. The returned object's functions can
// only be called from the thread that created the object.
//
pub fn create(
stream: interfaces::CefStreamReader) -> interfaces::CefZipReader {
unsafe {
CefWrap::to_rust(
::zip_reader::cef_zip_reader_create(
CefWrap::to_c(stream)))
}
}
}
impl CefWrap<*mut cef_zip_reader_t> for CefZipReader {
fn to_c(rust_object: CefZipReader) -> *mut cef_zip_reader_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_zip_reader_t) -> CefZipReader {
CefZipReader::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_zip_reader_t> for Option<CefZipReader> {
fn to_c(rust_object: Option<CefZipReader>) -> *mut cef_zip_reader_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_zip_reader_t) -> Option<CefZipReader> {
if c_object.is_null() {
None
} else {
Some(CefZipReader::from_c_object_addref(c_object))
}
}
}

Просмотреть файл

@ -0,0 +1,148 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This file is currently *not* autogenerated, but maybe it should be. (It's a little complicated
//! because we need to reexport a bunch of types in `types.rs`.)
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::{CefBrowser, CefBrowserHost, CefRunFileDialogCallback};
pub use interfaces::cef_browser::{cef_browser_host_t, cef_browser_t};
pub use interfaces::cef_browser::{cef_run_file_dialog_callback_t};
pub use interfaces::cef_browser_process_handler::{CefBrowserProcessHandler};
pub use interfaces::cef_browser_process_handler::{cef_browser_process_handler_t};
pub use interfaces::cef_callback::{CefCallback, CefCompletionCallback, cef_callback_t};
pub use interfaces::cef_callback::{cef_completion_callback_t};
pub use interfaces::cef_client::{CefClient, cef_client_t};
pub use interfaces::cef_command_line::{CefCommandLine, cef_command_line_t};
pub use interfaces::cef_context_menu_handler::{CefContextMenuHandler, CefContextMenuParams};
pub use interfaces::cef_context_menu_handler::{cef_context_menu_handler_t};
pub use interfaces::cef_context_menu_handler::{cef_context_menu_params_t};
pub use interfaces::cef_cookie::{CefCookieManager, CefCookieVisitor, cef_cookie_manager_t};
pub use interfaces::cef_cookie::{cef_cookie_visitor_t};
pub use interfaces::cef_dialog_handler::{CefDialogHandler, CefFileDialogCallback};
pub use interfaces::cef_dialog_handler::{cef_dialog_handler_t, cef_file_dialog_callback_t};
pub use interfaces::cef_display_handler::{CefDisplayHandler, cef_display_handler_t};
pub use interfaces::cef_dom::{CefDOMDocument, CefDOMNode, CefDOMVisitor, cef_domdocument_t};
pub use interfaces::cef_dom::{cef_domnode_t, cef_domvisitor_t};
pub use interfaces::cef_download_handler::{CefBeforeDownloadCallback, CefDownloadHandler};
pub use interfaces::cef_download_handler::{CefDownloadItemCallback};
pub use interfaces::cef_download_handler::{cef_before_download_callback_t};
pub use interfaces::cef_download_handler::{cef_download_handler_t, cef_download_item_callback_t};
pub use interfaces::cef_download_item::{CefDownloadItem, cef_download_item_t};
pub use interfaces::cef_drag_data::{CefDragData, cef_drag_data_t};
pub use interfaces::cef_drag_handler::{CefDragHandler, cef_drag_handler_t};
pub use interfaces::cef_focus_handler::{CefFocusHandler, cef_focus_handler_t};
pub use interfaces::cef_frame::{CefFrame, cef_frame_t};
pub use interfaces::cef_geolocation::{CefGetGeolocationCallback, cef_get_geolocation_callback_t};
pub use interfaces::cef_geolocation_handler::{CefGeolocationCallback, CefGeolocationHandler};
pub use interfaces::cef_geolocation_handler::{cef_geolocation_callback_t};
pub use interfaces::cef_geolocation_handler::{cef_geolocation_handler_t};
pub use interfaces::cef_jsdialog_handler::{CefJSDialogCallback, CefJSDialogHandler};
pub use interfaces::cef_jsdialog_handler::{cef_jsdialog_callback_t, cef_jsdialog_handler_t};
pub use interfaces::cef_keyboard_handler::{CefKeyboardHandler, cef_keyboard_handler_t};
pub use interfaces::cef_life_span_handler::{CefLifeSpanHandler, cef_life_span_handler_t};
pub use interfaces::cef_load_handler::{CefLoadHandler, cef_load_handler_t};
pub use interfaces::cef_menu_model::{CefMenuModel, cef_menu_model_t};
pub use interfaces::cef_print_handler::{CefPrintDialogCallback, CefPrintHandler};
pub use interfaces::cef_print_handler::{CefPrintJobCallback, cef_print_dialog_callback_t};
pub use interfaces::cef_print_handler::{cef_print_handler_t, cef_print_job_callback_t};
pub use interfaces::cef_print_settings::{CefPrintSettings, cef_print_settings_t};
pub use interfaces::cef_process_message::{CefProcessMessage, cef_process_message_t};
pub use interfaces::cef_render_handler::{CefRenderHandler, cef_render_handler_t};
pub use interfaces::cef_render_process_handler::{CefRenderProcessHandler};
pub use interfaces::cef_render_process_handler::{cef_render_process_handler_t};
pub use interfaces::cef_request::{CefPostData, CefPostDataElement, CefRequest};
pub use interfaces::cef_request::{cef_post_data_element_t, cef_post_data_t, cef_request_t};
pub use interfaces::cef_request_context::{CefRequestContext, cef_request_context_t};
pub use interfaces::cef_request_context_handler::{CefRequestContextHandler};
pub use interfaces::cef_request_context_handler::{cef_request_context_handler_t};
pub use interfaces::cef_request_handler::{CefAllowCertificateErrorCallback, CefQuotaCallback};
pub use interfaces::cef_request_handler::{CefRequestHandler};
pub use interfaces::cef_request_handler::{cef_allow_certificate_error_callback_t};
pub use interfaces::cef_request_handler::{cef_quota_callback_t, cef_request_handler_t};
pub use interfaces::cef_resource_bundle_handler::{CefResourceBundleHandler};
pub use interfaces::cef_resource_bundle_handler::{cef_resource_bundle_handler_t};
pub use interfaces::cef_resource_handler::{CefResourceHandler, cef_resource_handler_t};
pub use interfaces::cef_response::{CefResponse, cef_response_t};
pub use interfaces::cef_scheme::{CefSchemeHandlerFactory, CefSchemeRegistrar};
pub use interfaces::cef_scheme::{cef_scheme_handler_factory_t, cef_scheme_registrar_t};
pub use interfaces::cef_stream::{CefReadHandler, CefStreamReader, CefStreamWriter};
pub use interfaces::cef_stream::{CefWriteHandler, cef_read_handler_t, cef_stream_reader_t};
pub use interfaces::cef_stream::{cef_stream_writer_t, cef_write_handler_t};
pub use interfaces::cef_string_visitor::{CefStringVisitor, cef_string_visitor_t};
pub use interfaces::cef_task::{CefTask, CefTaskRunner, cef_task_runner_t, cef_task_t};
pub use interfaces::cef_trace::{CefEndTracingCallback, cef_end_tracing_callback_t};
pub use interfaces::cef_urlrequest::{CefURLRequest, CefURLRequestClient, cef_urlrequest_client_t};
pub use interfaces::cef_urlrequest::{cef_urlrequest_t};
pub use interfaces::cef_v8::{CefV8Accessor, CefV8Context, CefV8Exception, CefV8Handler};
pub use interfaces::cef_v8::{CefV8StackFrame, CefV8StackTrace, CefV8Value, cef_v8accessor_t};
pub use interfaces::cef_v8::{cef_v8context_t, cef_v8exception_t, cef_v8handler_t};
pub use interfaces::cef_v8::{cef_v8stack_frame_t, cef_v8stack_trace_t, cef_v8value_t};
pub use interfaces::cef_values::{CefBinaryValue, CefDictionaryValue, CefListValue};
pub use interfaces::cef_values::{cef_binary_value_t, cef_dictionary_value_t, cef_list_value_t};
pub use interfaces::cef_web_plugin::{CefWebPluginInfo, CefWebPluginInfoVisitor};
pub use interfaces::cef_web_plugin::{CefWebPluginUnstableCallback, cef_web_plugin_info_t};
pub use interfaces::cef_web_plugin::{cef_web_plugin_info_visitor_t};
pub use interfaces::cef_web_plugin::{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::{CefBase, CefBrowserSettings, CefCookie, CefGeoposition, CefKeyEvent};
pub use types::{CefMouseEvent, CefPopupFeatures, CefProcessId, CefScreenInfo};
pub use types::{CefValueType, CefWindowInfo, cef_base_t};
pub use types::{cef_browser_settings_t, cef_cookie_t, cef_geoposition_t, cef_key_event_t};
pub use types::{cef_mouse_event_t, cef_point_t, cef_popup_features_t};
pub use types::{cef_process_id_t, cef_screen_info_t, cef_string_map_t};
pub use types::{cef_time_t, cef_value_type_t, cef_window_info_t};
pub mod cef_app;
pub mod cef_auth_callback;
pub mod cef_browser;
pub mod cef_browser_process_handler;
pub mod cef_callback;
pub mod cef_client;
pub mod cef_command_line;
pub mod cef_context_menu_handler;
pub mod cef_cookie;
pub mod cef_dialog_handler;
pub mod cef_display_handler;
pub mod cef_dom;
pub mod cef_download_handler;
pub mod cef_download_item;
pub mod cef_drag_data;
pub mod cef_drag_handler;
pub mod cef_focus_handler;
pub mod cef_frame;
pub mod cef_geolocation;
pub mod cef_geolocation_handler;
pub mod cef_jsdialog_handler;
pub mod cef_keyboard_handler;
pub mod cef_life_span_handler;
pub mod cef_load_handler;
pub mod cef_menu_model;
pub mod cef_print_handler;
pub mod cef_print_settings;
pub mod cef_process_message;
pub mod cef_render_handler;
pub mod cef_render_process_handler;
pub mod cef_request;
pub mod cef_request_context;
pub mod cef_request_context_handler;
pub mod cef_request_handler;
pub mod cef_resource_bundle_handler;
pub mod cef_resource_handler;
pub mod cef_response;
pub mod cef_scheme;
pub mod cef_stream;
pub mod cef_string_visitor;
pub mod cef_task;
pub mod cef_trace;
pub mod cef_urlrequest;
pub mod cef_v8;
pub mod cef_values;
pub mod cef_web_plugin;
pub mod cef_xml_reader;
pub mod cef_zip_reader;

Просмотреть файл

@ -44,19 +44,34 @@ extern crate core_graphics;
#[cfg(target_os="macos")]
extern crate core_text;
// Must come first.
pub mod macros;
pub mod browser;
pub mod command_line;
pub mod cookie;
pub mod core;
pub mod drag_data;
pub mod eutil;
#[cfg(any(target_os="linux",target_os="macos"))]
pub mod mem;
pub mod interfaces;
pub mod print_settings;
pub mod process_message;
pub mod request;
pub mod request_context;
pub mod response;
pub mod stream;
pub mod string;
pub mod string_list;
pub mod string_map;
pub mod string_multimap;
pub mod stubs;
pub mod switches;
pub mod task;
pub mod types;
pub mod urlrequest;
pub mod values;
pub mod v8;
pub mod wrappers;
pub mod xml_reader;
pub mod zip_reader;

128
servo/ports/cef/macros.rs Normal file
Просмотреть файл

@ -0,0 +1,128 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![macro_escape]
// Provides the implementation of a CEF class. An example follows:
//
// struct ServoCefThing {
// ...
// }
//
// cef_class_impl! {
// ServoCefThing : CefThing, cef_thing_t {
// // Declare method implementations using the *C* API. (This may change later, once we
// // have associated types in Rust.)
// //
// // Note that if the method returns unit, you must write `-> ()` explicitly. This is
// // due to limitations of Rust's macro system.
// fn foo(&this, a: int, b: *mut cef_other_thing_t) -> () {
// // Inside here, `a` will have type `int`, and `b` will have the type
// // `CefOtherThing` -- i.e. the Rust-wrapped version of `cef_other_thing_t`.
// ...
// }
//
// fn bar(&this, a: int) -> *mut cef_other_thing_t {
// // Return types are automatically unwrapped from the Rust types (e.g.
// // `CefOtherThing`) into the corresponding C types (e.g. `*mut
// // cef_other_thing_t`).
// let x: CefOtherThing = ...;
// x
// }
// }
// }
macro_rules! cef_class_impl(
($class_name:ident : $interface_name:ident, $c_interface_name:ident {
$(
fn $method_name:ident ( & $method_this:ident
$( , $method_arg_name:ident : $method_arg_type:ty )* )
-> $method_return_type:ty $method_body:block
)*
}) => (
impl $class_name {
pub fn as_cef_interface(self) -> $interface_name {
let cef_object = unsafe {
// Calculate the offset of the reference count. This is the size of the
// structure.
let null: *const $c_interface_name = ::std::ptr::null();
let offset: *const uint = &(*null).ref_count;
let size = (offset as ::libc::size_t) - (null as ::libc::size_t);
$interface_name::from_c_object_addref(
::eutil::create_cef_object::<$c_interface_name,$class_name>(size))
};
unsafe {
$((*cef_object.c_object()).$method_name = Some($method_name);)*
let extra_slot =
::std::mem::transmute::<&mut u8,
&mut $class_name>(&mut (*cef_object.c_object())
.extra);
::std::ptr::write(extra_slot, self);
}
cef_object
}
}
$(
extern "C" fn $method_name(raw_this: *mut $c_interface_name,
$($method_arg_name: $method_arg_type),*)
-> $method_return_type {
let $method_this = unsafe {
$interface_name::from_c_object_addref(raw_this)
};
$(
let $method_arg_name = unsafe {
::wrappers::CefWrap::to_rust($method_arg_name)
};
)*
::wrappers::CefWrap::to_c($method_body)
}
)*
impl ::eutil::Downcast<$class_name> for $interface_name {
fn downcast(&self) -> &$class_name {
unsafe {
::std::mem::transmute::<&u8,&$class_name>(&(*self.c_object()).extra)
}
}
}
)
)
macro_rules! cef_static_method_impls(
(
$(
fn $method_name:ident ( $($method_arg_name:ident : $method_arg_type:ty ),* )
-> $method_return_type:ty $method_body:block
)*
) => (
$(
#[no_mangle]
pub extern "C" fn $method_name($($method_arg_name: $method_arg_type),*)
-> $method_return_type {
$(
let $method_arg_name = unsafe {
::wrappers::CefWrap::to_rust($method_arg_name)
};
)*
::wrappers::CefWrap::to_c($method_body)
}
)*
)
)
macro_rules! cef_stub_static_method_impls(
(
$(
fn $method_name:ident ( $($method_arg_name:ident : $method_arg_type:ty ),* )
-> $method_return_type:ty ;
)*
) => (
$(
pub extern "C" fn $method_name($(_: $method_arg_type),*)
-> $method_return_type {
panic!("unimplemented static method: {}", stringify!($method_name))
}
)*
)
)

Просмотреть файл

@ -1,61 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use libc::{c_void, size_t};
use std::mem;
use std::ptr::set_memory;
// -U _tc_* needed on OS X, but won't work on other platforms
#[cfg(target_os="macos")]
#[link_args="-Wl,-U,_tc_new -Wl,-U,_tc_newarray -Wl,-U,_tc_delete -Wl,-U,_tc_deletearray"]
extern {}
extern "C" {
fn tc_new(size: size_t) -> *mut c_void;
fn tc_delete(mem: *mut c_void);
fn tc_newarray(size: size_t) -> *mut c_void;
fn tc_deletearray(mem: *mut c_void);
}
#[allow(experimental)]
pub fn newarray0<T>(nmem: size_t) -> *mut T {
let mem = newarray::<T>(nmem) as *mut T;
unsafe {
set_memory(mem, 0 as u8, nmem as uint);
}
mem
}
pub fn newarray<T>(nmem: size_t) -> *mut T {
unsafe {
tc_newarray(nmem * mem::size_of::<T>() as size_t) as *mut T
}
}
#[allow(experimental)]
pub fn new0<T>(nmem: size_t) -> *mut T {
let mem = new(nmem * mem::size_of::<T>() as size_t) as *mut T;
unsafe {
set_memory(mem, 0 as u8, nmem as uint);
}
mem
}
pub fn new(size: size_t) -> *mut c_void {
unsafe {
tc_new(size)
}
}
pub fn delete(mem: *mut c_void) {
unsafe {
tc_delete(mem)
}
}
pub fn deletearray(mem: *mut c_void) {
unsafe {
tc_deletearray(mem)
}
}

Просмотреть файл

@ -0,0 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::cef_print_settings_t;
cef_stub_static_method_impls! {
fn cef_print_settings_create() -> *mut cef_print_settings_t;
}

Просмотреть файл

@ -0,0 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::cef_process_message_t;
use types::cef_string_t;
cef_stub_static_method_impls! {
fn cef_process_message_create(name: *const cef_string_t) -> *mut cef_process_message_t;
}

Просмотреть файл

@ -2,20 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::{cef_post_data_element_t, cef_post_data_t, cef_request_t};
use types::{cef_post_data_element_t, cef_post_data_t, cef_request_t};
#[no_mangle]
pub extern "C" fn cef_request_create() -> *mut cef_request_t {
0 as *mut cef_request_t
cef_stub_static_method_impls! {
fn cef_request_create() -> *mut cef_request_t;
fn cef_post_data_create() -> *mut cef_post_data_t;
fn cef_post_data_element_create() -> *mut cef_post_data_element_t;
}
#[no_mangle]
pub extern "C" fn cef_post_data_create() -> *mut cef_post_data_t {
0 as *mut cef_post_data_t
}
#[no_mangle]
pub extern "C" fn cef_post_data_element_create() -> *mut cef_post_data_element_t {
0 as *mut cef_post_data_element_t
}

Просмотреть файл

@ -0,0 +1,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::{cef_request_context_handler_t, cef_request_context_t};
cef_stub_static_method_impls! {
fn cef_request_context_get_global_context() -> *mut cef_request_context_t;
fn cef_request_context_create_context(_handler: *mut cef_request_context_handler_t)
-> *mut cef_request_context_t;
}

Просмотреть файл

@ -0,0 +1,10 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::cef_response_t;
cef_stub_static_method_impls! {
fn cef_response_create() -> *mut cef_response_t;
}

23
servo/ports/cef/stream.rs Normal file
Просмотреть файл

@ -0,0 +1,23 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::{cef_read_handler_t, cef_stream_reader_t, cef_stream_writer_t};
use interfaces::{cef_write_handler_t};
use types::cef_string_t;
use libc;
cef_stub_static_method_impls! {
fn cef_stream_reader_create_for_file(_file_name: *const cef_string_t)
-> *mut cef_stream_reader_t;
fn cef_stream_reader_create_for_data(_data: *mut (), _size: libc::size_t)
-> *mut cef_stream_reader_t;
fn cef_stream_reader_create_for_handler(_handler: *mut cef_read_handler_t)
-> *mut cef_stream_reader_t;
fn cef_stream_writer_create_for_file(_file_name: *const cef_string_t)
-> *mut cef_stream_writer_t;
fn cef_stream_writer_create_for_handler(_handler: *mut cef_write_handler_t)
-> *mut cef_stream_writer_t;
}

Просмотреть файл

@ -4,9 +4,8 @@
use eutil::slice_to_str;
use libc::{size_t, c_int, c_ushort,c_void};
use libc::{mod, size_t, c_int, c_ushort,c_void};
use libc::types::os::arch::c95::wchar_t;
use mem::{new0,newarray0,delete,deletearray};
use std::char;
use std::mem;
use std::ptr;
@ -19,35 +18,47 @@ use types::{cef_string_userfree_utf16_t, cef_string_userfree_utf8_t, cef_string_
#[no_mangle]
extern "C" fn string_wide_dtor(str: *mut wchar_t) {
deletearray(str as *mut c_void)
unsafe {
libc::free(str as *mut c_void)
}
}
#[no_mangle]
extern "C" fn string_utf8_dtor(str: *mut u8) {
deletearray(str as *mut c_void)
unsafe {
libc::free(str as *mut c_void)
}
}
#[no_mangle]
extern "C" fn string_utf16_dtor(str: *mut c_ushort) {
deletearray(str as *mut c_void)
unsafe {
libc::free(str as *mut c_void)
}
}
#[no_mangle]
pub extern "C" fn cef_string_userfree_wide_free(cs: *mut cef_string_userfree_wide_t) {
cef_string_wide_clear(cs);
delete(cs as *mut c_void)
cef_string_wide_clear(cs);
unsafe {
libc::free(cs as *mut c_void)
}
}
#[no_mangle]
pub extern "C" fn cef_string_userfree_utf8_free(cs: *mut cef_string_userfree_utf8_t) {
cef_string_utf8_clear(cs);
delete(cs as *mut c_void)
unsafe {
cef_string_utf8_clear(cs);
libc::free(cs as *mut c_void)
}
}
#[no_mangle]
pub extern "C" fn cef_string_userfree_utf16_free(cs: *mut cef_string_userfree_utf16_t) {
cef_string_utf16_clear(cs);
delete(cs as *mut c_void)
unsafe {
cef_string_utf16_clear(cs);
libc::free(cs as *mut c_void)
}
}
#[no_mangle]
@ -60,10 +71,12 @@ pub extern "C" fn cef_string_utf8_clear(cs: *mut cef_string_utf8_t) {
}
}
#[inline(never)]
#[no_mangle]
pub extern "C" fn cef_string_userfree_utf8_alloc() -> *mut cef_string_utf8_t {
#![inline(never)]
new0::<cef_string_utf8_t>(1)
unsafe {
libc::malloc(mem::size_of::<cef_string_utf8_t>() as u64) as *mut cef_string_utf8_t
}
}
#[no_mangle]
@ -72,7 +85,7 @@ pub extern "C" fn cef_string_utf8_set(src: *const u8, src_len: size_t, output: *
unsafe {
if copy != 0 {
if !src.is_null() && src_len > 0 {
(*output).str = newarray0::<u8>(src_len + 1);
(*output).str = libc::malloc(src_len + 1) as *mut u8;
if (*output).str.is_null() {
return 0;
}
@ -139,10 +152,12 @@ pub extern "C" fn cef_string_utf16_clear(cs: *mut cef_string_utf16_t) {
}
}
#[inline(never)]
#[no_mangle]
pub extern "C" fn cef_string_userfree_utf16_alloc() -> *mut cef_string_utf16_t {
#![inline(never)]
new0::<cef_string_utf16_t>(1)
unsafe {
libc::malloc(mem::size_of::<cef_string_utf16_t>() as u64) as *mut cef_string_utf16_t
}
}
#[no_mangle]
@ -151,7 +166,8 @@ pub extern "C" fn cef_string_utf16_set(src: *const c_ushort, src_len: size_t, ou
unsafe {
if copy != 0 {
if !src.is_null() && src_len > 0 {
(*output).str = newarray0::<c_ushort>(src_len + 1);
(*output).str = libc::malloc((src_len + 1) * mem::size_of::<c_ushort>() as u64) as
*mut u16;
if (*output).str.is_null() {
return 0;
}
@ -194,10 +210,12 @@ pub extern "C" fn cef_string_wide_clear(cs: *mut cef_string_wide_t) {
}
}
#[inline(never)]
#[no_mangle]
pub extern "C" fn cef_string_userfree_wide_alloc() -> *mut cef_string_wide_t {
#![inline(never)]
new0::<cef_string_wide_t>(1)
unsafe {
libc::malloc(mem::size_of::<cef_string_wide_t>() as u64) as *mut cef_string_wide_t
}
}
#[no_mangle]
@ -206,7 +224,8 @@ pub extern "C" fn cef_string_wide_set(src: *const wchar_t, src_len: size_t, outp
unsafe {
if copy != 0 {
if !src.is_null() && src_len > 0 {
(*output).str = newarray0::<wchar_t>(src_len + 1);
(*output).str = libc::malloc((src_len + 1) * mem::size_of::<wchar_t>() as u64) as
*mut wchar_t;
if (*output).str.is_null() {
return 0;
}
@ -250,6 +269,19 @@ pub extern "C" fn cef_string_utf8_to_wide(src: *const u8, src_len: size_t, outpu
})
}
/// Wraps a borrowed reference to a UTF-16 CEF string.
pub struct CefStringRef<'a> {
pub c_object: &'a *const cef_string_utf16_t,
}
impl<'a> CefStringRef<'a> {
pub unsafe fn from_c_object(c_object: &'a *const cef_string_utf16_t) -> CefStringRef<'a> {
CefStringRef {
c_object: c_object,
}
}
}
#[no_mangle]
pub extern "C" fn cef_string_wide_to_utf8(src: *const wchar_t, src_len: size_t, output: *mut cef_string_utf8_t) -> c_int {
if mem::size_of::<wchar_t>() == mem::size_of::<u16>() {
@ -280,3 +312,12 @@ pub extern "C" fn cef_string_ascii_to_wide(src: *const u8, src_len: size_t, outp
})
}
}
pub fn empty_utf16_string() -> cef_string_utf16_t {
cef_string_utf16_t {
str: ptr::null_mut(),
length: 0,
dtor: None,
}
}

Просмотреть файл

@ -4,7 +4,7 @@
use libc::{c_int};
use std::mem;
use string::{cef_string_userfree_utf8_alloc,cef_string_userfree_utf8_free,cef_string_utf8_set};
use string::{cef_string_userfree_utf16_alloc,cef_string_userfree_utf16_free,cef_string_utf16_set};
use types::{cef_string_list_t,cef_string_t};
@ -36,8 +36,8 @@ pub extern "C" fn cef_string_list_append(lt: *mut cef_string_list_t, value: *con
unsafe {
if lt.is_null() { return; }
let v = string_list_to_vec(lt);
let cs = cef_string_userfree_utf8_alloc();
cef_string_utf8_set(mem::transmute((*value).str), (*value).length, cs, 1);
let cs = cef_string_userfree_utf16_alloc();
cef_string_utf16_set(mem::transmute((*value).str), (*value).length, cs, 1);
(*v).push(cs);
}
}
@ -49,7 +49,7 @@ pub extern "C" fn cef_string_list_value(lt: *mut cef_string_list_t, index: c_int
let v = string_list_to_vec(lt);
if index as uint > (*v).len() - 1 { return 0; }
let cs = (*v)[index as uint];
cef_string_utf8_set(mem::transmute((*cs).str), (*cs).length, value, 1)
cef_string_utf16_set(mem::transmute((*cs).str), (*cs).length, value, 1)
}
}
@ -62,7 +62,7 @@ pub extern "C" fn cef_string_list_clear(lt: *mut cef_string_list_t) {
let mut cs;
while (*v).len() != 0 {
cs = (*v).pop();
cef_string_userfree_utf8_free(cs.unwrap());
cef_string_userfree_utf16_free(cs.unwrap());
}
}
}

Просмотреть файл

@ -7,7 +7,8 @@ use libc::{c_int};
use std::collections::TreeMap;
use std::mem;
use std::string::String;
use string::{cef_string_userfree_utf8_alloc, cef_string_userfree_utf8_free, cef_string_utf8_set};
use string::{cef_string_userfree_utf16_alloc, cef_string_userfree_utf16_free};
use string::{cef_string_utf16_set};
use types::{cef_string_map_t, cef_string_t};
fn string_map_to_treemap(sm: *mut cef_string_map_t) -> *mut TreeMap<String, *mut cef_string_t> {
@ -40,8 +41,8 @@ pub extern "C" fn cef_string_map_append(sm: *mut cef_string_map_t, key: *const c
let v = string_map_to_treemap(sm);
slice_to_str((*key).str as *const u8, (*key).length as uint, |result| {
let s = String::from_str(result);
let csv = cef_string_userfree_utf8_alloc();
cef_string_utf8_set((*value).str as *const u8, (*value).length, csv, 1);
let csv = cef_string_userfree_utf16_alloc();
cef_string_utf16_set((*value).str as *const u16, (*value).length, csv, 1);
(*v).insert(s, csv);
1
})
@ -56,7 +57,7 @@ pub extern "C" fn cef_string_map_find(sm: *mut cef_string_map_t, key: *const cef
slice_to_str((*key).str as *const u8, (*key).length as uint, |result| {
match (*v).get(&String::from_str(result)) {
Some(s) => {
cef_string_utf8_set((**s).str as *const u8, (**s).length, value, 1);
cef_string_utf16_set((**s).str as *const u16, (**s).length, value, 1);
1
}
None => 0
@ -74,7 +75,10 @@ pub extern "C" fn cef_string_map_key(sm: *mut cef_string_map_t, index: c_int, va
for (i, k) in (*v).keys().enumerate() {
if i == index as uint {
cef_string_utf8_set(k.as_bytes().as_ptr(), k.len() as u64, value, 1);
cef_string_utf16_set(k.as_bytes().as_ptr() as *const u16,
k.len() as u64,
value,
1);
return 1;
}
}
@ -91,7 +95,7 @@ pub extern "C" fn cef_string_map_value(sm: *mut cef_string_map_t, index: c_int,
for (i, val) in (*v).values().enumerate() {
if i == index as uint {
cef_string_utf8_set((**val).str as *const u8, (**val).length, value, 1);
cef_string_utf16_set((**val).str as *const u16, (**val).length, value, 1);
return 1;
}
}
@ -105,7 +109,7 @@ pub extern "C" fn cef_string_map_clear(sm: *mut cef_string_map_t) {
if sm.is_null() { return; }
let v = string_map_to_treemap(sm);
for val in (*v).values() {
cef_string_userfree_utf8_free(*val);
cef_string_userfree_utf16_free(*val);
}
(*v).clear();
}

Просмотреть файл

@ -8,7 +8,7 @@ use std::collections::TreeMap;
use std::iter::AdditiveIterator;
use std::mem;
use std::string::String;
use string::{cef_string_userfree_utf8_alloc,cef_string_userfree_utf8_free,cef_string_utf8_set};
use string::{cef_string_userfree_utf16_alloc,cef_string_userfree_utf16_free,cef_string_utf16_set};
use types::{cef_string_multimap_t,cef_string_t};
fn string_multimap_to_treemap(smm: *mut cef_string_multimap_t) -> *mut TreeMap<String, Vec<*mut cef_string_t>> {
@ -55,8 +55,8 @@ pub extern "C" fn cef_string_multimap_append(smm: *mut cef_string_multimap_t, ke
let v = string_multimap_to_treemap(smm);
slice_to_str((*key).str as *const u8, (*key).length as uint, |result| {
let s = String::from_str(result);
let csv = cef_string_userfree_utf8_alloc();
cef_string_utf8_set((*value).str as *const u8, (*value).length, csv, 1);
let csv = cef_string_userfree_utf16_alloc();
cef_string_utf16_set((*value).str as *const u16, (*value).length, csv, 1);
match (*v).get_mut(&s) {
Some(vc) => (*vc).push(csv),
None => { (*v).insert(s, vec!(csv)); }
@ -78,7 +78,7 @@ pub extern "C" fn cef_string_multimap_enumerate(smm: *mut cef_string_multimap_t,
return 0;
}
let cs = (*s)[index as uint];
cef_string_utf8_set((*cs).str as *const u8, (*cs).length, value, 1)
cef_string_utf16_set((*cs).str as *const u16, (*cs).length, value, 1)
}
None => 0
}
@ -95,7 +95,10 @@ pub extern "C" fn cef_string_multimap_key(smm: *mut cef_string_multimap_t, index
for (key, val) in (*v).iter() {
if rem < (*val).len() {
return cef_string_utf8_set((*key).as_bytes().as_ptr(), (*key).len() as u64, value, 1);
return cef_string_utf16_set((*key).as_bytes().as_ptr() as *const u16,
(*key).len() as u64,
value,
1);
} else {
rem -= (*val).len();
}
@ -114,7 +117,7 @@ pub extern "C" fn cef_string_multimap_value(smm: *mut cef_string_multimap_t, ind
for val in (*v).values() {
if rem < (*val).len() {
let cs = (*val)[rem as uint];
return cef_string_utf8_set((*cs).str as *const u8, (*cs).length, value, 1);
return cef_string_utf16_set((*cs).str as *const u16, (*cs).length, value, 1);
} else {
rem -= (*val).len();
}
@ -132,7 +135,7 @@ pub extern "C" fn cef_string_multimap_clear(smm: *mut cef_string_multimap_t) {
for (_, val) in (*v).iter_mut() {
while (*val).len() != 0 {
let cs = (*val).pop();
cef_string_userfree_utf8_free(cs.unwrap());
cef_string_userfree_utf16_free(cs.unwrap());
}
}
(*v).clear();

53
servo/ports/cef/stubs.rs Normal file
Просмотреть файл

@ -0,0 +1,53 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Just some stubs so that you can link against this library in place of the
//! Chromium version of CEF. If you call these functions you will assuredly
//! crash.
macro_rules! stub(
($name:ident) => (
#[no_mangle]
pub extern "C" fn $name() {
println!("CEF stub function called: {}", stringify!($name));
unsafe {
::std::intrinsics::abort()
}
}
)
)
stub!(cef_add_cross_origin_whitelist_entry)
stub!(cef_add_web_plugin_directory)
stub!(cef_add_web_plugin_path)
stub!(cef_begin_tracing)
stub!(cef_clear_cross_origin_whitelist)
stub!(cef_clear_scheme_handler_factories)
stub!(cef_create_url)
stub!(cef_end_tracing)
stub!(cef_force_web_plugin_shutdown)
stub!(cef_get_current_platform_thread_handle)
stub!(cef_get_current_platform_thread_id)
stub!(cef_get_extensions_for_mime_type)
stub!(cef_get_geolocation)
stub!(cef_get_mime_type)
stub!(cef_get_path)
stub!(cef_is_web_plugin_unstable)
stub!(cef_launch_process)
stub!(cef_now_from_system_trace_time)
stub!(cef_parse_url)
stub!(cef_post_delayed_task)
stub!(cef_post_task)
stub!(cef_refresh_web_plugins)
stub!(cef_register_extension)
stub!(cef_register_scheme_handler_factory)
stub!(cef_register_web_plugin_crash)
stub!(cef_remove_cross_origin_whitelist_entry)
stub!(cef_remove_web_plugin_path)
stub!(cef_set_osmodal_loop)
stub!(cef_string_utf16_to_wide)
stub!(cef_string_wide_to_utf16)
stub!(cef_unregister_internal_web_plugin)
stub!(cef_visit_web_plugin_info)

Просмотреть файл

@ -2,11 +2,19 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use libc::c_int;
use interfaces::cef_task_runner_t;
use types::cef_thread_id_t;
use libc::c_int;
//FIXME: this should check the current servo task I guess?
#[no_mangle]
pub extern "C" fn cef_currently_on(_tid: cef_thread_id_t) -> c_int {
1
}
cef_stub_static_method_impls! {
fn cef_task_runner_get_for_current_thread() -> *mut cef_task_runner_t;
fn cef_task_runner_get_for_thread(thread_id: cef_thread_id_t) -> *mut cef_task_runner_t;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -2,9 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use types::{cef_request_t, cef_urlrequest_client_t, cef_urlrequest_t};
use interfaces::{cef_request_t, cef_urlrequest_client_t, cef_urlrequest_t};
#[no_mangle]
pub extern "C" fn cef_urlrequest_create(_request: *mut cef_request_t,

29
servo/ports/cef/v8.rs Normal file
Просмотреть файл

@ -0,0 +1,29 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::{cef_v8accessor_t, cef_v8context_t, cef_v8handler_t, cef_v8stack_trace_t};
use interfaces::{cef_v8value_t};
use types::{cef_string_t, cef_time_t};
use libc::{mod, c_double, c_int};
cef_stub_static_method_impls! {
fn cef_v8context_get_current_context() -> *mut cef_v8context_t;
fn cef_v8context_get_entered_context() -> *mut cef_v8context_t;
fn cef_v8context_in_context() -> libc::c_int;
fn cef_v8value_create_undefined() -> *mut cef_v8value_t;
fn cef_v8value_create_null() -> *mut cef_v8value_t;
fn cef_v8value_create_bool(_value: c_int) -> *mut cef_v8value_t;
fn cef_v8value_create_int(_value: i32) -> *mut cef_v8value_t;
fn cef_v8value_create_uint(_value: u32) -> *mut cef_v8value_t;
fn cef_v8value_create_double(_value: c_double) -> *mut cef_v8value_t;
fn cef_v8value_create_date(_date: *const cef_time_t) -> *mut cef_v8value_t;
fn cef_v8value_create_string(_value: *const cef_string_t) -> *mut cef_v8value_t;
fn cef_v8value_create_object(_accessor: *mut cef_v8accessor_t) -> *mut cef_v8value_t;
fn cef_v8value_create_array(_length: libc::c_int) -> *mut cef_v8value_t;
fn cef_v8value_create_function(_name: *const cef_string_t, _handler: *mut cef_v8handler_t)
-> *mut cef_v8value_t;
fn cef_v8stack_trace_get_current(_frame_limit: libc::c_int) -> *mut cef_v8stack_trace_t;
}

14
servo/ports/cef/values.rs Normal file
Просмотреть файл

@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::{cef_binary_value_t, cef_dictionary_value_t, cef_list_value_t};
use libc;
cef_stub_static_method_impls! {
fn cef_binary_value_create(_data: *const (), _size: libc::size_t) -> *mut cef_binary_value_t;
fn cef_dictionary_value_create() -> *mut cef_dictionary_value_t;
fn cef_list_value_create() -> *mut cef_list_value_t;
}

250
servo/ports/cef/wrappers.rs Normal file
Просмотреть файл

@ -0,0 +1,250 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::{cef_drag_data_t, cef_post_data_element_t, cef_v8value_t, CefPostDataElement};
use interfaces::{CefV8Value};
use types::{cef_base_t, cef_browser_settings_t, cef_color_model_t};
use types::{cef_context_menu_edit_state_flags_t, cef_context_menu_handler_t};
use types::{cef_context_menu_media_state_flags_t};
use types::{cef_context_menu_media_type_t, cef_context_menu_type_flags_t, cef_cookie_t};
use types::{cef_dialog_handler_t};
use types::{cef_dom_document_type_t, cef_dom_node_type_t};
use types::{cef_download_handler_t, cef_drag_handler_t};
use types::{cef_drag_operations_mask_t, cef_duplex_mode_t};
use types::{cef_errorcode_t, cef_event_flags_t, cef_event_handle_t};
use types::{cef_file_dialog_mode_t, cef_focus_handler_t, cef_focus_source_t};
use types::{cef_geolocation_handler_t, cef_geoposition_t};
use types::{cef_jsdialog_handler_t, cef_jsdialog_type_t};
use types::{cef_key_event, cef_keyboard_handler_t};
use types::{cef_load_handler_t, cef_menu_item_type_t, cef_mouse_button_type_t};
use types::{cef_mouse_event, cef_navigation_type_t};
use types::{cef_page_range_t, cef_paint_element_type_t, cef_point_t, cef_postdataelement_type_t};
use types::{cef_popup_features_t, cef_process_id_t};
use types::{cef_rect_t, cef_request_context_t, cef_request_handler_t};
use types::{cef_resource_type_t};
use types::{cef_screen_info_t, cef_size_t, cef_string_t};
use types::{cef_string_list_t, cef_string_map_t, cef_string_multimap_t, cef_string_utf16};
use types::{cef_termination_status_t, cef_text_input_context_t, cef_thread_id_t};
use types::{cef_time_t, cef_transition_type_t, cef_urlrequest_status_t};
use types::{cef_v8_accesscontrol_t, cef_v8_propertyattribute_t, cef_value_type_t};
use types::{cef_window_info_t, cef_xml_encoding_type_t, cef_xml_node_type_t};
use libc::{mod, c_char, c_int, c_ushort, c_void};
use std::collections::HashMap;
use std::mem;
use std::ptr;
pub trait CefWrap<CObject> {
fn to_c(rust_object: Self) -> CObject;
unsafe fn to_rust(c_object: CObject) -> Self;
}
macro_rules! cef_noop_wrapper(
($ty:ty) => (
impl CefWrap<$ty> for $ty {
fn to_c(rust_object: $ty) -> $ty {
rust_object
}
unsafe fn to_rust(c_object: $ty) -> $ty {
c_object
}
}
)
)
macro_rules! cef_pointer_wrapper(
($ty:ty) => (
impl<'a> CefWrap<*const $ty> for &'a $ty {
fn to_c(rust_object: &'a $ty) -> *const $ty {
rust_object
}
unsafe fn to_rust(c_object: *const $ty) -> &'a $ty {
mem::transmute::<*const $ty,&'a $ty>(c_object)
}
}
impl<'a> CefWrap<*mut $ty> for &'a mut $ty {
fn to_c(rust_object: &'a mut $ty) -> *mut $ty {
rust_object
}
unsafe fn to_rust(c_object: *mut $ty) -> &'a mut $ty {
mem::transmute::<*mut $ty,&'a mut $ty>(c_object)
}
}
cef_noop_wrapper!(*const $ty)
cef_noop_wrapper!(*mut $ty)
)
)
macro_rules! cef_unimplemented_wrapper(
($c_type:ty, $rust_type:ty) => (
impl CefWrap<$c_type> for $rust_type {
fn to_c(_: $rust_type) -> $c_type {
panic!("unimplemented CEF type conversion: {}", stringify!($c_type))
}
unsafe fn to_rust(_: $c_type) -> $rust_type {
panic!("unimplemented CEF type conversion: {}", stringify!($c_type))
}
}
)
)
cef_pointer_wrapper!(())
cef_pointer_wrapper!(*mut ())
cef_pointer_wrapper!(*mut c_void)
cef_pointer_wrapper!(c_void)
cef_pointer_wrapper!(cef_base_t)
cef_pointer_wrapper!(cef_browser_settings_t)
cef_pointer_wrapper!(cef_cookie_t)
cef_pointer_wrapper!(cef_geoposition_t)
cef_pointer_wrapper!(cef_key_event)
cef_pointer_wrapper!(cef_mouse_event)
cef_pointer_wrapper!(cef_page_range_t)
cef_pointer_wrapper!(cef_point_t)
cef_pointer_wrapper!(cef_popup_features_t)
cef_pointer_wrapper!(cef_rect_t)
cef_pointer_wrapper!(cef_screen_info_t)
cef_pointer_wrapper!(cef_size_t)
cef_pointer_wrapper!(cef_time_t)
cef_pointer_wrapper!(cef_window_info_t)
cef_pointer_wrapper!(i32)
cef_pointer_wrapper!(i64)
cef_pointer_wrapper!(u32)
cef_pointer_wrapper!(u64)
cef_noop_wrapper!(())
cef_noop_wrapper!(*const cef_geolocation_handler_t)
cef_noop_wrapper!(*const cef_string_utf16)
cef_noop_wrapper!(*mut cef_context_menu_handler_t)
cef_noop_wrapper!(*mut cef_dialog_handler_t)
cef_noop_wrapper!(*mut cef_download_handler_t)
cef_noop_wrapper!(*mut cef_drag_data_t)
cef_noop_wrapper!(*mut cef_drag_handler_t)
cef_noop_wrapper!(*mut cef_event_handle_t)
cef_noop_wrapper!(*mut cef_focus_handler_t)
cef_noop_wrapper!(*mut cef_geolocation_handler_t)
cef_noop_wrapper!(*mut cef_jsdialog_handler_t)
cef_noop_wrapper!(*mut cef_keyboard_handler_t)
cef_noop_wrapper!(*mut cef_load_handler_t)
cef_noop_wrapper!(*mut cef_request_context_t)
cef_noop_wrapper!(*mut cef_request_handler_t)
cef_noop_wrapper!(*mut cef_string_list_t)
cef_noop_wrapper!(*mut cef_string_utf16)
cef_noop_wrapper!(c_int)
cef_noop_wrapper!(cef_color_model_t)
cef_noop_wrapper!(cef_context_menu_edit_state_flags_t)
cef_noop_wrapper!(cef_context_menu_media_state_flags_t)
cef_noop_wrapper!(cef_context_menu_media_type_t)
cef_noop_wrapper!(cef_context_menu_type_flags_t)
cef_noop_wrapper!(cef_dom_document_type_t)
cef_noop_wrapper!(cef_dom_node_type_t)
cef_noop_wrapper!(cef_drag_operations_mask_t)
cef_noop_wrapper!(cef_duplex_mode_t)
cef_noop_wrapper!(cef_errorcode_t)
cef_noop_wrapper!(cef_event_flags_t)
cef_noop_wrapper!(cef_event_handle_t)
cef_noop_wrapper!(cef_file_dialog_mode_t)
cef_noop_wrapper!(cef_focus_source_t)
cef_noop_wrapper!(cef_jsdialog_handler_t)
cef_noop_wrapper!(cef_jsdialog_type_t)
cef_noop_wrapper!(cef_key_event)
cef_noop_wrapper!(cef_menu_item_type_t)
cef_noop_wrapper!(cef_mouse_button_type_t)
cef_noop_wrapper!(cef_navigation_type_t)
cef_noop_wrapper!(cef_paint_element_type_t)
cef_noop_wrapper!(cef_postdataelement_type_t)
cef_noop_wrapper!(cef_process_id_t)
cef_noop_wrapper!(cef_resource_type_t)
cef_noop_wrapper!(cef_termination_status_t)
cef_noop_wrapper!(cef_text_input_context_t)
cef_noop_wrapper!(cef_thread_id_t)
cef_noop_wrapper!(cef_time_t)
cef_noop_wrapper!(cef_transition_type_t)
cef_noop_wrapper!(cef_urlrequest_status_t)
cef_noop_wrapper!(cef_v8_accesscontrol_t)
cef_noop_wrapper!(cef_v8_propertyattribute_t)
cef_noop_wrapper!(cef_value_type_t)
cef_noop_wrapper!(cef_xml_encoding_type_t)
cef_noop_wrapper!(cef_xml_node_type_t)
cef_noop_wrapper!(f64)
cef_noop_wrapper!(i64)
cef_noop_wrapper!(u32)
cef_noop_wrapper!(u64)
cef_unimplemented_wrapper!(*const *mut cef_v8value_t, *const CefV8Value)
cef_unimplemented_wrapper!(*mut *mut cef_post_data_element_t, *mut CefPostDataElement)
cef_unimplemented_wrapper!(cef_string_list_t, Vec<String>)
cef_unimplemented_wrapper!(cef_string_map_t, HashMap<String,String>)
cef_unimplemented_wrapper!(cef_string_multimap_t, HashMap<String,Vec<String>>)
cef_unimplemented_wrapper!(cef_string_t, String)
impl<'a> CefWrap<*const cef_string_t> for &'a [u16] {
fn to_c(buffer: &'a [u16]) -> *const cef_string_t {
unsafe {
let ptr: *mut c_ushort = mem::transmute(libc::malloc(((buffer.len() * 2) + 1) as u64));
ptr::copy_memory(ptr, mem::transmute(buffer.as_ptr()), (buffer.len() * 2) as uint);
*ptr.offset(buffer.len() as int) = 0;
// FIXME(pcwalton): This leaks!! We should instead have the caller pass some scratch
// stack space to create the object in. What a botch.
let boxed_string = box cef_string_utf16 {
str: ptr,
length: buffer.len() as u64,
dtor: Some(free_boxed_utf16_string),
};
let result: *const cef_string_utf16 = &*boxed_string;
mem::forget(boxed_string);
result
}
}
unsafe fn to_rust(cef_string: *const cef_string_t) -> &'a [u16] {
let (ptr, len): (*mut c_ushort, uint) = ((*cef_string).str, (*cef_string).length as uint);
mem::transmute((ptr, len))
}
}
extern "C" fn free_boxed_utf16_string(string: *mut c_ushort) {
unsafe {
libc::free(string as *mut c_void)
}
}
impl<'a> CefWrap<*mut cef_string_t> for &'a mut [u16] {
fn to_c(_: &'a mut [u16]) -> *mut cef_string_t {
panic!("unimplemented CEF type conversion: &'a str")
}
unsafe fn to_rust(_: *mut cef_string_t) -> &'a mut [u16] {
mem::transmute::<(int,int),_>(panic!("unimplemented CEF type conversion: *mut \
cef_string_t"))
}
}
// FIXME(pcwalton): This is pretty bogus, but it's only used for `init_from_argv`, which should
// never be called by Rust programs anyway. We should fix the wrapper generation though.
impl<'a,'b> CefWrap<*const *const c_char> for &'a &'b str {
fn to_c(_: &'a &'b str) -> *const *const c_char {
panic!("unimplemented CEF type conversion: &'a &'b str")
}
unsafe fn to_rust(_: *const *const c_char) -> &'a &'b str {
panic!("unimplemented CEF type conversion: *const *const cef_string_t")
}
}
impl<'a,'b> CefWrap<*mut *const c_char> for &'a mut &'b str {
fn to_c(_: &'a mut &'b str) -> *mut *const c_char {
panic!("unimplemented CEF type conversion: &'a mut &'b str")
}
unsafe fn to_rust(_: *mut *const c_char) -> &'a mut &'b str {
panic!("unimplemented CEF type conversion: *mut *const c_char")
}
}
impl<'a> CefWrap<cef_string_t> for &'a mut String {
fn to_c(_: &'a mut String) -> cef_string_t {
panic!("unimplemented CEF type conversion: &'a mut String")
}
unsafe fn to_rust(_: cef_string_t) -> &'a mut String {
panic!("unimplemented CEF type conversion: cef_string_t")
}
}

Просмотреть файл

@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::{cef_stream_reader_t, cef_xml_reader_t};
use types::{cef_string_t, cef_xml_encoding_type_t};
cef_stub_static_method_impls! {
fn cef_xml_reader_create(stream: *mut cef_stream_reader_t,
encoding_type: cef_xml_encoding_type_t,
uri: *const cef_string_t)
-> *mut cef_xml_reader_t;
}

Просмотреть файл

@ -0,0 +1,10 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use interfaces::{cef_stream_reader_t, cef_zip_reader_t};
cef_stub_static_method_impls! {
fn cef_zip_reader_create(stream: *mut cef_stream_reader_t) -> *mut cef_zip_reader_t;
}